Commit ee5d3b6e authored by Bruno Guillaume's avatar Bruno Guillaume

version 2.35.0: add show_root boolean option to conll_to_dep

parent 72382bda
2.34.2
\ No newline at end of file
2.35.0
\ No newline at end of file
......@@ -135,12 +135,15 @@ module Dep2pict = struct
| Mwe.Mwe -> "#ff760b"
(* ----------------------------------------------------------------------------- *)
let conll_to_dep ~conll =
let conll_to_dep ?(show_root=false) ~conll =
let buff = Buffer.create 32 in
bprintf buff "[GRAPH] {scale=200; fontname=\"Arial\"; background=transparent; }\n";
bprintf buff "[WORDS] {\n";
if show_root
then bprintf buff " N_0 { word=\"_\" }\n";
List.iter
(fun line ->
......@@ -214,7 +217,7 @@ module Dep2pict = struct
(fun line ->
List.iter
(function
| ((0,_),_) -> ()
| ((0,_),_) when not show_root -> ()
| (gov, lab) -> bprintf buff " N_%s -> N_%s { %s }\n" (Conll.Id.to_dot gov) (Conll.Id.to_dot line.Conll.id) (label_spec lab)
) line.Conll.deps
) conll.Conll.lines;
......@@ -1923,13 +1926,14 @@ module Dep2pict = struct
let bytes = (Dep2pict_utils.read_file filename) in
from_dep ~rtl ~dep:(Bytes.to_string bytes)
let from_conll ?(rtl=false) ~conll =
let from_conll ?(show_root=false) ?(rtl=false) ~conll =
handle (fun () ->
let dep_string = conll_to_dep conll in
let dep_string = conll_to_dep ~show_root ~conll in
from_dep ~rtl ~dep:dep_string
)
let load_conll ?(rtl=false) ~filename = from_conll ~rtl ~conll:(Conll.load filename)
let load_conll ?(show_root=false) ?(rtl=false) ~filename =
from_conll ~show_root ~rtl ~conll:(Conll.load filename)
let to_svg graph = let (svg,new_shift) = graph_to_svg graph in
shift := new_shift;
......
......@@ -10,8 +10,8 @@ module Dep2pict : sig
val from_dep : ?rtl:bool -> dep:string -> t
val load_dep : ?rtl:bool -> filename:string -> t
val from_conll : ?rtl:bool -> conll:Conll.t -> t
val load_conll : ?rtl:bool -> filename:string -> t
val from_conll : ?show_root:bool -> ?rtl:bool -> conll:Conll.t -> t
val load_conll : ?show_root:bool -> ?rtl:bool -> filename:string -> t
......@@ -22,7 +22,7 @@ module Dep2pict : sig
val save_png : filename:string -> t -> unit
val conll_to_dep : conll:Conll.t -> string
val conll_to_dep : ?show_root:bool -> conll:Conll.t -> string
(** [highlight_shift ()] returns the leftmost position highlighted in the last dep struct built. *)
val highlight_shift: unit -> float option
......
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