ENIAMsemXMLof.ml
3.83 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
(*
* ENIAMsemantics implements semantic processing for ENIAM
* 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 ENIAMsemTypes
let rec linear_term = function
| Tuple l -> Xml.Element("Tuple",[],Xlist.map l linear_term)
| Variant(e,l) ->
Xml.Element("Variant",["label",e],Xlist.map l (fun (i,t) ->
Xml.Element("option",["number",i],[linear_term t])))
| Dot -> Xml.Element("Dot",[],[])
| Val s -> Xml.Element("Val",[],[Xml.PCData s])
| Node t ->
Xml.Element("Node",["orth",t.orth;"lemma",t.lemma;"pos",t.pos;
"weight",string_of_float t.weight;"id",string_of_int t.id;"arg_dir",t.arg_dir;"gf",t.gf;
"role",t.role;"role_attr",t.role_attr;"arole",t.arole;"arole_attr",t.arole_attr;
"arev",string_of_bool t.arev;"label",t.label;"def_label",t.def_label],
[Xml.Element("symbol",[],[linear_term t.symbol]);
Xml.Element("arg_symbol",[],[linear_term t.arg_symbol]);
Xml.Element("attrs",[],Xlist.map t.attrs (fun (k,v) -> Xml.Element("attr",["name",k],[linear_term v])));
Xml.Element("args",[],[linear_term t.args]);
Xml.Element("selprefs",[],[linear_term t.selprefs]);
Xml.Element("meaning",[],[linear_term t.meaning]);
Xml.Element("sem_args",[],[linear_term t.sem_args])])
| Ref i -> Xml.Element("Ref",["id",string_of_int i],[])
| Concept c ->
Xml.Element("Concept",["local_quant",string_of_bool c.c_local_quant;
"label",c.c_label;"def_label",c.c_def_label;
"variable",fst c.c_variable ^ "_" ^ snd c.c_variable;"pos",string_of_int c.c_pos],
[Xml.Element("sense",[],[linear_term c.c_sense]);
Xml.Element("name",[],[linear_term c.c_name]);
Xml.Element("quant",[],[linear_term c.c_quant]);
Xml.Element("relations",[],[linear_term c.c_relations]);
Xml.Element("cat",[],[linear_term c.c_cat])])
| Context c ->
Xml.Element("Context",
["variable",fst c.cx_variable ^ "_" ^ snd c.cx_variable;"pos",string_of_int c.cx_pos],
[Xml.Element("sense",[],[linear_term c.cx_sense]);
Xml.Element("contents",[],[linear_term c.cx_contents]);
Xml.Element("relations",[],[linear_term c.cx_relations]);
Xml.Element("cat",[],[linear_term c.cx_cat])])
| Relation(r,a,c) -> Xml.Element("Relation",["role",r;"role_attribute",a],[linear_term c])
| RevRelation(r,a,c) -> Xml.Element("RevRelation",["role",r;"role_attribute",a],[linear_term c])
| SingleRelation r -> Xml.Element("SingleRelation",[],[linear_term r])
| AddRelation(t,r,a,s) ->
Xml.Element("AddRelation",["role",r;"role_attribute",a],
[Xml.Element("",[],[linear_term t]);Xml.Element("",[],[linear_term s])])
| RemoveRelation(r,a,t) -> Xml.Element("RemoveRelation",["role",r;"role_attribute",a],[linear_term t])
| SetContextName(s,t) ->
Xml.Element("SetContextName",[],[linear_term s;linear_term t])
| CreateContext(s,t) ->
Xml.Element("CreateContext",[],[linear_term (Context s);linear_term t])
| ManageCoordination(t,r) ->
Xml.Element("ManageCoordination",[],[linear_term (Node t);linear_term r])