In [1]:
%load_ext autoreload
%autoreload 2
In [2]:
from tf.app import use

Cluster display in Old Babylonian

We show some details of the display logic by following an example: cluster nodes in the Old Babylonian corpus.

Clusters are difficult, because

  • they do not necessarily respect proper embedding
  • material can be part of several clusters

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.

In [3]:
A = use("oldbabylonian:clone", checkout="clone", hoist=globals())
TF-app: ~/github/annotation/app-oldbabylonian/code
data: ~/github/Nino-cunei/oldbabylonian/tf/1.0.6
Text-Fabric API: names N F E L T S C TF directly usable

In [4]:
A.reuse()
  0.29s All features loaded/computed - for details use loadLog()

An example line

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.

In [4]:
ln = F.otype.s("line")[0]
ln
Out[4]:
230788
In [5]:
F.srcLn.v(ln)
Out[5]:
'1. [a-na] _{d}suen_-i-[din-nam]'
In [6]:
T.text(ln)
Out[6]:
'[a-na] _{d}suen_-i-[din-nam]'
In [7]:
T.text(ln, fmt="text-orig-rich")
Out[7]:
'a-na dโผsuen-i-din-nam'
In [8]:
T.text(ln, fmt="text-orig-unicode")
Out[8]:
'๐’€€๐’ˆพ ๐’€ญ๐’‚—๐’ช๐’„ฟ๐’ท๐’‰†'

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:

In [9]:
A.plain(ln, fmt="text-orig-unicode")
P509373 obverse:1ย ย ๐’€€๐’ˆพ ๐’€ญ๐’‚—๐’ช๐’„ฟ๐’ท๐’‰†

even better, we translate the effect of clusters into layout:

In [10]:
A.plain(ln, fmt="layout-orig-unicode")
P509373 obverse:1ย ย ๐’€€๐’ˆพ ๐’€ญ๐’‚—๐’ช๐’„ฟ๐’ท๐’‰†

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]

The clusters

By means of the L API the clusters of this line can be found.

They are returned as a tuple of nodes.

In [11]:
cls = L.d(ln, otype="cluster")
cls
Out[11]:
(203220, 203221, 203222, 203223)

We'll give each cluster its own highlight color:

In [12]:
colors = """
    cyan
    yellow
    lightsalmon
    lightgreen
    goldenrod
    cornflowerblue
    forestgreen
    burlywood
    orange
    indianred
""".strip().split()

highlights = dict(zip(cls, colors))
highlights
Out[12]:
{203220: 'cyan', 203221: 'yellow', 203222: 'lightsalmon', 203223: 'lightgreen'}
In [13]:
A.plain(ln, highlights=highlights)
P509373 obverse:1ย ย [a-na] _{d}suen_-i-[din-nam]

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.

In [14]:
A.pretty(ln, highlights=highlights, baseTypes="sign")
line
word [a-na]
cluster
[a-
na]
word _{d}suen_-i-[din-nam]
cluster
cluster
_{d}
suen_-
i-
cluster
[din-
nam]

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

In [15]:
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)
In [16]:
example(0, withNodes=True)
230788
1. [a-na] _{d}suen_-i-[din-nam]
[a-na] _{d}suen_-i-[din-nam]
P509373 obverse:1ย ย ๐’€€๐’ˆพ ๐’€ญ๐’‚—๐’ช๐’„ฟ๐’ท๐’‰†
{203220: 'cyan', 203221: 'yellow', 203222: 'lightsalmon', 203223: 'lightgreen'}
P509373 obverse:1ย ย 230788203220[a-na] 203221203222_{d}suen_-i-203223[din-nam]
<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} 
line:230788
word:258163 [a-na]
cluster:203220
1 [a-
2 na]
word:258164 _{d}suen_-i-[din-nam]
cluster:203221
cluster:203222
3 _{d}
4 suen_-
5 i-
cluster:203223
6 [din-
7 nam]
line:230788
word:258163 203220[a-na]
word:258164 203221203222_{d}suen_-i-203223[din-nam]
In [17]:
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
P509373 reverse:6'ย ย x ๐’€€๐’Šฎ ๐’ข๐’‰๐’€‰ ๐’†ช๐’Œฆ๐’ช๐’ˆ
{203268: 'cyan', 203269: 'yellow'}
P509373 reverse:6'ย ย 230810x 203268203269_[a-sza3_ 258252203268s,i]-bi-it ku-un-zu-lum
<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} 
line:230810
word:258250 x
196 x
word:258251 _[a-sza3_
cluster:203268
cluster:203269
197 _[a-
198 sza3_
word:258252 s,i]-bi-it
cluster:203268
199 s,i]-
200 bi-
201 it
word:258253 ku-un-zu-lum
202 ku-
203 un-
204 zu-
205 lum
line:230810
word:258250 x
word:258251 203268203269_[a-sza3_
word:258252 203268s,i]-bi-it
word:258253 ku-un-zu-lum

More examples

We finish off with some more examples.

Something peculiar is going on. In order to talk about it, we add node numbers.

In [18]:
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?_]
P510623 obverse:6ย ย ๐’…–๐’Œ… ๐’Šญ๐’€œ๐’•๐’€๐’ฎ ๐’€€๐’ˆพ ๐’Šบ๐’†ฐ
{205585: 'cyan', 205586: 'yellow'}
P510623 obverse:6ย ย 233341isz-tu sza-ad-da-aq-dam# a-na 265903205585_sze#-205586[numun?_]
line:233341
word:265900 isz-tu
20479 isz-
20480 tu
word:265901 sza-ad-da-aq-dam#
20481 sza-
20482 ad-
20483 da-
20484 aq-
20485 dam#
word:265902 a-na
20486 a-
20487 na
word:265903 _sze#-[numun?_]
cluster:205585
20488 _sze#-
cluster:205586
20489 [numun?_]
line:233341
word:265900 isz-tu
word:265901 sza-ad-da-aq-dam#
word:265902 a-na
word:265903 205585_sze#-205586[numun?_]

More cases

In [19]:
results = (
    (258201, 112),
    (258404, 591),
)
In [20]:
n = results[0][0]
A.pretty(n, highlights=set(results[0]), baseTypes="sign", withNodes=True, explain=False)
word:258201 7(disz)
cluster:203253
112 7(disz)
In [21]:
n = results[1][0]
A.pretty(n, highlights=set(results[1]), baseTypes="sign", withNodes=True, explain=False)
word:258404 4(disz)-kam_
cluster:203324
591 4(disz)-
592 kam_
In [22]:
w = 260817
A.pretty(w, baseTypes="sign", explain=False)
word _szunigin
cluster
_szunigin
In [23]:
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
In [24]:
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",
    },
)
P510556 reverse:8ย ย _szunigin 6(gesz2) 2(u) 1(asz) 5(ban2) sze gur {gesz}ban2#_ [{gesz}me]-sze#-qum
line
word _szunigin
cluster
_szunigin
word 6(gesz2)
cluster
6(gesz2)
word 2(u)
cluster
2(u)
word 1(asz)
cluster
1(asz)
word 5(ban2)
cluster
5(ban2)
word sze
cluster
sze
word gur
cluster
gur
word {gesz}ban2#_
cluster
cluster
{gesz}
ban2#_
word [{gesz}me]-sze#-qum
cluster
cluster
[{gesz}
me]-
sze#-
qum
In [25]:
A.pretty(ln)
line
word _szunigin
word 6(gesz2)
word 2(u)
word 1(asz)
word 5(ban2)
word sze
word gur
word {gesz}ban2#_
word [{gesz}me]-sze#-qum

Developer's cells

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().

In [ ]:
A.reuse()
In [26]:
A.showContext()

oldbabylonian app context

1. afterChild

{}

</details>

2. allowedValues

  • 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

</details>

3. apiVersion

None

</details>

4. appName

oldbabylonian

</details>

5. appPath

~/github/annotation/app-oldbabylonian/code

</details>

6. baseTypes

  1. word

</details>

7. bigTypes

set()

</details>

8. browseContentPretty

False

</details>

9. browseNavLevel

2

</details>

10. charText

mapping from readings to UNICODE

</details>

11. charUrl

https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/programs/mapReadings.ipynb

</details>

12. childType

  • cluster:
    • sign
  • document:
    • face
  • face:
    • line
  • line:
    • word
  • word:
    • cluster

</details>

13. commit

None

</details>

14. condenseType

line

</details>

15. corpus

Old Babylonian Letters 1900-1600: Cuneiform tablets

</details>

16. css

.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;
}

</details>

17. dataDisplay

  • 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

</details>

18. defaultClsOrig

txtu akk

</details>

19. descendantType

  • 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

</details>

20. direction

ltr

</details>

21. docBase

https://github.com/Nino-cunei/oldbabylonian/blob/master/docs

</details>

22. docExt

.md

</details>

23. docPage

about

</details>

24. docRoot

https://github.com

</details>

25. docUrl

https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/about.md

</details>

26. docs

  • 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: empty

</details>

27. doi

10.5281/zenodo.2579207

</details>

28. exampleSection

P509373 obverse:1

</details>

29. exampleSectionHtml

<code>P509373 obverse:1</code>

</details>

30. excludedFeatures

set()

</details>

31. exclusions

{}

</details>

32. extension

akk

</details>

33. featureBase

https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/transcription.md

</details>

34. featurePage

empty

</details>

35. features

  • 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:
    • []
    • {}

</details>

36. featuresBare

  • cluster:
    • []
    • {}
  • document:
      • collection
      • volume
      • docnumber
      • docnote
    • {}
  • face:
      • object
    • {}
  • line:
    • []
    • {}
  • sign:
    • []
    • {}
  • word:
    • []
    • {}

</details>

37. formatCls

  • 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

</details>

38. formatHtml

  1. layout-orig-rich
  2. layout-orig-unicode

</details>

39. formatMethod

  • layout-orig-rich: layoutRich
  • layout-orig-unicode: layoutUnicode

</details>

40. formatStyle

  • normal: txtn
  • orig: txtu akk
  • phono: txtp
  • source: txto
  • trans: txtt

</details>

41. graphicsRelative

None

</details>

42. hasGraphics

set()

</details>

43. hiddenTypes

set()

</details>

44. interfaceDefaults

  • condensed: False
  • hideTypes: True
  • lineNumbers: False
  • plainGaps: True
  • prettyTypes: True
  • queryFeatures: True
  • showGraphics: None
  • standardFeatures: False
  • withNodes: False
  • withTypes: False

</details>

45. isCompatible

True

</details>

46. labels

  • cluster:
    • {type}
      • type
  • document:
    • True
    • ()
  • face:
    • True
    • ()
  • line:
    • empty
    • ()
  • sign:
    • True
    • ()
  • word:
    • True
    • ()

</details>

47. language

akkadian

</details>

48. levelCls

  • 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: empty
    • container: contnr c0
    • label: lbl c0
  • word:
    • children: children hor
    • container: contnr c2
    • label: lbl c2

</details>

49. levels

  • cluster:
    • flow: hor
    • level: 1
    • stretch: False
    • wrap: 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: 0
    • stretch: False
    • wrap: False
  • word:
    • flow: hor
    • level: 2
    • stretch: True
    • wrap: False

</details>

50. lexMap

{}

</details>

51. lexTypes

set()

</details>

52. lineNumberFeature

  • document: srcLnNum
  • face: srcLnNum
  • line: srcLnNum

</details>

53. local

clone

</details>

54. localDir

~/github/Nino-cunei/oldbabylonian/_temp

</details>

55. moduleSpecs

()

</details>

56. noDescendTypes

set()

</details>

57. noneValues

  1. None

</details>

58. org

Nino-cunei

</details>

59. plainCustom

{}

</details>

60. prettyCustom

{}

</details>

61. provenanceSpec

  • corpus: Old Babylonian Letters 1900-1600: Cuneiform tablets
  • doi: 10.5281/zenodo.2579207
  • graphicsRelative: None
  • moduleSpecs: ()
  • org: Nino-cunei
  • relative: tf
  • repo: oldbabylonian
  • version: 1.0.5
  • webBase: https://cdli.ucla.edu
  • webHint: Show this document on CDLI
  • webLang: None
  • webLexId: None
  • webUrl: https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&ObjectID=<1>
  • webUrlLex: None
  • zip: None

</details>

62. relative

tf

</details>

63. release

None

</details>

64. repo

oldbabylonian

</details>

65. sectionSep1

</details>

66. sectionSep2

:

</details>

67. showVerseInTuple

True

</details>

68. styles

{}

</details>

69. templates

  • cluster:
    • empty
    • ()
  • document:
    • True
    • ()
  • face:
    • True
    • ()
  • line:
    • empty
    • ()
  • sign:
    • True
    • ()
  • word:
    • empty
    • ()

</details>

70. textFormat

text-orig-full

</details>

71. tfDoc

https://annotation.github.io/text-fabric

</details>

72. transform

{}

</details>

73. typeDisplay

  • cluster:
    • label: {type}
    • stretch: False
  • document:
    • 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: False

</details>

74. urlGh

https://github.com

</details>

75. urlNb

https://nbviewer.jupyter.org/github

</details>

76. verseTypes

  1. line

</details>

77. version

1.0.5

</details>

78. webBase

https://cdli.ucla.edu

</details>

79. webHint

Show this document on CDLI

</details>

80. webLang

None

</details>

81. webLexId

None

</details>

82. webUrl

https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&ObjectID=<1>

</details>

83. webUrlLex

None

</details>

84. writing

akk

</details>

85. zip

  1. oldbabylonian

</details> </details>