libgrew_.mli 5.52 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3 4 5 6 7 8 9
(**********************************************************************************)
(*    Libcaml-grew - a Graph Rewriting library dedicated to NLP applications      *)
(*                                                                                *)
(*    Copyright 2011-2013 Inria, Université de Lorraine                           *)
(*                                                                                *)
(*    Webpage: http://grew.loria.fr                                               *)
(*    License: CeCILL (see LICENSE folder or "http://www.cecill.info")            *)
(*    Authors: see AUTHORS file                                                   *)
(**********************************************************************************)
pj2m's avatar
pj2m committed
10 11

(** {2 Grew's core} *)
12
open Grew_base
bguillaum's avatar
bguillaum committed
13 14 15
open Grew_graph
open Grew_rule
open Grew_grs
pj2m's avatar
pj2m committed
16

17 18
val css_file: string

bguillaum's avatar
bguillaum committed
19
type loc = Loc.t
20 21 22 23 24 25


type instance = Instance.t


val line_of_loc: loc -> int
bguillaum's avatar
bguillaum committed
26 27
val string_of_loc: loc -> string

pj2m's avatar
pj2m committed
28 29
exception File_dont_exists of string

bguillaum's avatar
bguillaum committed
30 31
exception Parsing_err of string * loc option

pj2m's avatar
pj2m committed
32
(** raised when a Gr/Grs structure fails to build *)
bguillaum's avatar
bguillaum committed
33
exception Build of string * loc option
pj2m's avatar
pj2m committed
34

bguillaum's avatar
bguillaum committed
35
(** raised during rewriting when a command is undefined *)
bguillaum's avatar
bguillaum committed
36
exception Run of string * loc option
pj2m's avatar
pj2m committed
37

bguillaum's avatar
bguillaum committed
38
exception Bug of string * loc option
pj2m's avatar
pj2m committed
39

bguillaum's avatar
bguillaum committed
40
val set_timeout: float option -> unit
pj2m's avatar
pj2m committed
41

bguillaum's avatar
bguillaum committed
42
val rewrite: gr:Instance.t -> grs:Grs.t -> seq:string -> Rewrite_history.t
bguillaum's avatar
bguillaum committed
43

bguillaum's avatar
bguillaum committed
44
val is_empty: Rewrite_history.t -> bool
bguillaum's avatar
bguillaum committed
45

bguillaum's avatar
bguillaum committed
46 47
val num_sol: Rewrite_history.t -> int

bguillaum's avatar
bguillaum committed
48
(** display a gr with a grs in a rew_display
bguillaum's avatar
bguillaum committed
49 50 51 52
@param gr the grapth to rewrite
@param grs the graph rewriting system
@param seq the name of the sequence to apply
@return a structure {b {i easily}} displayable *)
bguillaum's avatar
bguillaum committed
53
val display: gr:Instance.t -> grs:Grs.t -> seq:string -> rew_display
bguillaum's avatar
bguillaum committed
54

bguillaum's avatar
bguillaum committed
55
val write_stat: string -> Rewrite_history.t -> unit
bguillaum's avatar
bguillaum committed
56

bguillaum's avatar
bguillaum committed
57
val empty_grs: Grs.t
pj2m's avatar
pj2m committed
58

bguillaum's avatar
bguillaum committed
59
(** get a graph rewriting system from a file
pj2m's avatar
pj2m committed
60 61 62 63
@return a graph rewriting system
@raise Parsing_err if libgrew can't parse the file
@raise File_dont_exists if the file doesn't exists
*)
64 65 66
val load_grs: string -> Grs.t

(** [build_html_doc directory grs ] *)
67
val build_html_doc: ?corpus:bool -> string -> Grs.t -> unit
pj2m's avatar
pj2m committed
68

bguillaum's avatar
bguillaum committed
69
(** give the list of sequence names defined in a GRS
70 71
@return a string list
*)
bguillaum's avatar
bguillaum committed
72
val get_sequence_names: Grs.t -> string list
73

bguillaum's avatar
bguillaum committed
74
val to_sentence: ?main_feat:string -> Instance.t -> string
pj2m's avatar
pj2m committed
75

bguillaum's avatar
bguillaum committed
76 77
val save_graph_conll: string -> Instance.t -> unit

78 79
val save_gr: string -> Rewrite_history.t -> unit

bguillaum's avatar
bguillaum committed
80 81
val save_conll: string -> Rewrite_history.t -> unit

82 83 84 85
(** [save_full_conll base_name rh] saves one conll_file for each normal form defined in [rh].
    Output files are named according to [base_name] and a secondary index after "__".
    The number of conll file produced is returned. *)
val save_full_conll: string -> Rewrite_history.t -> int
86

87 88
val save_det_gr: string -> Rewrite_history.t -> unit

89
val save_det_conll: ?header:string -> string -> Rewrite_history.t -> unit
bguillaum's avatar
bguillaum committed
90

bguillaum's avatar
bguillaum committed
91 92 93
val det_dep_string: Rewrite_history.t -> string option

val conll_dep_string: ?keep_empty_rh:bool -> Rewrite_history.t -> string option
bguillaum's avatar
bguillaum committed
94

95 96
(** get a graph from a file either in 'gr' or 'conll' format.
File extension should be '.gr' or '.conll'.
pj2m's avatar
pj2m committed
97 98 99
@raise Parsing_err if libgrew can't parse the file
@raise File_dont_exists if the file doesn't exists
*)
100
val load_graph: string -> Instance.t
bguillaum's avatar
bguillaum committed
101

102
(** [of_conll filename line_list] *)
bguillaum's avatar
bguillaum committed
103 104
val of_conll: string -> (int * string) list -> Instance.t

105 106
val of_brown: string -> Instance.t

bguillaum's avatar
bguillaum committed
107 108
val xml_graph: Xml.xml -> Instance.t

bguillaum's avatar
bguillaum committed
109
(** [raw_graph instance] returns all graph information with a triple of elementary caml types:
bguillaum's avatar
bguillaum committed
110 111 112 113 114 115 116 117 118
    - the meta data
    - the list of node (node is a list of feature (feature is string * string))
    - the list of edge (src, label, tar) where src and tar refers to the position in the node list
*)
val raw_graph: Instance.t ->
    (string * string) list *
    (string * string) list list *
    (int * string * int) list

bguillaum's avatar
bguillaum committed
119 120
val save_index: dirname:string -> base_names: string list -> unit

121
val write_annot: title:string -> string -> string -> (string * Rewrite_history.t) list -> unit
122

bguillaum's avatar
bguillaum committed
123
val write_html:
124 125
    ?no_init: bool ->
    ?out_gr: bool ->
126
    ?filter: string list ->
bguillaum's avatar
bguillaum committed
127
    ?main_feat: string ->
128
    ?dot: bool ->
129
    header: string ->
bguillaum's avatar
bguillaum committed
130
    ?graph_file: string ->
131
    Rewrite_history.t -> string -> unit
pj2m's avatar
pj2m committed
132

bguillaum's avatar
bguillaum committed
133 134 135
val error_html:
    ?no_init:bool ->
    ?main_feat:string ->
136
    ?dot: bool ->
bguillaum's avatar
bguillaum committed
137 138 139 140
    header: string ->
    string ->
    ?init:Instance.t ->
    string ->
141
    unit
142

bguillaum's avatar
bguillaum committed
143
val make_index:
bguillaum's avatar
bguillaum committed
144
    title: string ->
bguillaum's avatar
bguillaum committed
145 146 147
    grs_file: string ->
    html: bool ->
    grs: Grs.t ->
bguillaum's avatar
bguillaum committed
148
    seq: string ->
bguillaum's avatar
bguillaum committed
149 150 151
    input_dir: string ->
    output_dir: string ->
    base_names: string list ->
bguillaum's avatar
bguillaum committed
152
      unit
pj2m's avatar
pj2m committed
153

bguillaum's avatar
bguillaum committed
154
val html_sentences: title:string -> string -> (bool * string * int * string) list -> unit
bguillaum's avatar
bguillaum committed
155

156
val graph_of_instance: Instance.t -> G_graph.t
157 158

val feature_names: unit -> string list option
159 160 161 162 163 164

val to_dot_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
val to_conll_graph: graph -> string

165 166 167
(* type and function added for the grep mode of grew *)
type pattern
type matching
168 169

(** [load_pattern filename] returns the pattern describer in the fuile *)
170
val load_pattern: string -> pattern
171 172

(** [match_in_graph patern graph] returns the list of the possible matching og [pattern] in [graph] *)
173
val match_in_graph: pattern -> graph -> matching list
174 175 176

(** [match_deco pattern matching] returns the deco to be used in the graphical representation.
    WARNING: the function supposes that [matching] was find with the given [pattern]! *)
bguillaum's avatar
bguillaum committed
177
val match_deco: pattern -> matching -> deco