Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 2d2aa150 authored by Bruno Guillaume's avatar Bruno Guillaume
Browse files

more output formats

parent 25135cf4
......@@ -19,7 +19,9 @@ module Grew_args = struct
let grs = ref Grs.empty
let dep_dir = ref None
let cupt = ref false
type output = Conll | Cupt | Gr | Dot
let output = ref Conll
let (input_data : string list ref) = ref []
let (output_file : string option ref) = ref None
......@@ -89,6 +91,7 @@ module Grew_args = struct
"Optionnal arguments:";
" -strat <name> The stategy used in transformation (default=\"main\")";
" -cupt If the option is present, a 11-column CoNLL format is produced";
" -gr If the option is present, the gr output format is produced";
" -track_rules If the option is present, data about the rules applied are given in output";
"";
"For additional information, see http://grew.fr";
......@@ -109,7 +112,9 @@ module Grew_args = struct
| "-max_rules" :: i :: args -> Rewrite.set_max_rules (int_of_string i); loop args
| "-quiet" :: args -> quiet := true; loop args
| "-cupt" :: args -> cupt := true; loop args
| "-cupt" :: args -> output := Cupt; loop args
| "-gr" :: args -> output := Gr; loop args
| "-dot" :: args -> output := Dot; loop args
| "-safe_commands" :: args -> Libgrew.set_safe_commands true; loop args
| "-track_rules" :: args -> Libgrew.set_track_rules true; loop args
......
......@@ -45,11 +45,22 @@ let transform () =
let out_ch = match !Grew_args.output_file with
| Some output_file -> open_out output_file
| None -> stdout in
let out_graph ?new_sent_id graph = match (!Grew_args.output, new_sent_id) with
| (Grew_args.Conll,None) -> fprintf out_ch "%s\n" (Graph.to_conll_string graph)
| (Grew_args.Conll,Some nsi) -> fprintf out_ch "%s\n" (graph |> Graph.to_conll |> Conll.set_sentid nsi |> Conll.to_string)
| (Grew_args.Cupt, None) -> fprintf out_ch "%s\n" (Graph.to_conll_string ~cupt:true graph)
| (Grew_args.Cupt,Some nsi) -> fprintf out_ch "%s\n" (graph |> Graph.to_conll |> Conll.set_sentid nsi |> Conll.to_string ~cupt:true)
| (Grew_args.Gr, None) -> fprintf out_ch "%s\n" (Graph.to_gr graph)
| (Grew_args.Gr, Some nsi) -> fprintf out_ch "# sent_id = %s\n%s\n" nsi (Graph.to_gr graph)
| (Grew_args.Dot, None) -> fprintf out_ch "%s\n" (Graph.to_dot graph)
| (Grew_args.Dot, Some nsi) -> fprintf out_ch "# sent_id = %s\n%s\n" nsi (Graph.to_dot graph) in
Array.iteri
(fun index (id, gr) ->
Counter.print index len id;
match Rewrite.simple_rewrite ~gr ~grs ~strat:!Grew_args.strat with
| [one] -> fprintf out_ch "%s\n" (Graph.to_conll_string ~cupt:!Grew_args.cupt one)
| [one] -> out_graph one
| l ->
List.iteri (fun i gr ->
let conll = Graph.to_conll gr in
......@@ -57,10 +68,10 @@ let transform () =
fprintf out_ch "%s\n" (Conll.to_string conll_new_id)
) l
) graph_array;
Counter.finish ();
match !Grew_args.output_file with
| Some output_file -> close_out out_ch
| None -> ();
Counter.finish ()
| None -> ()
) ()
(* -------------------------------------------------------------------------------- *)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment