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
''')


This is Text-Fabric 2.3.7
Api reference : https://github.com/ETCBC/text-fabric/wiki/Api
Tutorial      : https://github.com/ETCBC/text-fabric/blob/master/docs/tutorial.ipynb
Data sources  : https://github.com/ETCBC/text-fabric-data
Data docs     : https://etcbc.github.io/text-fabric-data
Shebanq docs  : https://shebanq.ancient-data.org/text
Slack team    : https://shebanq.slack.com/signup
Questions? Ask shebanq@ancient-data.org for an invite to Slack
111 features found and 0 ignored
  0.00s loading features ...
   |     0.03s B otype                from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.01s B book                 from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.01s B chapter              from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.00s B verse                from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.14s B lex_utf8             from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.10s B sp                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.10s B nu                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.09s B gn                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.10s B ps                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.10s B vt                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.11s B vs                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.08s B st                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.01s B gloss                from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.16s B typ                  from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.00s Feature overview: 104 for nodes; 5 for edges; 2 configs; 7 computed
  4.91s All features loaded/computed - for details use loadLog()

In [3]:
api.makeAvailableIn(globals())

In [5]:
chpNode = T.nodeFromSection(('Esther',))
chpNode


Out[5]:
1367567

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 [ ]: