#!/usr/bin/env python # coding: utf-8 # In[1]: get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') # In[2]: from tf.app import use from fixture import typeShow # # BHSA specifics # In[3]: A = use("bhsa:clone", checkout="clone", hoist=globals()) # In[ ]: A.reuse() # In[4]: A.showContext() # # A slot with standard features # In[5]: A.displayShow("standardFeatures") # In[6]: w = 2 p = L.u(w, otype="phrase")[0] # In[24]: tree = A.unravel(w, explain=True) # In[25]: tree = A.unravel(p, explain=True) # In[26]: A.pretty(w, standardFeatures=True) A.pretty(p, standardFeatures=True) # # Base types # In[27]: p = 675477 highlights = {p} A.pretty(p, highlights=highlights) A.pretty(p, highlights=highlights, baseTypes="phrase") # # A tricky verse # In[28]: v = T.nodeFromSection(("Genesis", 7, 14)) v # In[29]: A.plain(v, explain=False) # Halfverses are hidden. This verse is divided (at top level) in 3 spans: one for each clause chunk. The first and last chunks # belong to clause 1, and the middle chunk is clause 2. # # Look what happens if we set `hideTypes=True`: # In[30]: A.plain(v, hideTypes=False, explain=False) # When you make the browser window narrower, the line breaks are different. # Because now the verse is divided in 2 spans: one for each half verse, and the separation between # the half verses is within the third clause chunk. # # See it in pretty view: # In[31]: A.pretty(v, explain=False) # We can selectively unhide the half verse and leave everything else hidden: # In[32]: A.pretty( v, hideTypes=True, hiddenTypes="subphrase phrase_atom clause_atom sentence_atom", explain=False, ) # This shows the reason of the split. # # We can also print the full structure (although that's a bit over the top): # In[33]: A.pretty(v, hideTypes=False) # # Alignment in tables # In[34]: A.table( ((2, 213294, 426583), (3, 213295, 426582), (4, 213296, 426581)), withPassage={1, 2} ) # # Subphrases # # Subphrases with equal slots: # In[35]: w = 3461 sps = L.u(w, otype="subphrase") for sp in sps[0:-1]: print(E.oslots.s(sp)) A.pretty(sp, standardFeatures=True, extraFeatures="rela", withNodes=True) # # Sentence spanning two verses # In[36]: A.pretty(v, withNodes=True, explain=False) # # Base types # In[37]: cl = 427612 words = L.d(cl, otype="word") phrases = L.d(cl, otype="phrase") highlights = {phrases[1]: "lightsalmon", words[2]: "lightblue"} A.pretty(cl, baseTypes="phrase", withNodes=True, highlights=highlights, explain=True) # # Gaps # In[38]: c = 427931 s = L.u(c, otype="sentence")[0] v = L.u(c, otype="verse")[0] highlights = {c: "khaki", c + 1: "lightblue"} # In[39]: A.webLink(s) # In[40]: A.plain(s, withNodes=True, highlights=highlights) # In[41]: A.plain(s) # In[42]: T.formats # In[43]: A.plain(c, fmt="text-phono-full", withNodes=True, explain=False) # In[44]: A.plain(c, withNodes=False, explain=False) # In[45]: A.pretty(c, withNodes=True, explain=False) # In[46]: A.pretty(c, withNodes=True, hideTypes=False, explain=False) # In[47]: A.pretty(s, withNodes=True, highlights=highlights, explain=False) # In[48]: A.plain(s, withNodes=True, hideTypes=False) # In[49]: A.pretty(s, withNodes=True, highlights=highlights, hideTypes=False, explain=False) # In[50]: A.plain(427931) A.pretty(427931, withNodes=True) A.plain(427932) A.pretty(427932) # In[51]: sp = F.otype.s("subphrase")[0] v = L.u(sp, otype="verse")[0] # In[52]: A.pretty(v) # In[53]: p = 653380 s = L.u(p, otype="sentence")[0] c = L.d(s, otype="clause")[0] # In[54]: A.plain(p) # In[55]: A.pretty(p) # In[56]: A.pretty(p, baseTypes="phrase_atom", hideTypes=True) # In[57]: A.pretty(p, baseTypes="phrase") # In[58]: A.plain(s) # In[59]: A.plain(s, plainGaps=False) # In[60]: A.plain(c, withNodes=True) # In[61]: A.pretty(c) # In[62]: A.pretty(s, baseTypes={"subphrase", "word"}) # In[63]: A.pretty(s, baseTypes="phrase") # In[64]: A.prettyTuple((p,), 1, baseTypes="phrase") # In[65]: A.pretty(p, baseTypes="phrase") # # Atom types # In[66]: p = F.otype.s("phrase")[0] pa = F.otype.s("phrase_atom")[0] # # Plain # In[67]: A.plain(p, highlights={p, pa}) A.plain(p, highlights={p, pa}, hideTypes=False) # In[68]: A.plain(p, highlights={p}) A.plain(p, highlights={p}, hideTypes=False) # In[69]: A.plain(p, highlights={pa}) A.plain(p, highlights={pa}, hideTypes=False) # In[70]: A.plain(pa, highlights={p, pa}) A.plain(pa, highlights={p, pa}, hideTypes=False) # In[71]: A.plain(pa, highlights={pa}) A.plain(pa, highlights={pa}, hideTypes=False) # In[72]: A.plain(pa, highlights={p}) A.plain(pa, highlights={p}, hideTypes=False) # # Pretty # In[73]: A.pretty(p, highlights={p, pa}) A.pretty(p, highlights={p, pa}, hideTypes=False) # In[74]: A.pretty(p, highlights={p}) A.pretty(p, highlights={p}, hideTypes=False) # In[75]: A.pretty(p, highlights={pa}) A.pretty(p, highlights={pa}, hideTypes=False) # In[76]: A.pretty(pa, highlights={p, pa}) A.pretty(pa, highlights={p, pa}, hideTypes=False) # In[77]: A.pretty(pa, highlights={pa}) A.pretty(pa, highlights={pa}, hideTypes=False) # In[78]: A.pretty(pa, highlights={p}) A.pretty(pa, highlights={p}, hideTypes=False) # # Highlights # In[79]: cl = 435509 ph = 675481 w = 38625 highlights = {ph, w} # In[80]: A.pretty(cl, highlights=highlights, withNodes=True) # In[81]: A.pretty(cl, highlights=highlights, baseTypes={"phrase"}, withNodes=True) # In[82]: A.plain(ph, highlights=highlights) # In[83]: A.plain(ph, highlights=highlights, baseTypes={"phrase"}, withNodes=True) # In[84]: typeShow(A)