@@ -5,11 +5,11 @@ use regex::Regex;
55use std:: collections:: HashSet ;
66use std:: fs;
77use std:: thread;
8- use time:: PreciseTime ;
8+ use time:: Instant ;
99use yaml_rust:: YamlLoader ;
1010
1111fn main ( ) -> std:: io:: Result < ( ) > {
12- let start = PreciseTime :: now ( ) ;
12+ let start = Instant :: now ( ) ;
1313 let with_sorting = false ;
1414 let outdir = "words" ;
1515 fs:: create_dir_all ( outdir) ?;
@@ -23,7 +23,7 @@ fn main() -> std::io::Result<()> {
2323 let wg = wg. clone ( ) ;
2424 thread:: spawn ( move || {
2525 let filepath = path. to_str ( ) . unwrap ( ) . replace ( ".yml" , ".txt" ) ;
26- println ! ( "{:?}" , filepath) ;
26+ // println!("{:?}", filepath);
2727 let text = fs:: read_to_string ( & filepath)
2828 . unwrap ( )
2929 . to_lowercase ( )
@@ -41,22 +41,22 @@ fn main() -> std::io::Result<()> {
4141 let docs = YamlLoader :: load_from_str ( & yaml) . unwrap ( ) ;
4242 let meta = & docs[ 0 ] ;
4343 let out = format ! (
44- "{}/extracted-words-for -{}.txt" ,
44+ "{}/{} -{}.txt" ,
4545 outdir,
46- meta[ "label" ] . as_str( ) . unwrap( )
46+ meta[ "lang" ] . as_str( ) . unwrap( ) ,
47+ meta[ "code" ] . as_str( ) . unwrap( )
4748 ) ;
48- fs:: write ( out, words. join ( "\n " ) ) ;
49-
49+ if let Err ( e) = fs:: write ( out, words. join ( "\n " ) ) {
50+ println ! ( "Writing error: {}" , e. to_string( ) ) ;
51+ }
5052 drop ( wg) ;
5153 } ) ;
5254 }
5355 Err ( e) => println ! ( "{:?}" , e) ,
5456 }
5557 }
5658 wg. wait ( ) ;
57- let end = PreciseTime :: now ( ) ;
58- println ! ( "{:?} seconds." , start . to ( end) ) ;
59+ let end = Instant :: now ( ) ;
60+ println ! ( "{:?} seconds." , end - start ) ;
5961 Ok ( ( ) )
6062}
61-
62- // 2s
0 commit comments