grew_fs.mli 4.46 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                                                   *)
(**********************************************************************************)

Bruno Guillaume's avatar
Bruno Guillaume committed
11
open Yojson.Basic
12 13
open Conll

14
open Grew_base
15
open Grew_types
bguillaum's avatar
bguillaum committed
16
open Grew_ast
17 18 19 20 21 22 23 24 25
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
26

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

32
  val empty: t
33

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

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

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

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

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

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

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

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

65 66 67
  (** [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
68
end (* module G_fs *)
69

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

75 76
  val to_json: ?domain:Domain.t -> t -> Yojson.Basic.json

77
  val empty: t
78

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

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

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

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

87
  val feat_list: t -> (string * string option) list
bguillaum's avatar
bguillaum committed
88

89
  exception Fail
pj2m's avatar
pj2m committed
90

bguillaum's avatar
bguillaum committed
91
  (** [match_ ?param p_fs g_fs] tries to match the pattern fs [p_fs] with the graph fs [g_fs].
92 93
      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].
94
   *)
95 96
  val match_: ?param:Lex_par.t -> t -> G_fs.t -> Lex_par.t option

97 98
  (** [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. *)
99
  val check_position: ?param:Lex_par.t -> float option -> t -> bool
100

bguillaum's avatar
bguillaum committed
101
  exception Fail_unif
102

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

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