-
Notifications
You must be signed in to change notification settings - Fork 0
/
statistics.py
73 lines (68 loc) · 1.53 KB
/
statistics.py
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
import transforge as tf
from ratiotheory import ratiotheory
#from lang2tools import lang2tools
import json
def test(complex_string):
return ratiotheory.parse(complex_string, *(tf.Source() for _ in range(10)))#.primitive()
expressions =[
"""
1: R2(MassDensity, Region);
2: R1(Region);
consarchimed(
arealinterpol(
coverage2lattice(1)
,
2
)
)
""",
"""
1: R2(MassDensity, Region);
2: R1(Region);
consarchimed(
field2lattice (
revert 1
) 2
)
""",
"""
1: R2(Region, EventCount);
2: R1(Region);
consarchimed(
arealinterpol(
consproportion(1),
2
)
)
""",
"""
1: R2(Object, Region * EventCount) ;
2: R1(Region);
apply2 multiply
(arealinterpol
(getregionqualities
(join_attr
(get_attrL 1)
(apply2 ratio
(get_attrR 1)
(apply1(measure,get_attrL(1)))
)
)
) 2
)
(apply measure 2)
""",
"""
1: AmountofObject;
2: Region;
multiply(ratio(measure(1),measure(2)), measure(2))
"""
]
for e in expressions:
print(test(e).tree())
#Get the subtype structure (ontology) in rdf
g = tf.TransformationGraph(ratiotheory)
g.add_taxonomy()
g.add_operators()
print(g.serialize())
#print(json.dumps(lang2tools(ratiotheory, avgfield=(ratiotheory.MassDensity,)), indent=4))