ENIAMsemStringOf.ml
3.04 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
(*
* 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 c = function
| Tuple l ->
let s = String.concat "⊗" (Xlist.map l (linear_term 2)) in
if c > 1 then "(" ^ s ^ ")" else s
| Variant(e,l) -> "〈" ^ String.concat "," (Xlist.map l (fun (i,t) -> e^i^": "^linear_term 0 t)) ^ "〉"
| Dot -> "∙"
| Val s -> s
| Node t ->
"[" ^
(String.concat "; " (Xlist.map (["ORTH",Val t.orth;"LEMMA",Val t.lemma;"POS",Val t.pos;"ID",Val (string_of_int t.id);
"WEIGHT",Val (string_of_float t.weight);"SYMBOL",t.symbol;
"ARG_SYMBOL",t.arg_symbol;"ARG_DIR",Val t.arg_dir;"ARGS",t.args] @ t.attrs) (fun (e,t) ->
e ^ ": " ^ (linear_term 0 t)))) ^ "]"
| Ref i -> "ref " ^ string_of_int i
| Concept c ->
"[" ^
(String.concat "; " (Xlist.map ([
"SENSE",c.c_sense;"NAME",c.c_name;
"VARIABLE",Val (fst c.c_variable ^ "_" ^ snd c.c_variable);"POS",Val (string_of_int c.c_pos);
"QUANT",c.c_quant;"LOCAL-QUANT",if c.c_local_quant then Val "+" else Val "-";"RELATIONS",c.c_relations]) (fun (e,t) ->
e ^ ": " ^ (linear_term 0 t)))) ^ "]"
| Context c ->
"[" ^
(String.concat "; " (Xlist.map ([
"SENSE",c.cx_sense;
"VARIABLE",Val (fst c.cx_variable ^ "_" ^ snd c.cx_variable);"POS",Val (string_of_int c.cx_pos);
"RELATIONS",c.cx_relations;"CONTENTS",c.cx_contents]) (fun (e,t) ->
e ^ ": " ^ (linear_term 0 t)))) ^ "]"
| Relation(r,a,c) -> "relation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 c ^ ")"
| RevRelation(r,a,c) -> "revrelation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 c ^ ")"
| SingleRelation r -> "singlerelation(" ^ linear_term 0 r ^ ")"
| TripleRelation(r,a,c,t) -> "triplerelation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 c ^ "," ^ linear_term 0 t ^ ")"
| AddRelation(t,r,a,s) -> "addrelation(" ^ linear_term 0 t ^ "," ^ r ^ "," ^ a ^ "," ^ linear_term 0 s ^ ")"
| RemoveRelation r -> "removerelation(" ^ linear_term 0 r ^ ")"
| SetContextName(s,t) -> "setcontextname(" ^ linear_term 0 s ^ "," ^ linear_term 0 t ^ ")"
| MakeTripleRelation(r,a,c) -> "maketriplerelation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 c ^ ")"