This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
yesh-test.py
126 lines (93 loc) · 2.04 KB
/
yesh-test.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
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
# coding: utf-8
# In[1]:
import sys
import collections
import subprocess
from lxml import etree
import laf
from laf.fabric import LafFabric
from etcbc.preprocess import prepare
from etcbc.mql import MQL
fabric = LafFabric()
# In[2]:
API = fabric.load('etcbc4', '--', 'mql', {
"xmlids": {"node": False, "edge": False},
"features": ('''
oid otype monads
g_word g_word_utf8 g_cons lex
typ code function rela det
book chapter verse label
''',''),
"prepare": prepare,
}, verbose='DETAIL')
exec(fabric.localnames.format(var='fabric'))
# In[3]:
i = 0
for n in NN():
i += 1
print(i)
# The number of nodes that you see should be ``1441144`` and the number below should have the same value.
# In[4]:
Q = MQL(API)
print('There are {} objects'.format(len(Q.index2node)))
# In[5]:
yesh_query = '''
select all objects where
[book [chapter [verse
[clause
[clause_atom
[phrase
[phrase_atom
[word lex="JC/" or lex=">JN/"]
]
]
]
]
]]]
'''
# In[10]:
sheaf = Q.mql(yesh_query)
# In[7]:
for x in sheaf.results():
print(x)
break
# In[15]:
nresults = 0
n_yesh = 0
n_ein = 0
for ((book,
((chapter,
((verse,
((clause,
((clause_atom,
((phrase,
((phrase_atom,
((word,),
)),
)),
)),
)),
)),
)),
)),
) in sheaf.results():
nresults += 1
lex = F.lex.v(word)
if lex == 'JC/':
n_yesh += 1
else:
n_ein += 1
print('{:<15s} {:>3}:{:>3} {:<5s} {:<15s} {:>5}-{:<3} {}-{} {}'.format(
F.book.v(book),
F.chapter.v(chapter),
F.verse.v(verse),
lex,
F.g_word.v(word),
F.typ.v(clause),
F.code.v(clause_atom),
F.function.v(phrase),
F.det.v(phrase_atom),
F.g_word_utf8.v(word),
))
print('There are {} results, {} yesh and {} ein'.format(nresults, n_yesh, n_ein))
# In[ ]: