Commit c2abb500 authored by Bruno Guillaume's avatar Bruno Guillaume

Add option ?get_url in Graph.to_dot

parent a28f73ea
......@@ -1126,7 +1126,7 @@ module G_graph = struct
Conll.to_string ?cupt (Conll.normalize_multiwords conll)
(* -------------------------------------------------------------------------------- *)
let to_dot ?main_feat ?(deco=G_deco.empty) graph =
let to_dot ?main_feat ?(get_url = fun _ -> None) ?(deco=G_deco.empty) graph =
let domain = get_domain graph in
let buff = Buffer.create 32 in
......@@ -1139,11 +1139,18 @@ module G_graph = struct
let decorated_feat =
try List.assoc id deco.G_deco.nodes
with Not_found -> ("",[]) in
bprintf buff " N_%s [label=<%s>, color=%s]\n"
let fs = G_node.get_fs node in
let lab_url = match G_fs.get_string_atom "label" fs with
| None -> None
| Some lab ->
match get_url lab with
| None -> None
| Some url -> Some (lab,url)
in
bprintf buff " N_%s [label=<%s>%s]\n"
(Gid.to_string id)
(G_fs.to_dot ~decorated_feat ?main_feat (G_node.get_fs node))
(* TODO: add bgcolor in dot output *)
(if List.mem_assoc id deco.G_deco.nodes then "red" else "black")
(G_fs.to_dot ~decorated_feat ?main_feat fs)
(match lab_url with None -> "" | Some (lab,url) -> sprintf ", URL=\"%s\", target=_blank, tooltip=\"%s\", shape=record" url lab)
) graph.map;
(* edges *)
......
......@@ -192,7 +192,7 @@ module G_graph: sig
(* Output functions *)
(* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
val to_gr: t -> string
val to_dot: ?main_feat:string -> ?deco:G_deco.t -> t -> string
val to_dot: ?main_feat:string -> ?get_url:(string -> string option) -> ?deco:G_deco.t -> t -> string
val to_sentence: ?main_feat:string -> ?deco:G_deco.t -> t -> string
val to_dep: ?filter: (string -> bool) -> ?main_feat:string -> ?deco:G_deco.t -> t -> string
val to_conll: t -> Conll.t
......
......@@ -203,8 +203,8 @@ module Graph = struct
let of_brown ?domain ?sentid brown =
Libgrew.handle ~name:"Graph.of_brown" (fun () -> Grew_graph.G_graph.of_brown ?domain ?sentid brown) ()
let to_dot ?main_feat ?(deco=Grew_graph.G_deco.empty) graph =
Libgrew.handle ~name:"Graph.to_dot" (fun () -> Grew_graph.G_graph.to_dot ?main_feat graph ~deco) ()
let to_dot ?main_feat ?(deco=Grew_graph.G_deco.empty) ?get_url graph =
Libgrew.handle ~name:"Graph.to_dot" (fun () -> Grew_graph.G_graph.to_dot ?main_feat ?get_url graph ~deco) ()
let to_dep ?filter ?main_feat ?(deco=Grew_graph.G_deco.empty) graph =
Libgrew.handle ~name:"Graph.to_dep" (fun () -> Grew_graph.G_graph.to_dep ?filter ?main_feat ~deco graph) ()
......
......@@ -99,7 +99,7 @@ module Graph : sig
val to_sentence: ?main_feat:string -> ?deco:Deco.t -> t -> string
val to_dot : ?main_feat:string -> ?deco:Deco.t -> t -> string
val to_dot : ?main_feat:string -> ?deco:Deco.t -> ?get_url:(string -> string option) -> t -> string
val to_dep : ?filter: (string -> bool) -> ?main_feat:string -> ?deco:Deco.t -> t -> string
......
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