Blame view

walenty/ENIAMwalTypes.ml 6.73 KB
Wojciech Jaworski authored
1
(*
Wojciech Jaworski authored
2
3
4
 *  ENIAMwalenty, a converter for Polish Valence Dictionary "Walenty".
 *  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
Wojciech Jaworski authored
5
 *
Wojciech Jaworski authored
6
7
 *  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
Wojciech Jaworski authored
8
9
10
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
Wojciech Jaworski authored
11
 *  This library is distributed in the hope that it will be useful,
Wojciech Jaworski authored
12
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Wojciech Jaworski authored
14
 *  GNU Lesser General Public License for more details.
Wojciech Jaworski authored
15
 *
Wojciech Jaworski authored
16
 *  You should have received a copy of the GNU Lesser General Public License
Wojciech Jaworski authored
17
18
19
20
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *)

open Xstd
Wojciech Jaworski authored
22
23
type opinion = Pewny | Potoczny | Watpliwy | Archaiczny | Zly | Wulgarny | Nieokreslony
             | Metaforyczny | Dziedzinowy | Sporadyczny | OpinionUndef
Wojciech Jaworski authored
24
type negation = Negation | Aff | NegationUndef | NegationNA
Wojciech Jaworski authored
25
type pred = PredTrue | PredFalse | PredUndef | PredNA
Wojciech Jaworski authored
26
27
28
type aspect = Aspect of string | AspectUndef | AspectNA
type case = Case of string | Str | Part | CaseAgr | NomAgr | GenAgr | AllAgr | CaseUndef | AllUAgr | CaseUAgr
type comp = Comp of string | Zeby | Gdy | CompUndef
Wojciech Jaworski authored
29
type comp_type = Int | Rel | CompTypeUndef
Wojciech Jaworski authored
30
31
type number = Number of string | NumberUndef | NumberAgr
type gender = Gender of string | GenderUndef | GenderAgr | Genders of string list
Wojciech Jaworski authored
32
type grad = Grad of string | GradUndef
Wojciech Jaworski authored
33
type refl = ReflEmpty | ReflTrue | ReflFalse | ReflUndef
Wojciech Jaworski authored
34
(* type acm = Acm of string | AcmUndef *)
Wojciech Jaworski authored
35
Wojciech Jaworski authored
36
type gf = SUBJ | OBJ | ARG
Wojciech Jaworski authored
37
Wojciech Jaworski authored
38
type pos =
Wojciech Jaworski authored
39
    SUBST of number * case
Wojciech Jaworski authored
40
41
42
  | PPRON12 of number * case
  | PPRON3 of number * case
  | SIEBIE of case
Wojciech Jaworski authored
43
  | PREP of case
Wojciech Jaworski authored
44
  | NUM of case * gender (* acm*)
Wojciech Jaworski authored
45
46
  | ADJ of number * case * gender * grad
  | ADV of grad
Wojciech Jaworski authored
47
48
  | GER of number * case * gender * aspect * negation (** refl*)
  | PACT of number * case * gender * aspect * negation (* refl*)
Wojciech Jaworski authored
49
  | PPAS of number * case * gender * aspect * negation
Wojciech Jaworski authored
50
  | INF of aspect * negation (* refl*)
Wojciech Jaworski authored
51
52
53
  | QUB
  | COMPAR
  | COMP of comp_type
Wojciech Jaworski authored
54
  | PERS of (*number * gender * aspect * person * *)negation (* refl*)
Wojciech Jaworski authored
55
  | FIXED
Wojciech Jaworski authored
56
57

type phrase =
Wojciech Jaworski authored
58
    NP of case
Wojciech Jaworski authored
59
  | PrepNP of string * case
Wojciech Jaworski authored
60
  | AdjP of case
Wojciech Jaworski authored
61
  | PrepAdjP of string * case
Wojciech Jaworski authored
62
  | NumP of case
Wojciech Jaworski authored
63
64
  | PrepNumP of string * case
  | ComprepNP of string
Wojciech Jaworski authored
65
  | ComparP of string (** case*)
Wojciech Jaworski authored
66
67
  | CP of comp_type * comp
  | NCP of case * comp_type * comp
Wojciech Jaworski authored
68
69
  | PrepNCP of string * case * comp_type * comp
  | InfP of aspect
Wojciech Jaworski authored
70
  | AdvP of string
Wojciech Jaworski authored
71
  | FixedP of string
Wojciech Jaworski authored
72
  (* | Num of case (* acm*) *)
Wojciech Jaworski authored
73
74
  | Or
  | Qub
Wojciech Jaworski authored
75
76
  (* | Pro
  | ProNG *)
Wojciech Jaworski authored
77
  | Null
Wojciech Jaworski authored
78
79
80
81
82
  | GerP of case
  | PrepGerP of string * case
  | PpasP of case
  | PrepPpasP of string * case
  | PactP of case
Wojciech Jaworski authored
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

type phrase_abbr =
    Xp of string
  | Nonch
  | Distrp
  | Possp

type phrase_comp =
    Cp
  | Ncp of case
  | Prepncp of string * case

type lex =
    Lexeme of string
  | ORconcat of lex list
  | ORcoord of lex list
  | XOR of lex list
  | Elexeme of gender
Wojciech Jaworski authored
101
Wojciech Jaworski authored
102
type restr = Natr | Ratr | Ratrs | Ratr1 | Atr | Atr1 | NoRestr
Wojciech Jaworski authored
103
Wojciech Jaworski authored
104
105
106
107
108
109
110
type sel_prefs =
    SynsetId of int
  | Predef of string
  | RelationArgId of string * int (* nazwa relacji * id argumentu ramy *)
  | RelationRole of string * string * string (* relacji * rola * atrybut roli *)

