In [1]:
from tf.fabric import Fabric
import csv
ETCBC = 'hebrew/etcbc4c'
TF = Fabric( modules=ETCBC, silent=False )
api = TF.load('''
book chapter verse
sp nu gn ps vt vs st
otype lex_utf8
gloss typ
''')
In [3]:
api.makeAvailableIn(globals())
In [5]:
chpNode = T.nodeFromSection(('Esther',))
chpNode
Out[5]:
In [6]:
wordNode = L.d(chpNode, otype='word')
c = ''
p = ''
i = 0
book = 'esth'
f = open('./' + book + '.csv','w')
csvWriter = csv.writer(f)
csvWriter.writerow(['book','lex','sp','vs','vt','ctyp','ptyp','gloss'])
for n in wordNode:
sentenceNode = L.u(n, otype='sentence')
clauseNode = L.u(n, otype='clause')
phraseNode = L.u(n, otype='phrase')
if i == 0:
clauseCode = F.typ.v(clauseNode[0])
phraseCode = F.typ.v(phraseNode[0])
else:
if clauseNode[0] == c:
clauseCode = ''
else:
clauseCode = F.typ.v(clauseNode[0])
if phraseNode[0] == p:
phraseCode = ''
else:
phraseCode = F.typ.v(phraseNode[0])
verbal_stem = F.vs.v(n)
verbal_tense = F.vt.v(n)
if verbal_stem == 'NA':
verbal_stem = ''
if verbal_tense == 'NA':
verbal_tense = ''
csvWriter.writerow([book, F.lex_utf8.v(n),F.sp.v(n),verbal_stem,verbal_tense,clauseCode,phraseCode,F.gloss.v(L.u(n, otype='lex')[0])])
#print('{}\t{}\t{}\t{}\t{}\t{}\t{}'.format(F.lex_utf8.v(n), F.sp.v(n), verbal_stem, verbal_tense, clauseCode, phraseCode, F.gloss.v(L.u(n, otype='lex')[0])))
c = clauseNode[0]
p = phraseNode[0]
i = i + 1
In [ ]: