@@ -3,42 +3,54 @@ extern crate rustling;
33extern crate rustling_ontology_grammar as grammar;
44extern crate rustling_ontology_values;
55extern crate serde;
6- #[ macro_use]
7- extern crate serde_derive;
86
9- #[ path= "src/parser.rs" ]
7+ #[ path = "src/parser.rs" ]
108mod parser;
119
12- use std:: thread:: { self , JoinHandle } ;
13- use std:: { path, env, fs} ;
1410use grammar:: Lang ;
11+ use std:: thread:: { self , JoinHandle } ;
12+ use std:: { env, fs, path} ;
1513
1614pub fn train_async ( lang : Lang ) -> JoinHandle < ( ) > {
17- println ! ( "cargo:rerun-if-changed=grammar/{}/src/" , lang. to_string( ) . to_lowercase( ) ) ;
15+ println ! (
16+ "cargo:rerun-if-changed=grammar/{}/src/" ,
17+ lang. to_string( ) . to_lowercase( )
18+ ) ;
1819 thread:: spawn ( move || {
1920 let out_dir = path:: PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
20- let mut file = fs:: File :: create ( out_dir. join ( format ! ( "{}{}" , lang. to_string( ) . to_lowercase( ) , ".rmp" ) ) ) . unwrap ( ) ;
21+ let mut file = fs:: File :: create ( out_dir. join ( format ! (
22+ "{}{}" ,
23+ lang. to_string( ) . to_lowercase( ) ,
24+ ".rmp"
25+ ) ) )
26+ . unwrap ( ) ;
2127 let rules = grammar:: rules ( lang) . unwrap ( ) ;
22- let examples = grammar:: examples ( lang) ;
23- let model = :: rustling:: train:: train ( & rules, examples, :: parser:: FeatureExtractor ( ) ) . unwrap ( ) ;
24- :: rmp_serde:: encode:: write ( & mut file, & model) . unwrap ( ) ;
28+ let examples = grammar:: examples ( lang) ;
29+ let model = rustling:: train:: train ( & rules, examples, parser:: FeatureExtractor ( ) ) . unwrap ( ) ;
30+ rmp_serde:: encode:: write ( & mut file, & model) . unwrap ( ) ;
2531 } )
2632}
2733
2834pub fn train_sync ( lang : Lang ) {
29- println ! ( "cargo:rerun-if-changed=grammar/{}/src/" , lang. to_string( ) . to_lowercase( ) ) ;
35+ println ! (
36+ "cargo:rerun-if-changed=grammar/{}/src/" ,
37+ lang. to_string( ) . to_lowercase( )
38+ ) ;
3039 let out_dir = path:: PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
31- let mut file = fs:: File :: create ( out_dir. join ( format ! ( "{}{}" , lang. to_string( ) . to_lowercase( ) , ".rmp" ) ) ) . unwrap ( ) ;
40+ let mut file =
41+ fs:: File :: create ( out_dir. join ( format ! ( "{}{}" , lang. to_string( ) . to_lowercase( ) , ".rmp" ) ) )
42+ . unwrap ( ) ;
3243 let rules = grammar:: rules ( lang) . unwrap ( ) ;
33- let examples = grammar:: examples ( lang) ;
34- let model = :: rustling:: train:: train ( & rules, examples, :: parser:: FeatureExtractor ( ) ) . unwrap ( ) ;
35- :: rmp_serde:: encode:: write ( & mut file, & model) . unwrap ( ) ;
44+ let examples = grammar:: examples ( lang) ;
45+ let model = rustling:: train:: train ( & rules, examples, parser:: FeatureExtractor ( ) ) . unwrap ( ) ;
46+ rmp_serde:: encode:: write ( & mut file, & model) . unwrap ( ) ;
3647}
3748
3849pub fn train_all_async ( ) {
39- let join_handlers: Vec < _ > = Lang :: all ( ) . into_iter ( ) . map ( |lang| {
40- train_async ( lang)
41- } ) . collect ( ) ;
50+ let join_handlers: Vec < _ > = Lang :: all ( )
51+ . into_iter ( )
52+ . map ( |lang| train_async ( lang) )
53+ . collect ( ) ;
4254
4355 for join in join_handlers {
4456 join. join ( ) . unwrap ( ) ;
0 commit comments