File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -248,13 +248,17 @@ impl From<Tagger> for TaggerFields {
248248impl From < TaggerFields > for Tagger {
249249 fn from ( data : TaggerFields ) -> Self {
250250 let word_store_fst = Map :: new ( data. word_store_fst ) . unwrap ( ) ;
251- let word_store: BiMap < String , WordIdInt > = word_store_fst
252- . into_stream ( )
253- . into_str_vec ( )
254- . unwrap ( )
255- . into_iter ( )
256- . map ( |( key, value) | ( key, WordIdInt ( value as u32 ) ) )
257- . collect ( ) ;
251+ let mut word_store: BiMap < String , WordIdInt > = BiMap :: with_capacity ( word_store_fst. len ( ) ) ;
252+ let mut stream = word_store_fst. into_stream ( ) ;
253+
254+ while let Some ( ( key, value) ) = stream. next ( ) {
255+ word_store. insert (
256+ std:: str:: from_utf8 ( key)
257+ . expect ( "word store keys are valid utf-8." )
258+ . to_owned ( ) ,
259+ WordIdInt ( value as u32 ) ,
260+ ) ;
261+ }
258262
259263 let mut tags = DefaultHashMap :: new ( ) ;
260264 let mut groups = DefaultHashMap :: new ( ) ;
You can’t perform that action at this time.
0 commit comments