grew_domain.mli 3.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
(**********************************************************************************)
(*    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                                                   *)
(**********************************************************************************)

open Grew_base
open Grew_types
open Grew_ast

(* ================================================================================ *)
module Label_domain : sig
  type style
  val parse_option: string -> string list -> style
  val is_void: style -> bool

  val to_dep: ?deco:bool -> style -> string
  val to_dot: ?deco:bool -> style -> string

  type t

  (* [decl] is the type for a label declaration: the name and a list of display options *)
  type decl = string * string list

29 30
  val merge: decl list -> decl list -> decl list

31
  val build: decl list -> t
32

33 34 35 36 37 38
end

(* ================================================================================ *)
module Feature_domain: sig
  type t

39 40 41
  val build:
    ?conll_fields: (string * string * string * string) ->
    Ast.feature_spec list -> t
42

43 44 45
  (** [sub domain fn1 fn2] returns [true] iff the domain of [fn1] is a subset if the domain of [fn2]. *)
  val sub:  t -> feature_name -> feature_name -> bool

46
  val merge: Ast.feature_spec list -> Ast.feature_spec list -> Ast.feature_spec list
47 48 49 50 51 52
end (* module Feature_domain *)

(* ================================================================================ *)
module Domain : sig
  type t

53 54
  val dump: t option -> unit

Bruno Guillaume's avatar
Bruno Guillaume committed
55 56
  val to_json: t -> Yojson.Basic.json

57
  val build: Label_domain.t -> Feature_domain.t -> t
58 59
  val build_features_only: Feature_domain.t -> t
  val build_labels_only: Label_domain.t -> t
60 61 62 63 64 65 66 67 68 69 70 71

  val build_disj : ?loc:Loc.t -> ?domain:t ->
           feature_name ->
           feature_atom list -> value list


  val feature_names: t -> string list

  val get_label_name: ?domain:t -> int -> string option
  val get_label_style: ?domain:t -> int -> Label_domain.style option

  val edge_id_from_string: ?loc:Loc.t -> ?domain:t -> string -> int option
72

73 74 75
  (** [is_open_feature domain feature_name] returns [true] iff no domain is set or if [feature_name] is defined to be open in the current domain. *)
  val is_open_feature: ?domain: t -> feature_name -> bool

76 77 78
  (** [is_num domain feature_name] returns [true] iff the domain is set and [feature_name] is defined to be numerical *)
  val is_num: ?domain: t -> feature_name -> bool

79 80 81 82 83
  (** [check_feature ~loc domain feature_name feature_value] fails iff a domain is set and [feature_name,feature_value] is not defined in the current domain. *)
  val check_feature: ?loc:Loc.t -> ?domain: t -> feature_name -> feature_atom -> unit

  (** [check_feature_name ~loc domain feature_name] fails iff a domain is set and [feature_name] is not defined in the current domain. *)
  val check_feature_name: ?loc:Loc.t -> ?domain:t -> feature_name -> unit
84 85

  val conll_fields: t option -> (string * string * string * string)
86
end