%load_ext autoreload
%autoreload 2
from tf.app import use
We show some details of the display logic by following an example: cluster nodes in the Old Babylonian corpus.
Clusters are difficult, because
We show how we deal with the second part and prevent multiple display of members of multiple clusters. As an illustration, we'll show the effect of an earlier bug and indicate the fix.
We start with loading the corpus.
A = use("oldbabylonian:clone", checkout="clone", hoist=globals())
A.reuse()
0.29s All features loaded/computed - for details use loadLog()
Here is a line with some nested clusters. In fact, it is the first line of the corpus.
The node number is stored in the variable ln
.
We show the raw ATF source of the line, and the text according to several text formats.
ln = F.otype.s("line")[0]
ln
230788
F.srcLn.v(ln)
'1. [a-na] _{d}suen_-i-[din-nam]'
T.text(ln)
'[a-na] _{d}suen_-i-[din-nam]'
T.text(ln, fmt="text-orig-rich")
'a-na d⁼suen-i-din-nam'
T.text(ln, fmt="text-orig-unicode")
'𒀀𒈾 𒀭𒂗𒍪𒄿𒁷𒉆'
N.B: These are the right unicodes but not the right signs, we need another font for that.
We can get the right signs by using plain
:
A.plain(ln, fmt="text-orig-unicode")
even better, we translate the effect of clusters into layout:
A.plain(ln, fmt="layout-orig-unicode")
Click on the passage link in order to go to the page for this tablet on CDLI, where you can read off the exact source:
1. [a-na] _{d}suen_-i-[din-nam]
cls = L.d(ln, otype="cluster")
cls
(203220, 203221, 203222, 203223)
We'll give each cluster its own highlight color:
colors = """
cyan
yellow
lightsalmon
lightgreen
goldenrod
cornflowerblue
forestgreen
burlywood
orange
indianred
""".strip().split()
highlights = dict(zip(cls, colors))
highlights
{203220: 'cyan', 203221: 'yellow', 203222: 'lightsalmon', 203223: 'lightgreen'}
A.plain(ln, highlights=highlights)
In this corpus, pretty
displays unfold until the word level, by default.
But first we want it to unfold to the very end, to the sign level.
A.pretty(ln, highlights=highlights, baseTypes="sign")
Let's see some more examples.
We have written a function to quickly execute examples.
The first example is the index of the line in the list of all lines produces by F.otype.s('line')
.
def example(nLine, extraHighlights={}, **options):
ln = F.otype.s("line")[nLine]
print(ln)
print(F.srcLn.v(ln))
print(T.text(ln))
A.plain(ln, fmt="layout-orig-unicode")
cls = L.d(ln, otype="cluster")
highlights = dict(zip(cls, colors[0 : len(cls)]))
print(highlights)
A.plain(ln, highlights={**highlights, **extraHighlights}, **options)
A.pretty(
ln,
highlights={**highlights, **extraHighlights},
baseTypes="sign",
**options,
explain=True
)
A.pretty(ln, highlights={**highlights, **extraHighlights}, **options)
example(0, withNodes=True)
230788 1. [a-na] _{d}suen_-i-[din-nam] [a-na] _{d}suen_-i-[din-nam]
{203220: 'cyan', 203221: 'yellow', 203222: 'lightsalmon', 203223: 'lightgreen'}
<0> TOP <1> line 230788 {1-7} <2> word 258163 {1-2} <3> cluster 203220 {1-2} <4> sign 1 {1} <4> sign 2 {2} <2> word 258164 {3-7} <3> cluster 203221 {3-4} <4> cluster 203222 {3} <5> sign 3 {3} <4> sign 4 {4} <3> sign 5 {5} <3> cluster 203223 {6-7} <4> sign 6 {6} <4> sign 7 {7}
example(22, withNodes=True, extraHighlights={258252: "lightsalmon"})
230810 6'. x _[a-sza3_ s,i]-bi-it ku-un-zu-lum x _[a-sza3_ s,i]-bi-it ku-un-zu-lum
{203268: 'cyan', 203269: 'yellow'}
<0> TOP <1> line 230810 {196-205} <2> word 258250 {196} <3> sign 196 {196} <2> word 258251 {197-198} <3> cluster 203268 {197-198} rno <4> cluster 203269 {197-198} <5> sign 197 {197} <5> sign 198 {198} <2> word 258252 {199-201} <3> cluster 203268 {199} lno <4> sign 199 {199} <3> sign 200 {200} <3> sign 201 {201} <2> word 258253 {202-205} <3> sign 202 {202} <3> sign 203 {203} <3> sign 204 {204} <3> sign 205 {205}
We finish off with some more examples.
Something peculiar is going on. In order to talk about it, we add node numbers.
example(2553, withNodes=True, extraHighlights={265903: "lightsalmon"})
233341 6. isz-tu sza-ad-da-aq-dam# a-na _sze#-[numun?_] isz-tu sza-ad-da-aq-dam# a-na _sze#-[numun?_]
{205585: 'cyan', 205586: 'yellow'}
results = (
(258201, 112),
(258404, 591),
)
n = results[0][0]
A.pretty(n, highlights=set(results[0]), baseTypes="sign", withNodes=True, explain=False)
n = results[1][0]
A.pretty(n, highlights=set(results[1]), baseTypes="sign", withNodes=True, explain=False)
w = 260817
A.pretty(w, baseTypes="sign", explain=False)
ln = 231650
print(T.text(ln))
print(F.srcLn.v(ln))
_szunigin 6(gesz2) 2(u) 1(asz) 5(ban2) sze gur {gesz}ban2#_ [{gesz}me]-sze#-qum 8. _szunigin 6(gesz2) 2(u) 1(asz) 5(ban2) sze gur {gesz}ban2#_ [{gesz}me]-sze#-qum
A.plain(
ln,
withNodes=False,
baseTypes="sign",
explain=False,
highlights={
204104: "lightsalmon",
204105: "yellow",
204106: "lightgreen",
204107: "lightblue",
},
)
A.pretty(
ln,
withNodes=False,
baseTypes="sign",
explain=False,
highlights={
204104: "lightsalmon",
204105: "yellow",
204106: "lightgreen",
204107: "lightblue",
},
)
A.pretty(ln)
Use A.reuse()
if you have changed the config.yaml
of this corpus and want to reapply the settings.
Inspect the result of the new settings by means of A.showContext()
.
A.reuse()
A.showContext()
{}
baseTypes
:word
cluster
sign
condenseType
:document
face
line
word
cluster
hiddenTypes
:word
cluster
textFormat
:layout-orig-rich
: sign
layout-orig-unicode
: sign
text-orig-full
: sign
text-orig-plain
: sign
text-orig-rich
: sign
text-orig-unicode
: sign
None
oldbabylonian
~/github/annotation/app-oldbabylonian/code
word
set()
False
2
mapping from readings to UNICODE
https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/programs/mapReadings.ipynb
cluster
:sign
document
:face
face
:line
line
:word
word
:cluster
None
line
Old Babylonian Letters 1900-1600: Cuneiform tablets
.pnum {
font-family: sans-serif;
font-size: small;
font-weight: bold;
color: #444444;
}
.op {
padding: 0.5em 0.1em 0.1em 0.1em;
margin: 0.8em 0.1em 0.1em 0.1em;
font-family: monospace;
font-size: x-large;
font-weight: bold;
}
.period {
font-family: monospace;
font-size: medium;
font-weight: bold;
color: #0000bb;
}
.comment {
color: #7777dd;
font-family: monospace;
font-size: small;
}
.operator {
color: #ff77ff;
font-size: large;
}
/* LANGUAGE: superscript and subscript */
/* cluster */
.det {
vertical-align: super;
}
/* cluster */
.langalt {
vertical-align: sub;
}
/* REDACTIONAL: line over or under */
/* flag */
.collated {
font-weight: bold;
text-decoration: underline;
}
/* cluster */
.excised {
color: #dd0000;
text-decoration: line-through;
}
/* cluster */
.supplied {
color: #0000ff;
text-decoration: overline;
}
/* flag */
.remarkable {
font-weight: bold;
text-decoration: overline;
}
/* UNSURE: italic*/
/* cluster */
.uncertain {
font-style: italic
}
/* flag */
.question {
font-weight: bold;
font-style: italic
}
/* BROKEN: text-shadow */
/* cluster */
.missing {
color: #999999;
text-shadow: #bbbbbb 1px 1px;
}
/* flag */
.damage {
font-weight: bold;
color: #999999;
text-shadow: #bbbbbb 1px 1px;
}
.empty {
color: #ff0000;
}
showVerseInTuple
: True
textFormats
:layout-orig-rich
:method
: layoutRich
style
: trans
layout-orig-unicode
:method
: layoutUnicode
style
: orig
text-orig-full
:style
: source
text-orig-plain
:style
: trans
text-orig-rich
:style
: trans
text-orig-unicode
:style
: orig
txtu akk
cluster
:cluster
sign
document
:cluster
document
face
line
sign
word
face
:cluster
face
line
sign
word
line
:cluster
line
sign
word
word
:cluster
sign
word
ltr
https://github.com/Nino-cunei/oldbabylonian/blob/master/docs
.md
about
https://github.com
https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/about.md
charText
: mapping from readings to UNICODE
charUrl
: https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/programs/mapReadings.ipynb
docBase
: https://github.com/Nino-cunei/oldbabylonian/blob/master/docs
docExt
: .md
docPage
: about
docRoot
: https://github.com
docUrl
: https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/about.md
featureBase
: https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/transcription.md
featurePage
: empty10.5281/zenodo.2579207
P509373 obverse:1
<code>P509373 obverse:1</code>
set()
{}
akk
https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/transcription.md
empty
cluster
:document
:face
:line
:remarks
translation@en
sign
:collated
remarkable
question
damage
det
uncertain
missing
excised
supplied
langalt
comment
remarks
repeat
fraction
operator
grapheme
word
:cluster
:document
:collection
volume
docnumber
docnote
face
:object
line
:sign
:word
:layout-orig-rich
: txtt
layout-orig-unicode
: txtu akk
text-orig-full
: txto
text-orig-plain
: txtt
text-orig-rich
: txtt
text-orig-unicode
: txtu akk
layout-orig-rich
layout-orig-unicode
layout-orig-rich
: layoutRich
layout-orig-unicode
: layoutUnicode
normal
: txtn
orig
: txtu akk
phono
: txtp
source
: txto
trans
: txtt
None
set()
set()
condensed
: FalsehideTypes
: True
lineNumbers
: FalseplainGaps
: True
prettyTypes
: True
queryFeatures
: True
showGraphics
: NonestandardFeatures
: FalsewithNodes
: FalsewithTypes
: FalseTrue
cluster
:{type}
type
document
:True
face
:True
line
:sign
:True
word
:True
akkadian
cluster
:children
: children hor wrap
container
: contnr c1
label
: lbl c1
document
:children
: children hor wrap
container
: contnr c4
label
: lbl c4
face
:children
: children hor wrap
container
: contnr c4
label
: lbl c4
line
:children
: children hor wrap
container
: contnr c3
label
: lbl c3
sign
:children
: emptycontainer
: contnr c0
label
: lbl c0
word
:children
: children hor
container
: contnr c2
label
: lbl c2
cluster
:flow
: hor
level
: 1
stretch
: Falsewrap
: True
document
:flow
: hor
level
: 4
stretch
: True
wrap
: True
face
:flow
: hor
level
: 4
stretch
: True
wrap
: True
line
:flow
: hor
level
: 3
stretch
: True
wrap
: True
sign
:flow
: ver
level
: 0stretch
: Falsewrap
: Falseword
:flow
: hor
level
: 2
stretch
: True
wrap
: False{}
set()
document
: srcLnNum
face
: srcLnNum
line
: srcLnNum
clone
~/github/Nino-cunei/oldbabylonian/_temp
()
set()
Nino-cunei
{}
{}
corpus
: Old Babylonian Letters 1900-1600: Cuneiform tablets
doi
: 10.5281/zenodo.2579207
graphicsRelative
: NonemoduleSpecs
: ()org
: Nino-cunei
relative
: tf
repo
: oldbabylonian
version
: 1.0.5
webBase
: https://cdli.ucla.edu
webHint
: Show this document on CDLI
webLang
: NonewebLexId
: NonewebUrl
: https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&ObjectID=<1>
webUrlLex
: Nonezip
: Nonetf
None
oldbabylonian
:
True
{}
cluster
:document
:True
face
:True
line
:sign
:True
word
:text-orig-full
https://annotation.github.io/text-fabric
{}
cluster
:label
: {type}
stretch
: Falsedocument
:featuresBare
: collection volume docnumber docnote
lineNumber
: srcLnNum
face
:featuresBare
: object
lineNumber
: srcLnNum
line
:features
: remarks translation@en
lineNumber
: srcLnNum
sign
:features
: collated remarkable question damage det uncertain missing excised supplied langalt comment remarks repeat fraction operator grapheme
word
:base
: True
label
: True
wrap
: Falsehttps://github.com
https://nbviewer.jupyter.org/github
line
1.0.5
https://cdli.ucla.edu
Show this document on CDLI
None
None
https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&ObjectID=<1>
None
akk
oldbabylonian