Commit ab3a75f1 authored by bguillaum's avatar bguillaum

add ~filter optional argument in to_dep_graph function

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7729 7838e531-6607-4d57-9587-6c381814729c
parent b41a510b
VERSION = 0.17.0
VERSION = 0.18.0
INSTALL_DIR_LIB = @OCAMLLIB@
INSTALL_DIR = @prefix@/bin/
......
......@@ -46,6 +46,11 @@ module Domain = struct
match build ?loc name [value] with
| [x] -> x
| _ -> Error.bug ?loc "[Domain.build_one]"
let feature_names () =
match !current with
| None -> None
| Some dom -> Some (List.map (function Ast.Closed (fn, _) | Ast.Open fn | Ast.Int fn -> fn) dom)
end
(* ==================================================================================================== *)
......@@ -206,11 +211,14 @@ module G_fs = struct
| (None, _) -> "#"
| (Some atom, _) -> string_of_value atom
let to_dep ?main_feat t =
let to_dep ?main_feat ?filter t =
let (main_opt, sub) = get_main ?main_feat t in
let reduced_sub = match filter with
| None -> sub
| Some l -> List.filter (fun (fn,_) -> List.mem fn l) sub in
sprintf " word=\"%s\"; subword=\"%s\"; "
(match main_opt with Some atom -> string_of_value atom | None -> "")
(List_.to_string G_feature.to_string "#" sub)
(List_.to_string G_feature.to_string "#" reduced_sub)
end (* module G_fs *)
(* ==================================================================================================== *)
......@@ -226,7 +234,11 @@ module P_fs = struct
let to_string t = List_.to_string P_feature.to_string "\\n" t
let to_dep param_names t = List_.to_string (P_feature.to_string ~param_names) "#" t
let to_dep ?filter param_names t =
let reduced = match filter with
| None -> t
| Some l -> List.filter (fun (fn,_) -> List.mem fn l) t in
List_.to_string (P_feature.to_string ~param_names) "#" reduced
let to_dot t = List_.to_string P_feature.to_string "\\n" t
......
......@@ -5,6 +5,8 @@ module Domain: sig
val reset: unit -> unit
val init: Ast.domain -> unit
val feature_names: unit -> string list option
end
(* [G_fs] define the ferute srtuctures that are used in graphs *)
......@@ -29,7 +31,7 @@ module G_fs: sig
val to_gr: t -> string
val to_dot: ?main_feat: string -> t -> string
val to_word: ?main_feat: string -> t -> string
val to_dep: ?main_feat: string -> t -> string
val to_dep: ?main_feat: string -> ?filter: string list -> t -> string
val to_raw: t -> (string * string) list
val to_string: t -> string
......@@ -52,7 +54,7 @@ module P_fs: sig
val to_string: t -> string
val to_dep: (string list * string list) -> t -> string
val to_dep: ?filter: string list -> (string list * string list) -> t -> string
val to_dot: t -> string
......
......@@ -562,7 +562,7 @@ module G_graph = struct
]
(* -------------------------------------------------------------------------------- *)
let to_dep ?main_feat ?(deco=G_deco.empty) graph =
let to_dep ?filter ?main_feat ?(deco=G_deco.empty) graph =
let buff = Buffer.create 32 in
bprintf buff "[GRAPH] { opacity=0; scale = 200; fontname=\"Arial\"; }\n";
......@@ -576,9 +576,9 @@ module G_graph = struct
(fun (id, node) ->
if List.mem id deco.G_deco.nodes
then bprintf buff
"N_%s { %sforecolor=red; subcolor=red; }\n" (Gid.to_string id) (G_fs.to_dep ?main_feat (G_node.get_fs node))
"N_%s { %sforecolor=red; subcolor=red; }\n" (Gid.to_string id) (G_fs.to_dep ?filter ?main_feat (G_node.get_fs node))
else bprintf buff
"N_%s { %s }\n" (Gid.to_string id) (G_fs.to_dep ?main_feat (G_node.get_fs node))
"N_%s { %s }\n" (Gid.to_string id) (G_fs.to_dep ?filter ?main_feat (G_node.get_fs node))
) snodes;
bprintf buff "} \n";
......
......@@ -147,7 +147,7 @@ module G_graph: sig
val to_gr: t -> string
val to_dot: ?main_feat:string -> ?deco:G_deco.t -> t -> string
val to_sentence: ?main_feat:string -> t -> string
val to_dep: ?main_feat:string -> ?deco:G_deco.t -> t -> string
val to_dep: ?filter : string list -> ?main_feat:string -> ?deco:G_deco.t -> t -> string
val to_raw: t ->
(string * string) list *
......
......@@ -25,5 +25,5 @@ and big_step = {
}
let to_dot_graph ?main_feat ?(deco=G_deco.empty) graph = G_graph.to_dot ?main_feat graph ~deco
let to_dep_graph ?main_feat ?(deco=G_deco.empty) graph = G_graph.to_dep ?main_feat ~deco graph
let to_dep_graph ?filter ?main_feat ?(deco=G_deco.empty) graph = G_graph.to_dep ?filter ?main_feat ~deco graph
let to_gr_graph graph = G_graph.to_gr graph
......@@ -32,5 +32,5 @@ and big_step = {
(** {2 Types displaying} *)
val to_dot_graph : ?main_feat:string -> ?deco:deco -> graph -> string
val to_dep_graph : ?main_feat:string -> ?deco:deco -> graph -> string
val to_dep_graph : ?filter: string list -> ?main_feat:string -> ?deco:deco -> graph -> string
val to_gr_graph: graph -> string
......@@ -3,6 +3,7 @@ include Grew_types
open Printf
open Log
open Grew_fs
open Grew_utils
open Grew_graph
open Grew_rule
......@@ -202,3 +203,5 @@ let html_sentences ~title = Html_sentences.build ~title
let get_css_file = Filename.concat DATA_DIR "style.css"
let graph_of_instance instance = instance.Instance.graph
let feature_names () = Domain.feature_names ()
......@@ -108,3 +108,5 @@ val html_sentences: title:string -> string -> (bool * string * int * string) lis
val get_css_file: string
val graph_of_instance: Instance.t -> G_graph.t
val feature_names: unit -> string list 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