{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Explore edges."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from tf.app import use"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"TF-app: ~/github/annotation/app-bhsa/code"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"data: ~/text-fabric-data/etcbc/bhsa/tf/c"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"data: ~/text-fabric-data/etcbc/phono/tf/c"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"data: ~/text-fabric-data/etcbc/parallels/tf/c"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Text-Fabric: Text-Fabric API 8.3.0, app-bhsa, Search Reference
Data: BHSA, Character table, Feature docs
Features:
Parallel Passages
crossref
BHSA = Biblia Hebraica Stuttgartensia Amstelodamensis
book
book@ll
chapter
code
det
domain
freq_lex
function
g_cons
g_cons_utf8
g_lex
g_lex_utf8
g_word
g_word_utf8
gloss
gn
label
language
lex
lex_utf8
ls
nametype
nme
nu
number
otype
pargr
pdp
pfm
prs
prs_gn
prs_nu
prs_ps
ps
qere
qere_trailer
qere_trailer_utf8
qere_utf8
rank_lex
rela
sp
st
tab
trailer
trailer_utf8
txt
typ
uvf
vbe
vbs
verse
voc_lex
voc_lex_utf8
vs
vt
mother
oslots
Phonetic Transcriptions
phono
phono_trailer
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A = use(\"ETCBC/bhsa:clone\", hoist=globals())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First determine the from-types and the to-types of nodes connected by a mother edge:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"From types: ['clause', 'clause_atom', 'phrase', 'phrase_atom', 'subphrase']\n",
"To types: ['clause', 'clause_atom', 'phrase', 'phrase_atom', 'subphrase', 'word']\n"
]
}
],
"source": [
"fromTypes = set()\n",
"toTypes = set()\n",
"\n",
"for f in N.walk():\n",
" ts = E.mother.f(f)\n",
" if ts:\n",
" fromTypes.add(F.otype.v(f))\n",
" for t in ts:\n",
" toTypes.add(F.otype.v(t))\n",
"\n",
"print(f\"From types: {sorted(fromTypes)}\")\n",
"print(f\"To types: {sorted(toTypes)}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now list how many edges there are between all these types:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" clause =mother( 13897x)=> clause\n",
" clause =mother( 13897x)=> clause_atom\n",
" clause =mother( 5305x)=> phrase\n",
" clause =mother( 5305x)=> phrase_atom\n",
" clause =mother( 5305x)=> subphrase\n",
" clause =mother( 1567x)=> word\n",
" clause_atom =mother( 13897x)=> clause\n",
" clause_atom =mother(103496x)=> clause_atom\n",
" clause_atom =mother( 5305x)=> phrase\n",
" clause_atom =mother( 5305x)=> phrase_atom\n",
" clause_atom =mother( 5305x)=> subphrase\n",
" clause_atom =mother( 1567x)=> word\n",
" phrase =mother( 51x)=> clause\n",
" phrase =mother( 51x)=> clause_atom\n",
" phrase =mother( 507x)=> phrase\n",
" phrase =mother( 507x)=> phrase_atom\n",
" phrase =mother( 507x)=> subphrase\n",
" phrase =mother( 8x)=> word\n",
" phrase_atom =mother( 51x)=> clause\n",
" phrase_atom =mother( 51x)=> clause_atom\n",
" phrase_atom =mother( 507x)=> phrase\n",
" phrase_atom =mother( 13007x)=> phrase_atom\n",
" phrase_atom =mother( 507x)=> subphrase\n",
" phrase_atom =mother( 1842x)=> word\n",
" subphrase =mother( 51x)=> clause\n",
" subphrase =mother( 51x)=> clause_atom\n",
" subphrase =mother( 507x)=> phrase\n",
" subphrase =mother( 507x)=> phrase_atom\n",
" subphrase =mother( 22453x)=> subphrase\n",
" subphrase =mother( 34968x)=> word\n"
]
}
],
"source": [
"for fT in sorted(fromTypes):\n",
" for tT in sorted(toTypes):\n",
" n = E.mother.freqList(nodeTypesFrom=fT, nodeTypesTo=tT)\n",
" if n:\n",
" print(f\"{fT:>20} =mother({n:>6}x)=> {tT}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}