@@ -3,12 +3,16 @@ use fst::raw::{Fst, Output};
3
3
/// Final-state-transducer (FST) Segmenter
4
4
pub ( crate ) struct FstSegmenter < ' fst > {
5
5
words_fst : & ' fst Fst < & ' fst [ u8 ] > ,
6
- min_length : Option < usize > , // Optional minimum length for a word to be segmented
7
- allow_char_split : bool , // Flag to allow or disallow splitting words into characters
6
+ min_length : Option < usize > , // Optional minimum length for a word to be segmented
7
+ allow_char_split : bool , // Flag to allow or disallow splitting words into characters
8
8
}
9
9
10
10
impl < ' fst > FstSegmenter < ' fst > {
11
- pub ( crate ) fn new ( words_fst : & ' fst Fst < & ' fst [ u8 ] > , min_length : Option < usize > , allow_char_split : bool ) -> Self {
11
+ pub ( crate ) fn new (
12
+ words_fst : & ' fst Fst < & ' fst [ u8 ] > ,
13
+ min_length : Option < usize > ,
14
+ allow_char_split : bool ,
15
+ ) -> Self {
12
16
Self { words_fst, min_length, allow_char_split }
13
17
}
14
18
@@ -66,7 +70,8 @@ impl<'fst> FstSegmenter<'fst> {
66
70
67
71
Box :: new ( iter)
68
72
}
69
- } /// find the longest key that is prefix of the given value.
73
+ }
74
+ /// find the longest key that is prefix of the given value.
70
75
#[ inline]
71
76
fn find_longest_prefix ( fst : & Fst < & [ u8 ] > , value : & [ u8 ] ) -> Option < ( u64 , usize ) > {
72
77
let mut node = fst. root ( ) ;
@@ -85,4 +90,4 @@ fn find_longest_prefix(fst: &Fst<&[u8]>, value: &[u8]) -> Option<(u64, usize)> {
85
90
}
86
91
}
87
92
last_match
88
- }
93
+ }
0 commit comments