Commit 2cee37c8 authored by Bruno Guillaume's avatar Bruno Guillaume

Fix highlight for combine search: f=v/g=u

parent a9d46186
......@@ -280,8 +280,18 @@ module G_fs = struct
(* ---------------------------------------------------------------------- *)
let to_dot ?(decorated_feat=("",[])) ?main_feat t =
let (pid_name, highlighted_feat_list) = decorated_feat in
let is_highlithed feat_name =
(List.mem_assoc feat_name highlighted_feat_list) ||
(List.exists (function
| (f, Some g) when g = feat_name && (not (List.mem_assoc f t)) && (List.mem_assoc g t) -> true
| _ -> false
) highlighted_feat_list
) in
let buff = Buffer.create 32 in
let () = match (fst decorated_feat) with
let () = match pid_name with
| "" -> ()
| pid -> bprintf buff "<TR><TD COLSPAN=\"3\" BGCOLOR=\"yellow\"><B>[%s]</B></TD></TR>\n" pid in
......@@ -289,7 +299,7 @@ module G_fs = struct
match get_main ?main_feat t with
| (None, sub) -> sub
| (Some (feat_name,atom), sub) ->
if List.mem feat_name (snd decorated_feat)
if is_highlithed feat_name
then bprintf buff "<TR><TD COLSPAN=\"3\" BGCOLOR=\"yellow\"><B>%s</B></TD></TR>\n" (string_of_value atom)
else bprintf buff "<TR><TD COLSPAN=\"3\"><B>%s</B></TD></TR>\n" (string_of_value atom);
sub in
......@@ -321,7 +331,15 @@ module G_fs = struct
(* ---------------------------------------------------------------------- *)
let to_dep ?(decorated_feat=("",[])) ?position ?main_feat ?filter t =
let (pid_name, feat_list) = decorated_feat in
let (pid_name, highlighted_feat_list) = decorated_feat in
let is_highlithed feat_name =
(List.mem_assoc feat_name highlighted_feat_list) ||
(List.exists (function
| (f, Some g) when g = feat_name && (not (List.mem_assoc f t)) && (List.mem_assoc g t) -> true
| _ -> false
) highlighted_feat_list
) in
let (main_opt, sub) = get_main ?main_feat t in
let sub = List.sort G_feature.print_cmp sub in
......@@ -330,10 +348,11 @@ module G_fs = struct
| None -> []
| Some (feat_name, atom) ->
let esc_atom = escape_sharp (string_of_value atom) in
[ if List.mem feat_name (snd decorated_feat)
[ if is_highlithed feat_name
then sprintf "%s:B:#8bf56e" esc_atom
else esc_atom] in
(* add the pattern identifier *)
let word_list = match pid_name with
| "" -> main
| _ -> (sprintf "[%s]:B:#8bf56e" pid_name)::main in
......@@ -349,7 +368,7 @@ module G_fs = struct
let lines = List.fold_left
(fun acc (feat_name, atom) ->
let esc_atom = escape_sharp (G_feature.to_string (decode_feat_name feat_name, atom)) in
if List.mem feat_name (snd decorated_feat)
if is_highlithed feat_name
then (sprintf "%s:B:#8bf56e" esc_atom) :: acc
else
match filter with
......@@ -419,7 +438,11 @@ module P_fs = struct
let unsorted = List.map (P_feature.build ?domain ?pat_vars) ast_fs in
List.sort P_feature.compare unsorted
let feat_list t = List.map P_feature.get_name t
let feat_list t =
List.map (function
| (fn, {P_feature.cst=P_feature.Else (_,fn2,_)}) -> (fn, Some fn2)
| (fn, _) -> (fn, None)
) t
let to_string t = List_.to_string P_feature.to_string "\\n" t
......
......@@ -47,9 +47,9 @@ module G_fs: sig
val get_float_feat: string -> t -> float option
val to_gr: t -> string
val to_dot: ?decorated_feat:(string * string list) -> ?main_feat: string -> t -> string
val to_dot: ?decorated_feat:(string * (string * string option) list) -> ?main_feat: string -> t -> string
val to_word: t -> string option
val to_dep: ?decorated_feat:(string * string list) -> ?position:float -> ?main_feat: string -> ?filter: (string -> bool) -> t -> string
val to_dep: ?decorated_feat:(string * (string * string option) list) -> ?position:float -> ?main_feat: string -> ?filter: (string -> bool) -> t -> string
val to_conll_string: ?exclude: string list -> t -> string
val to_conll: ?exclude: string list -> t -> (string * string) list
val to_json: t -> json
......@@ -84,7 +84,7 @@ module P_fs: sig
val to_dot: t -> string
val feat_list: t -> string list
val feat_list: t -> (string * string option) list
exception Fail
......
......@@ -212,8 +212,11 @@ end (* module P_graph *)
(* ================================================================================ *)
module G_deco = struct
(* value is (f, Some g) for combined request "f=v/g=u" and (j, None) else *)
type highlighted_feat = string * string option
type t = {
nodes: (Gid.t * (string * string list)) list; (* a list of (node, (pattern_id, features of nodes implied in the step)) *)
nodes: (Gid.t * (string * highlighted_feat list)) list; (* a list of (node, (pattern_id, features of nodes implied in the step)) *)
edges: (Gid.t * G_edge.t * Gid.t) list; (* an edge list *)
}
......
......@@ -32,10 +32,13 @@ end (* module P_deco *)
(* ================================================================================ *)
module G_deco: sig
type t =
{ nodes: (Gid.t * (string * string list)) list;
edges: (Gid.t * G_edge.t * Gid.t) list;
}
(* value is (f, Some g) for combined request "f=v/g=u" and (j, None) else *)
type highlighted_feat = string * string option
type t = {
nodes: (Gid.t * (string * highlighted_feat list)) list; (* a list of (node, (pattern_id, features of nodes implied in the step)) *)
edges: (Gid.t * G_edge.t * Gid.t) list; (* an edge list *)
}
val empty:t
end (* module G_deco *)
......
......@@ -591,7 +591,8 @@ module Rule = struct
Pid_map.fold
(fun pid gid acc ->
let pnode = P_graph.find pid (fst pattern).graph in
(gid, (P_node.get_name pnode, P_fs.feat_list (P_node.get_fs pnode))) ::acc
let pattern_feat_list = P_fs.feat_list (P_node.get_fs pnode) in
(gid, (P_node.get_name pnode, pattern_feat_list)) ::acc
) matching.n_match [];
G_deco.edges = List.fold_left (fun acc (_,edge) -> edge::acc) [] matching.e_match;
}
......@@ -617,14 +618,15 @@ module Rule = struct
) Gid_map.empty commands in
{
G_deco.nodes = List.map (fun (gid,feat_list) -> (gid, ("",feat_list))) (Gid_map.bindings feat_to_highlight);
G_deco.edges = List.fold_left
(fun acc -> function
| (Command.ADD_EDGE (src_cn,tar_cn,edge),loc) ->
(find src_cn (matching, created_nodes), edge, find tar_cn (matching, created_nodes)) :: acc
| _ -> acc
) [] commands
}
G_deco.nodes = List.map (fun (gid,feat_list) ->
(gid, ("", (List.map (fun x -> (x,None)) feat_list)))
) (Gid_map.bindings feat_to_highlight);
G_deco.edges = List.fold_left (fun acc -> function
| (Command.ADD_EDGE (src_cn,tar_cn,edge),loc) ->
(find src_cn (matching, created_nodes), edge, find tar_cn (matching, created_nodes)) :: acc
| _ -> acc
) [] commands;
}
exception Fail
type partial = {
......
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