Commit 0fdb1ba5 authored by Bruno Guillaume's avatar Bruno Guillaume

version 0.41: adapt to libcaml-conll 0.12.0 (UD empty nodes)

parent bb17bff3
......@@ -41,7 +41,7 @@ module Label_domain = struct
let parse_option string_label options =
let init_style = match Str.bounded_split (Str.regexp ":") string_label 2 with
| ["S"; l] -> {default with text=l; color=Some "red"}
| ["D"; l] -> {default with text=l; color=Some "blue"; bottom=true}
| ["D"; l] | ["E"; l] -> {default with text=l; color=Some "blue"; bottom=true}
| ["I"; l] -> {default with text=l; color=Some "grey"}
| _ -> {default with text=string_label} in
List.fold_left
......
......@@ -345,7 +345,7 @@ module G_fs = struct
let to_conll ?exclude t =
let reduced_t = match exclude with
| None -> t
| Some list -> List.filter (fun (fn,_) -> not (List.mem fn list || fn.[0]='_')) t in
| Some list -> List.filter (fun (fn,_) -> not (List.mem fn list)) t in
let ud_ordering = (* In UD CoNLL-U format, features are sorted wrt lowercase form *)
List.sort
(fun feat1 feat2 -> Pervasives.compare (String.lowercase_ascii (G_feature.get_name feat1)) (String.lowercase_ascii (G_feature.get_name feat2)))
......
......@@ -368,7 +368,7 @@ module G_graph = struct
let sorted_lines = Conll.root :: (List.sort Conll.compare conll.Conll.lines) in
let gtable = (Array.of_list (List.map (fun line -> line.Conll.id) sorted_lines), string_of_int) in
let gtable = (Array.of_list (List.map (fun line -> line.Conll.id) sorted_lines), Conll.dot_of_id) in
let rec loop index prec = function
| [] -> Gid_map.empty
......@@ -405,9 +405,9 @@ module G_graph = struct
(fun {Conll.first; last; fusion; mw_line_num} ->
let loc = Loc.file_opt_line_opt conll.Conll.file mw_line_num in
(
Id.gbuild ~loc first gtable,
Id.gbuild ~loc (first,None) gtable,
(
Id.gbuild ~loc last gtable,
Id.gbuild ~loc (last, None) gtable,
fusion
)
)
......@@ -426,7 +426,7 @@ module G_graph = struct
let feats = match (i,sentid) with
| (0,Some id) -> [("sentid", id)]
| _ -> [] in
Conll.build_line ~id:(i+1) ~form ~lemma ~xpos:pos ~feats ~deps:([(i, "SUC")]) ()
Conll.build_line ~id:(i+1,None) ~form ~lemma ~xpos:pos ~feats ~deps:([(i, "SUC")]) ()
| _ -> Error.build "[Graph.of_brown] Cannot parse Brown item >>>%s<<< (expected \"phon/POS/lemma\") in >>>%s<<<" item brown
) units in
of_conll ?domain { Conll.file=None; meta=[]; lines=conll_lines; multiwords=[] }
......@@ -788,7 +788,9 @@ module G_graph = struct
let style = match G_fs.get_string_atom "void" fs with
| Some "y" -> "; forecolor=red; subcolor=red; "
| _ -> "" in
| _ -> match G_fs.get_string_atom "_UD_empty" fs with
| Some "Yes" -> "; forecolor=purple; subcolor=purple; "
| _ -> "" in
bprintf buff "N_%s { %s%s }\n"
(Gid.to_string id)
......
......@@ -79,10 +79,15 @@ module G_node = struct
let fs = G_fs.build ?domain ast_node.Ast.fs in
{ empty with name=Some ast_node.Ast.node_id; fs; position = float_of_int position; prec; succ }
let float_of_conll_id = function
| (i,None) -> float i
| (i, Some j) when j >0 && j < 10 -> (float i) +. (float j) /. 10.
| _ -> Error.bug "[float_of_conll_id]"
let of_conll ?loc ?prec ?succ ?domain line =
if line = Conll.root
then { empty with conll_root=true; succ}
else { empty with fs = G_fs.of_conll ?loc ?domain line; position = float line.Conll.id; prec; succ; efs=line.Conll.efs }
else { empty with fs = G_fs.of_conll ?loc ?domain line; position = float_of_conll_id line.Conll.id; prec; succ; efs=line.Conll.efs }
let pst_leaf ?loc ?domain phon position =
{ empty with fs = G_fs.pst_leaf ?loc ?domain phon; position = float position }
......
......@@ -60,7 +60,17 @@ module Domain = struct
let ast = Grew_loader.Loader.domain filename in
Grew_grs.Grs.domain_build ast
let feature_names domain = handle ~name:"feature_names" (fun () -> Grew_domain.Domain.feature_names domain) ()
let load filename =
handle ~name:"feature_names"
(fun () ->
let ast = Grew_loader.Loader.domain filename in
Grew_grs.Grs.domain_build ast
) ()
let feature_names domain =
handle ~name:"feature_names"
(fun () -> Grew_domain.Domain.feature_names domain)
()
end
(* ==================================================================================================== *)
......
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