grew_rule.mli 3.38 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3
(**********************************************************************************)
(*    Libcaml-grew - a Graph Rewriting library dedicated to NLP applications      *)
(*                                                                                *)
Bruno Guillaume's avatar
Bruno Guillaume committed
4
(*    Copyright 2011-2018 Inria, Université de Lorraine                           *)
bguillaum's avatar
bguillaum committed
5
(*                                                                                *)
Bruno Guillaume's avatar
Bruno Guillaume committed
6
(*    Webpage: http://grew.fr                                                     *)
bguillaum's avatar
bguillaum committed
7 8 9 10
(*    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
bguillaum's avatar
bguillaum committed
12
open Grew_base
13
open Grew_types
14
open Grew_domain
bguillaum's avatar
bguillaum committed
15 16
open Grew_graph
open Grew_command
pj2m's avatar
pj2m committed
17 18
open Grew_edge
open Grew_fs
bguillaum's avatar
bguillaum committed
19
open Grew_ast
pj2m's avatar
pj2m committed
20 21


22
(* ================================================================================ *)
pj2m's avatar
pj2m committed
23 24 25
module Rule : sig
  type t

26 27 28 29 30 31
  (** [set_max_depth_det value] set the maximum rewriting depth in deterministic application of a module. *)
  val set_max_depth_det: int -> unit

  (** [set_max_depth_non_det value] set the maximum rewriting depth in non-deterministic application of a module. *)
  val set_max_depth_non_det: int -> unit

bguillaum's avatar
bguillaum committed
32 33 34 35
  (** [set_debug_loop ()] turns the debug mode on for loop: when the bound is reached, the graph is considered as a normal form.
      This is a kind of hack to be able to explore loops in GUI. *)
  val set_debug_loop: unit -> unit

36
  (** [get_name t] returns the name of the rule [t]. *)
bguillaum's avatar
bguillaum committed
37 38
  val get_name: t -> string

bguillaum's avatar
bguillaum committed
39
  (** [get_loc t] returns the file location of the rule [t]. *)
40 41
  val get_loc: t -> Loc.t

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

bguillaum's avatar
bguillaum committed
44
  (** [to_dep t] returns a string in the [dep] language describing the match basic of the rule *)
bguillaum's avatar
bguillaum committed
45
  val to_dep: ?domain:Domain.t -> t -> string
bguillaum's avatar
bguillaum committed
46

47
  (** [build domain ?local dir ast_rule] returns the Rule.t value corresponding to [ast_rule].
48
      [dir] is used for localisation of lp files *)
Bruno Guillaume's avatar
Bruno Guillaume committed
49
  val build: ?domain:Domain.t -> string -> Ast.rule -> t
pj2m's avatar
pj2m committed
50

bguillaum's avatar
bguillaum committed
51

bguillaum's avatar
bguillaum committed
52 53
  (** the type matching encodes the graph morphism from a pattern to a graph *)
  (* NB: it was made public for the grep mode *)
bguillaum's avatar
bguillaum committed
54
  type matching
55 56
  type pattern

57
  val pid_name_list: pattern -> Id.name list
58

Bruno Guillaume's avatar
Bruno Guillaume committed
59
  val to_python: pattern -> G_graph.t -> matching -> json
60

Bruno Guillaume's avatar
Bruno Guillaume committed
61
  val build_pattern: ?domain:Domain.t -> ?lexicons: Lexicons.t -> Ast.pattern -> pattern
bguillaum's avatar
bguillaum committed
62

63
  (** [node_matching pattern graph matching] return a assoc list (pid_name, gid.position) *)
64
  val node_matching: pattern -> G_graph.t -> matching -> (string * float) list
65

bguillaum's avatar
bguillaum committed
66
  (** [match_in_graph rule graph] returns the list of matching of the pattern of the rule into the graph *)
67
  val match_in_graph: ?domain:Domain.t -> ?lexicons: Lexicons.t -> pattern -> G_graph.t -> matching list
bguillaum's avatar
bguillaum committed
68

69
  (** [match_deco rule matching] builds the decoration of the [graph] illustrating the given [matching] of the [rule] *)
bguillaum's avatar
bguillaum committed
70
  (* NB: it can be computed independly from the graph itself! *)
71
  val match_deco: pattern -> matching -> G_deco.t
Bruno Guillaume's avatar
Bruno Guillaume committed
72 73 74 75




Bruno Guillaume's avatar
Bruno Guillaume committed
76 77
  val wrd_apply: ?domain: Domain.t -> t -> (G_graph.t * Libgrew_types.big_step option) -> (G_graph.t * Libgrew_types.big_step) option

78
  val onf_apply: ?domain: Domain.t -> t -> G_graph.t -> G_graph.t option
Bruno Guillaume's avatar
Bruno Guillaume committed
79

80 81 82 83
  val gwh_apply: ?domain: Domain.t -> t -> Graph_with_history.t -> Graph_with_history_set.t



Bruno Guillaume's avatar
Bruno Guillaume committed
84

85
end (* module Rule *)