Text-Fabric Api 활용예제 4

각 단어의 속성 출력


In [1]:
from tf.fabric import Fabric

ETCBC = 'hebrew/etcbc4c'
PHONO = 'hebrew/phono'
TF = Fabric( modules=[ETCBC, PHONO], silent=False )

api = TF.load('''
    book chapter verse
    sp nu gn ps vt vs st
    otype
    det
    g_word_utf8 trailer_utf8
    lex_utf8 lex voc_utf8
    g_prs_utf8 g_uvf_utf8
    prs_gn prs_nu prs_ps g_cons_utf8
    gloss
''')


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.06s B otype                from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.02s 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.01s B verse                from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.13s B g_cons_utf8          from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.17s B g_word_utf8          from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.15s B lex_utf8             from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.06s B trailer_utf8         from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.09s B sp                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.09s 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.09s B vt                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.09s B vs                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.07s B st                   from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.13s B det                  from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.13s B lex                  from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.01s B voc_utf8             from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.11s B g_prs_utf8           from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.06s B g_uvf_utf8           from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.09s B prs_gn               from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.12s B prs_nu               from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.11s B prs_ps               from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.06s B gloss                from /home/kungsik/github/text-fabric-data/hebrew/etcbc4c
   |     0.00s Feature overview: 104 for nodes; 5 for edges; 2 configs; 7 computed
  5.72s All features loaded/computed - for details use loadLog()

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

창세기 1:1의 ברא 동사의 속성 출력 (ברא 동사는 3번 노드)


In [3]:
verseNode = T.nodeFromSection(('Genesis',1,1))
wordsNode = L.d(verseNode, otype='word')
wordsNode


Out[3]:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

In [4]:
node = wordsNode[2]

r = {
    "tricons": F.lex_utf8.v(node).replace('=', '').replace('/','').replace('[',''),
    "lex": F.lex.v(node),
    "voc_utf8": F.voc_utf8.v(L.u(node, otype='lex')[0]),
    "sp": F.sp.v(node),
    "ps": F.ps.v(node),
    "nu": F.nu.v(node),
    "gn": F.gn.v(node),
    "vt": F.vt.v(node), # vt = verbal tense
    "vs": F.vs.v(node), # vs = verbal stem
    "st": F.st.v(node), # construct/absolute/emphatic
    "is_definite": F.det.v(L.u(node, otype='phrase_atom')[0]),
    "g_prs_utf8": F.g_prs_utf8.v(node),
    "g_uvf_utf8": F.g_uvf_utf8.v(node),
    "g_cons_utf8": F.g_cons_utf8.v(node),
    "prs_nu": F.prs_nu.v(node),
    "prs_gn": F.prs_gn.v(node),
    "prs_ps": F.prs_ps.v(node),
    "has_suffix": "Yes" if F.g_prs_utf8.v(node) != "" else "No",
    "gloss": F.gloss.v(L.u(node, otype='lex')[0]),
}

r


Out[4]:
{'g_cons_utf8': 'ברא',
 'g_prs_utf8': '',
 'g_uvf_utf8': '',
 'gloss': 'create',
 'gn': 'm',
 'has_suffix': 'No',
 'is_definite': 'NA',
 'lex': 'BR>[',
 'nu': 'sg',
 'prs_gn': 'unknown',
 'prs_nu': 'unknown',
 'prs_ps': 'unknown',
 'ps': 'p3',
 'sp': 'verb',
 'st': 'NA',
 'tricons': 'ברא',
 'voc_utf8': 'ברא',
 'vs': 'qal',
 'vt': 'perf'}

In [ ]: