@@ -15,14 +15,14 @@ static JIEBA: OnceCell<Jieba> = OnceCell::new();
1515static TFIDF_INSTANCE : OnceCell < TFIDF > = OnceCell :: new ( ) ;
1616
1717#[ napi]
18- fn load ( ) -> Result < ( ) > {
18+ pub fn load ( ) -> Result < ( ) > {
1919 assert_not_init ( ) ?;
2020 let _ = JIEBA . get_or_init ( Jieba :: new) ;
2121 Ok ( ( ) )
2222}
2323
2424#[ napi]
25- fn load_dict ( dict : Buffer ) -> Result < ( ) > {
25+ pub fn load_dict ( dict : Buffer ) -> Result < ( ) > {
2626 assert_not_init ( ) ?;
2727 let mut readable_dict: & [ u8 ] = & dict;
2828 JIEBA . get_or_init ( || {
@@ -50,7 +50,7 @@ fn assert_not_init() -> Result<()> {
5050}
5151
5252#[ napi( ts_return_type = "string[]" ) ]
53- fn cut ( env : Env , sentence : Either < String , Buffer > , hmm : Option < bool > ) -> Result < Array > {
53+ pub fn cut ( env : Env , sentence : Either < String , Buffer > , hmm : Option < bool > ) -> Result < Array > {
5454 let hmm = hmm. unwrap_or ( false ) ;
5555 let jieba = JIEBA . get_or_init ( Jieba :: new) ;
5656 let cutted = jieba. cut (
@@ -66,7 +66,7 @@ fn cut(env: Env, sentence: Either<String, Buffer>, hmm: Option<bool>) -> Result<
6666}
6767
6868#[ napi( ts_return_type = "string[]" ) ]
69- fn cut_all ( env : Env , sentence : Either < String , Buffer > ) -> Result < Array > {
69+ pub fn cut_all ( env : Env , sentence : Either < String , Buffer > ) -> Result < Array > {
7070 let jieba = JIEBA . get_or_init ( Jieba :: new) ;
7171 let cutted = jieba. cut_all ( match & sentence {
7272 Either :: A ( s) => s. as_str ( ) ,
@@ -79,7 +79,11 @@ fn cut_all(env: Env, sentence: Either<String, Buffer>) -> Result<Array> {
7979}
8080
8181#[ napi( ts_return_type = "string[]" ) ]
82- fn cut_for_search ( env : Env , sentence : Either < String , Buffer > , hmm : Option < bool > ) -> Result < Array > {
82+ pub fn cut_for_search (
83+ env : Env ,
84+ sentence : Either < String , Buffer > ,
85+ hmm : Option < bool > ,
86+ ) -> Result < Array > {
8387 let hmm = hmm. unwrap_or ( false ) ;
8488 let jieba = JIEBA . get_or_init ( Jieba :: new) ;
8589 let cutted = jieba. cut_for_search (
@@ -96,13 +100,13 @@ fn cut_for_search(env: Env, sentence: Either<String, Buffer>, hmm: Option<bool>)
96100}
97101
98102#[ napi( object) ]
99- struct TaggedWord {
103+ pub struct TaggedWord {
100104 pub tag : String ,
101105 pub word : String ,
102106}
103107
104108#[ napi]
105- fn tag ( sentence : Either < String , Buffer > , hmm : Option < bool > ) -> Result < Vec < TaggedWord > > {
109+ pub fn tag ( sentence : Either < String , Buffer > , hmm : Option < bool > ) -> Result < Vec < TaggedWord > > {
106110 let jieba = JIEBA . get_or_init ( Jieba :: new) ;
107111 let tagged = jieba. tag (
108112 match & sentence {
@@ -132,7 +136,7 @@ pub struct Keyword {
132136}
133137
134138#[ napi]
135- fn extract (
139+ pub fn extract (
136140 sentence : Either < String , Buffer > ,
137141 topn : u32 ,
138142 allowed_pos : Option < String > ,
@@ -176,7 +180,7 @@ fn extract(
176180}
177181
178182#[ napi( js_name = "loadTFIDFDict" ) ]
179- fn load_tfidf_dict ( dict : Buffer ) -> Result < ( ) > {
183+ pub fn load_tfidf_dict ( dict : Buffer ) -> Result < ( ) > {
180184 let mut readable_dict: & [ u8 ] = & dict;
181185 if TFIDF_INSTANCE . get ( ) . is_some ( ) {
182186 return Err ( Error :: new (
0 commit comments