Mother - walking edges in the Hebrew Bible

This is a task using edges. In the Hebrew data source, nodes corresponding to constituents may have labelled edges pointing to other constituents. We make an inventory of all such edges labeled mother.


In [1]:
import sys
import collections

from laf.fabric import LafFabric
processor = LafFabric(verbose='DETAIL')


  0.00s This is LAF-Fabric 4.3.3
http://laf-fabric.readthedocs.org/en/latest/texts/API-reference.html

In [2]:
API = processor.load('etcbc4', '--', 'mother',
{
    "xmlids": {"node": False, "edge": False},
    "features": ("otype book", "mother"),
})


  0.00s LOADING API: please wait ... 
  0.10s DETAIL: COMPILING m: UP TO DATE
  0.10s INFO: USING DATA COMPILED AT: 2014-07-14T16-45-08
  0.11s DETAIL: COMPILING a: UP TO DATE
  0.12s DETAIL: load main: G.node_anchor_min
  0.20s DETAIL: load main: G.node_anchor_max
  0.25s DETAIL: load main: G.node_sort
  0.30s DETAIL: load main: G.node_sort_inv
  0.72s DETAIL: load main: G.edges_from
  0.79s DETAIL: load main: G.edges_to
  0.86s DETAIL: load main: F.etcbc4_db_otype [node] 
  1.53s DETAIL: load main: F.etcbc4_sft_book [node] 
  1.55s DETAIL: load main: F.etcbc4_ft_mother [e] 
  1.61s DETAIL: load main: C.etcbc4_ft_mother -> 
  1.77s DETAIL: load main: C.etcbc4_ft_mother <- 
  1.89s LOGFILE=/Users/dirk/laf-fabric-output/etcbc4/mother/__log__mother.txt
  1.90s INFO: DATA LOADED FROM SOURCE etcbc4 AND ANNOX -- FOR TASK mother AT 2014-07-15T12-29-36

In [3]:
F = API['F']
C = API['C']
NN = API['NN']
msg = API['msg']
infile = API['infile']
outfile = API['outfile']
my_file = API['my_file']

msg("Get the mothers...")

out = outfile("mothers.tsv")

bookname = None
found = 0
mother_kind = collections.defaultdict(lambda: collections.defaultdict(lambda: 0))

for i in NN():
    otype = F.otype.v(i)
    for mother in C.mother.v(i):
        found += 1
        motype = F.otype.v(mother)
        mother_kind[otype][motype] += 1
        out.write("{}\t{}\t{}\t{}\n".format(otype, i, motype, mother))
    if otype == "book":
        if bookname: sys.stderr.write("{} ({})\n".format(bookname, found))
        bookname = F.book.v(i)
sys.stderr.write("{} ({})\n".format(bookname, found))
sys.stderr.write("Total {}\n".format(found))
for source_type in sorted(mother_kind):
    for target_type in sorted(mother_kind[source_type]):
        print("{:<15} ==mother==> {:<15} : {:>10} x".format(source_type, target_type, mother_kind[source_type][target_type]))
API['close']()


    14s Get the mothers...
Genesis (11431)
Exodus (20608)
Leviticus (27191)
Numeri (37409)
Deuteronomium (45951)
Josua (52012)
Judices (57451)
Samuel_I (64537)
Samuel_II (70685)
Reges_I (78502)
Reges_II (85825)
Jesaia (95708)
Jeremia (108537)
Ezechiel (119305)
Hosea (120544)
Joel (121078)
Amos (122228)
Obadia (122383)
Jona (122751)
Micha (123561)
Nahum (123874)
Habakuk (124256)
Zephania (124707)
Haggai (125101)
Sacharia (127000)
Maleachi (127463)
Psalmi (139207)
Iob (143212)
Proverbia (147353)
Ruth (148057)
Canticum (148832)
Ecclesiastes (150671)
Threni (151489)
Esther (153381)
Daniel (156840)
Esra (159218)
Nehemia (162763)
Chronica_I (169177)
Chronica_II (176411)
Total 176411
    21s Results directory:
/Users/dirk/laf-fabric-output/etcbc4/mother

__log__mother.txt                       232 Tue Jul 15 14:29:57 2014
mothers.tsv                         6185197 Tue Jul 15 14:29:57 2014
clause          ==mother==> clause          :      12462 x
clause          ==mother==> phrase          :       5167 x
clause          ==mother==> word            :        951 x
clause_atom     ==mother==> clause_atom     :      89079 x
phrase          ==mother==> clause          :          5 x
phrase          ==mother==> phrase          :        195 x
phrase          ==mother==> word            :          7 x
phrase_atom     ==mother==> phrase_atom     :      11717 x
phrase_atom     ==mother==> word            :       1584 x
subphrase       ==mother==> subphrase       :      20556 x
subphrase       ==mother==> word            :      34688 x

In [ ]: