ENIAM_LCGtypes.ml
5.13 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
(*
* ENIAM_LCGparser, a parser for Logical Categorial Grammar formalism
* Copyright (C) 2016-2017 Wojciech Jaworski <wjaworski atSPAMfree mimuw dot edu dot pl>
* Copyright (C) 2016-2017 Institute of Computer Science Polish Academy of Sciences
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
open Xstd
type direction = Forward | Backward | Both
type linear_variable = string
type node = {
orth: string;
lemma: string;
pos: string;
weight: float;
id: int;
symbol: linear_term;
arg_symbol: linear_term;
arg_dir: string;
(*agf: ENIAMwalTypes.gf;
amorf: ENIAMwalTypes.morf;
arole: string;
arole_attr: string;
meaning: string;
hipero: StringSet.t;
meaning_weight: float;
position: ENIAMwalTypes.schema_field;*)
attrs: (string * linear_term) list;
args: linear_term}
(*and concept =
{c_sense: linear_term; c_name: linear_term; (*c_visible_var: bool;*) c_quant: linear_term; c_local_quant: bool;
(*c_modalities: (string * type_term) list;*)
c_relations: linear_term; c_variable: (string * string); c_pos: int}
and context =
{cx_sense: linear_term; cx_contents: linear_term; cx_relations: linear_term; cx_variable: (string * string); cx_pos: int}*)
and linear_term =
Var of linear_variable
| Tuple of linear_term list
(* | LetIn of linear_variable list * linear_term * linear_term *)
| Variant of string * (string * linear_term) list (* etykieta * indeks * term *)
| VariantVar of string * linear_term
| Proj of int * linear_term
| ProjVar of string * linear_term
| SubstVar of string
| Subst of linear_term * string * linear_term
| Inj of int * linear_term
| Case of linear_term * (linear_variable * linear_term) list
| Lambda of linear_variable * linear_term
| LambdaSet of linear_variable list * linear_term
| LambdaRot of int * linear_term
| App of linear_term * linear_term
| Dot
| SetAttr of string * linear_term * linear_term
| Val of string
| Fix of linear_term * linear_term
| Empty of linear_term
| Apply of linear_term
| Insert of linear_term * linear_term
| Node of node
(* | Morf of ENIAMwalTypes.morf
| Gf of ENIAMwalTypes.gf*)
(* | Choice of (*linear_term StringMap.t*) string * string list * linear_term (* etykieta * indeksy * term *) *)
(* | Concept of concept
| Context of context
| Relation of linear_term * linear_term * linear_term (* role * role_attr * concept *)
| RevRelation of linear_term * linear_term * linear_term (* role * role_attr * concept *)
| SingleRelation of linear_term
| AddRelation of linear_term * string * string * linear_term (* nadrządnik * role * role_attr * podrzędnik *)
| RemoveRelation of linear_term
| SetContextName of string * linear_term*)
| Coord of linear_term list * linear_term * linear_term
| AddCoord of linear_term * linear_term
| MapCoord of linear_term * linear_term
| ConcatCoord of linear_term * linear_term
| Ref of int
| Cut of linear_term
type internal_grammar_symbol =
Atom of string
| AVar of string
| With of internal_grammar_symbol list
| Zero
| Top
type grammar_symbol =
Tensor of internal_grammar_symbol list
| Plus of grammar_symbol list
| Imp of grammar_symbol * direction * grammar_symbol
| One
| ImpSet of grammar_symbol * (direction * grammar_symbol) list
| WithVar of string * internal_grammar_symbol * string * grammar_symbol (* zmienna * wartości * etykieta * term *)
| StarWith of grammar_symbol list
| Star of grammar_symbol * grammar_symbol (* argument * funktor spójnika *)
| Conj of grammar_symbol (* funktor spójnika *)
| Preconj
| Bracket of bool * bool * grammar_symbol
| BracketSet of direction
| Maybe of grammar_symbol
module OrderedSymbol = struct
type t = grammar_symbol
let compare = compare
end
module SymbolMap = Xmap.Make(OrderedSymbol)
module OrderedTerm = struct
type t = linear_term
let compare = compare
end
module TermMap = Xmap.Make(OrderedTerm)
module TermSet = Xset.Make(OrderedTerm)
module OrderedSymbolTerm = struct
type t = grammar_symbol * linear_term
let compare = compare
end
module SymbolTermSet = Xset.Make(OrderedSymbolTerm)
type chart = (SymbolTermSet.key list * int) array array array
exception Timeout of float
exception SemTooBig
type dep_tree =
DepNode of int * dep_tree list * (grammar_symbol * linear_term) list * dep_tree list (* conll_id * left_nodes * ... * right_nodes *)
exception NotDepParsed of
int *
(grammar_symbol * linear_term) list list *
(grammar_symbol * linear_term) list *
(grammar_symbol * linear_term) list list
let no_nodes = ref 10000000