grew_fs.mli 4.37 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3 4 5 6 7 8 9 10
(**********************************************************************************)
(*    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                                                   *)
(**********************************************************************************)

11 12
open Conll

bguillaum's avatar
bguillaum committed
13
open Grew_base
14
open Grew_types
bguillaum's avatar
bguillaum committed
15
open Grew_ast
16 17 18 19 20 21 22 23 24
open Grew_domain

(* ================================================================================ *)
module Feature_value: sig
  val build_disj: ?loc:Loc.t -> ?domain: Domain.t -> feature_name -> feature_atom list -> value list

  val build_value: ?loc:Loc.t -> ?domain: Domain.t -> feature_name -> feature_atom -> value
end (* module Feature_domain *)

pj2m's avatar
pj2m committed
25

bguillaum's avatar
bguillaum committed
26 27
(* ================================================================================ *)
(* module [G_fs] defines the feature structures that are used in graphs *)
28
module G_fs: sig
pj2m's avatar
pj2m committed
29 30
  type t

31
  val empty: t
32

33
  (** [set_feat domain feature_name atom t] adds the feature ([feature_name],[atom]) in [t].
34
      If [t] already contains a feature named [feature_name], the old value is erased by the new one. *)
bguillaum's avatar
bguillaum committed
35
  val set_feat: ?loc:Loc.t -> ?domain:Domain.t -> feature_name -> string -> t ->  t
36 37 38 39

  (** [del_feat feature_name t] remove the feature with name [feature_name] in [t].
      If [t] does not contain such a feature, [t] is returned unchanged. *)
  val del_feat:  string -> t ->  t
bguillaum's avatar
bguillaum committed
40

Bruno Guillaume's avatar
Bruno Guillaume committed
41 42
  val get_atom: string -> t -> value option

bguillaum's avatar
bguillaum committed
43
  (** [get_string_atom f t] returns [Some v] if the fs [t] contains the feature (f,v).
44
      It returns [None] if there is no feature named [f] in [t] *)
bguillaum's avatar
bguillaum committed
45
  val get_string_atom: string -> t -> string option
bguillaum's avatar
bguillaum committed
46

bguillaum's avatar
bguillaum committed
47
  val get_float_feat: string -> t -> float option
48
  val to_gr: t -> string
49
  val to_dot: ?decorated_feat:(string * string list) -> ?main_feat: string -> t -> string
50
  val to_word: ?main_feat: string -> t -> string
51
  val to_dep: ?decorated_feat:(string * string list) -> ?position:float -> ?main_feat: string -> ?filter: string list -> t -> string
52 53
  val to_conll_string: ?exclude: string list -> t -> string
  val to_conll: ?exclude: string list -> t -> (string * string) list
54 55 56

  val to_string: t -> string

bguillaum's avatar
bguillaum committed
57
  val build: ?domain:Domain.t -> Ast.feature list -> t
bguillaum's avatar
bguillaum committed
58

bguillaum's avatar
bguillaum committed
59
  val of_conll: ?loc:Loc.t -> ?domain:Domain.t -> Conll.line -> t
bguillaum's avatar
bguillaum committed
60

61 62 63
  val pst_leaf: ?loc:Loc.t -> ?domain:Domain.t -> string -> t
  val pst_node: ?loc:Loc.t -> ?domain:Domain.t -> string -> t

64 65 66
  (** [unif t1 t2] returns [Some t] if [t] is the unification of two graph feature structures
      [None] is returned if the two feature structures cannot be unified. *)
  val unif: t -> t -> t option
bguillaum's avatar
bguillaum committed
67
end (* module G_fs *)
68

bguillaum's avatar
bguillaum committed
69 70
(* ================================================================================ *)
(* module [P_fs] defines the feature structures that are used in patterns *)
71 72
module P_fs: sig
  type t
bguillaum's avatar
bguillaum committed
73

Bruno Guillaume's avatar
Bruno Guillaume committed
74 75
  val to_json: ?domain:Domain.t -> t -> Yojson.Basic.json

76
  val empty: t
77

bguillaum's avatar
bguillaum committed
78
  val build: ?domain:Domain.t -> ?pat_vars: string list -> Ast.feature list -> t
79

80
  val to_string: t -> string
pj2m's avatar
pj2m committed
81

82
  val to_dep: ?filter: string list -> (string list * string list) -> t -> string
bguillaum's avatar
bguillaum committed
83

84
  val to_dot: t -> string
pj2m's avatar
pj2m committed
85

86
  val feat_list: t -> string list
bguillaum's avatar
bguillaum committed
87

88
  exception Fail
pj2m's avatar
pj2m committed
89

bguillaum's avatar
bguillaum committed
90
  (** [match_ ?param p_fs g_fs] tries to match the pattern fs [p_fs] with the graph fs [g_fs].
91 92
      If [param] is [None], it returns [None] if matching succeeds and else raise [Fail].
      If [param] is [Some p], it returns [Some p'] if matching succeeds and else raise [Fail].
93
   *)
94 95
  val match_: ?param:Lex_par.t -> t -> G_fs.t -> Lex_par.t option

96 97
  (** [check_position ?parma position pfs] checks wheter [pfs] is compatible with a node at [position].
      It returns [true] iff [pfs] has no requirement about position ok if the requirement is satisfied. *)
98
  val check_position: ?param:Lex_par.t -> float option -> t -> bool
99

bguillaum's avatar
bguillaum committed
100
  exception Fail_unif
101

bguillaum's avatar
bguillaum committed
102
  (** [unif fs1 fs2] returns the unification of the two feature structures.
103
      It raises [Fail_unif] exception in case of Failure. *)
bguillaum's avatar
bguillaum committed
104
  val unif: t -> t -> t
105

bguillaum's avatar
bguillaum committed
106
end (* module P_fs *)