grew_fs.mli 4.5 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

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

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

bguillaum's avatar
bguillaum committed
52
  (** [get_annot_info fs] searches for a feature with name starting with "__".
bguillaum's avatar
bguillaum committed
53
      It returns the feature_name without the prefix "__"
bguillaum's avatar
bguillaum committed
54
      raise an [Build] exception if there is more than one such feature. *)
bguillaum's avatar
bguillaum committed
55
  val get_annot_info: t -> string option
bguillaum's avatar
bguillaum committed
56

57 58
  val to_string: t -> string

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

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

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

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

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

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

78
  val empty: t
79

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

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

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

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

88
  val feat_list: t -> string list
bguillaum's avatar
bguillaum committed
89

90
  exception Fail
pj2m's avatar
pj2m committed
91

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

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

bguillaum's avatar
bguillaum committed
102
  exception Fail_unif
103

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

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