Commit ddde63b4 authored by bguillaum's avatar bguillaum

fix bug when remove Conll.root in outputs

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8100 7838e531-6607-4d57-9587-6c381814729c
parent ff78b7a6
......@@ -698,7 +698,9 @@ module G_graph = struct
(* -------------------------------------------------------------------------------- *)
let to_conll graph =
let nodes = Gid_map.fold (fun gid node acc -> (gid,node)::acc) graph.map [] in
let nodes = Gid_map.fold
(fun gid node acc -> if G_node.is_conll_root node then acc else (gid,node)::acc)
graph.map [] in
let snodes = List.sort (fun (_,n1) (_,n2) -> G_node.pos_comp n1 n2) nodes in
let get_num gid = (list_num (fun (x,_) -> x=gid) snodes) in
......@@ -744,7 +746,7 @@ module G_graph = struct
(String.concat "|" govs)
(String.concat "|" labs)
)
(List.tl snodes) (* do not consider the root node in CONLL output *);
snodes;
Buffer.contents buff
end (* module G_graph *)
......
......@@ -11,6 +11,7 @@ module G_node = struct
fs: G_fs.t;
pos: float option;
next: G_edge.t Massoc_gid.t;
conll_root: bool;
}
let get_fs t = t.fs
......@@ -19,7 +20,9 @@ module G_node = struct
let set_fs t fs = {t with fs = fs}
let set_pos t pos = {t with pos = Some pos}
let empty = { fs = G_fs.empty; pos = None; next = Massoc_gid.empty }
let empty = { fs = G_fs.empty; pos = None; next = Massoc_gid.empty; conll_root=false }
let is_conll_root t = t.conll_root
let to_string t =
Printf.sprintf " fs=[%s]\n next=%s\n"
......@@ -45,16 +48,18 @@ module G_node = struct
{ fs = fs_with_num;
pos = (match ast_node.Ast.position with Some n -> Some (float n) | None -> None);
next = Massoc_gid.empty;
conll_root=false;
} )
let of_conll line =
if line = Conll.root
then { fs = G_fs.empty; pos = Some 0.; next = Massoc_gid.empty }
then { fs = G_fs.empty; pos = Some 0.; next = Massoc_gid.empty; conll_root=true; }
else
{
fs = G_fs.of_conll line;
pos = Some (String_.to_float line.Conll.num);
next = Massoc_gid.empty;
conll_root=false;
}
let remove (id_tar : Gid.t) label t = {t with next = Massoc_gid.remove id_tar label t.next}
......
......@@ -18,6 +18,8 @@ module G_node: sig
val set_fs: t -> G_fs.t -> t
val set_pos: t -> float -> t
val is_conll_root: t -> bool
val remove: Gid.t -> G_edge.t -> t -> t
val remove_key: Gid.t -> t -> t
......
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