type position = {psn_id: int; gf: gf; role: string; role_attr: string; sel_prefs: sel_prefs list;
Wojciech Jaworski authored
111
112
113
114
115
116
117
118
119
120
121
                 mode: string list; cr: string list; ce: string list; morfs: morf list}

and morf =
    Phrase of phrase
  | E of phrase
  | LexPhrase of (pos * lex) list * (restr * position list)
  | PhraseAbbr of phrase_abbr * morf list
  | PhraseComp of phrase_comp * (comp_type * comp list)
  | MorfId of int
  | SimpleLexArg of string * pos
  | LexArg of int * string * pos
Wojciech Jaworski authored
122
123

let empty_position =
Wojciech Jaworski authored
124
  {psn_id=(-1); gf=ARG; role=""; role_attr=""; mode=[]; sel_prefs=[]; cr=[]; ce=[]; morfs=[]}
Wojciech Jaworski authored
125
Wojciech Jaworski authored
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
type lex_record = {
  lex_argument: morf;
  lex_arguments: morf list;
  lex_lemma: lex;
  lex_numeral_lemma: lex;
  lex_mode: string list;
  lex_negation: negation;
  lex_degree: grad;
  lex_number: number;
  lex_reflex: refl;
  lex_gender: gender;
  lex_modification: restr * position list;
}

let empty_lex = {lex_argument=Phrase Null; lex_arguments=[]; lex_lemma=Lexeme "";
                 lex_numeral_lemma=Lexeme ""; lex_mode=[]; lex_negation=NegationUndef;
                 lex_degree=GradUndef; lex_number=NumberUndef; lex_reflex=ReflUndef;
                 lex_gender=GenderUndef; lex_modification = Natr,[]}
Wojciech Jaworski authored
145
146
147
148
149
150
151
152
153
154
155
156
type meaning = {mng_id: int;
                name: string;
                variant: string;
                plwnluid: int;
                gloss: string}

let empty_meaning = {mng_id = (-1);
                     name = "";
                     variant = "";
                     plwnluid = (-1);
                     gloss = ""}
Wojciech Jaworski authored
157
type schema = {sch_id: int; opinion: opinion; reflexiveMark: bool; aspect: aspect;
Wojciech Jaworski authored
158
159
               negativity: negation; predicativity: pred; positions: position list; text_rep: string}
Wojciech Jaworski authored
160
161
type lex_entry =
    SimpleLexEntry of string * string
Wojciech Jaworski authored
162
163
  | LexEntry of int * string * string * restr * position list
  | ComprepNPEntry of string * restr * position list
Wojciech Jaworski authored
164
Wojciech Jaworski authored
165
Wojciech Jaworski authored
166
module OrderedEntry = struct
Wojciech Jaworski authored
167
  type  t = lex_entry
Wojciech Jaworski authored
168
169
170
171
  let compare = compare
end

module EntrySet = Xset.Make(OrderedEntry)
Wojciech Jaworski authored
172
Wojciech Jaworski authored
173
174
175
176
module OrderedAbbr = struct
  type  t = phrase_abbr
  let compare = compare
end
Wojciech Jaworski authored
177
Wojciech Jaworski authored
178
module AbbrMap = Xmap.Make(OrderedAbbr)
Wojciech Jaworski authored
179
Wojciech Jaworski authored
180
181
182
183
module OrderedComp = struct
  type  t = comp_type
  let compare = compare
end
Wojciech Jaworski authored
184
Wojciech Jaworski authored
185
module CompMap = Xmap.Make(OrderedComp)
Wojciech Jaworski authored
186
Wojciech Jaworski authored
187
type example = {exm_id: int;
Wojciech Jaworski authored
188
189
                meaning: int;
                phrases: (int * int * int) list;
Wojciech Jaworski authored
190
191
192
193
194
                sentence: string;
                source: string;
                opinion: opinion;
                note: string}
Wojciech Jaworski authored
195
type argument = {arg_id: int;
Wojciech Jaworski authored
196
197
                 role: string;
                 role_attribute: string;
Wojciech Jaworski authored
198
                 sel_prefs: sel_prefs list}
Wojciech Jaworski authored
199
Wojciech Jaworski authored
200
type frame  = {frm_id: int;
Wojciech Jaworski authored
201
               opinion: opinion;
Wojciech Jaworski authored
202
               meanings: int list;
Wojciech Jaworski authored
203
204
               arguments: argument list}
Wojciech Jaworski authored
205
206
207
208
type connection = {argument: int;
                   phrases: (int * int list) list}

type alternation = {schema: int; frame: int; connections: connection list}
Wojciech Jaworski authored
209
Wojciech Jaworski authored
210
type entry = {ent_id: int;
Wojciech Jaworski authored
211
212
213
214
215
              status: string;
              form_orth: string;
              form_pos: string;
              schemata: schema list;
              examples: example list;
Wojciech Jaworski authored
216
              frames: frame list;
Wojciech Jaworski authored
217
              meanings: meaning list;
Wojciech Jaworski authored
218
              alternations: alternation list}
Wojciech Jaworski authored
219
Wojciech Jaworski authored
220
let empty_entry = {ent_id=(-1); status=""; form_orth=""; form_pos=""; schemata=[]; examples=[];
Wojciech Jaworski authored
221
                   frames=[]; meanings=[]; alternations=[]}