"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# The following will push the Text-Fabric stylesheet to this notebook (to facilitate proper display with notebook viewer)\n",
"N1904.dh(N1904.getCss())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "03caad3d-8c64-4b7b-b8d5-8ad99e5e7a6a",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Set default view in a way to limit noise as much as possible.\n",
"N1904.displaySetup(condensed=True, multiFeatures=False,queryFeatures=False)"
]
},
{
"cell_type": "markdown",
"id": "a29a3dc3-f727-458d-b90b-bee8e4545859",
"metadata": {},
"source": [
"# 3 - Performing the queries "
]
},
{
"cell_type": "markdown",
"id": "5b98ec15-fdbe-4b7f-a5fe-8364d26dcb7e",
"metadata": {
"tags": []
},
"source": [
"## 3.1 - Show a specific verse\n",
"##### [Back to TOC](#TOC)\n",
"\n",
"The following example will query for a specific verte (i.e. Matthew 1:8). As expected, the query yealds one result."
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "7a6b5c40-7a4f-4a8e-bc8c-363c9691c40e",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Define the query template\n",
"VerseQuery = '''\n",
"book book=Mark\n",
" chapter chapter=1\n",
" verse verse=1\n",
"'''"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "334f8f6d-5006-4779-8ec5-5428092dc679",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.01s 1 result\n"
]
}
],
"source": [
"# The following will create a list containing ordered tuples consisting of node numbers of the items as they appear in the query\n",
"VerseResult = N1904.search(VerseQuery)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "ed34eb3a-c748-4fde-8e01-3a9f840569a8",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"verse 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Mark 1:1
sentence #1 (start: Mark 1:1)
wg #2: cl Verbless P2CL
wg #3: np p NPofNP
wg #4: np DetNP
wg #5: np NPofNP
wg #6: apposition np Np-Appos
wg #7: apposition np Np-Appos
wg #8: np NPofNP apposition
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Print some of the results\n",
"# Note the options \"condensed=True, multiFeatures=False,queryFeatures=False\" are included below due to the earlier N1904.displaySetup(...)\n",
"N1904.show(VerseResult, start=1, end=2)"
]
},
{
"cell_type": "markdown",
"id": "434ae56a-d68e-49b2-af5a-b22346688775",
"metadata": {},
"source": [
"## 3.2 - Selecting individual words of the verse \n",
"##### [Back to TOC](#TOC)"
]
},
{
"cell_type": "markdown",
"id": "650d23c8-62c1-4954-b6e4-4af5e913ba51",
"metadata": {},
"source": [
"A similar (but still different) result can be obtained by selecting all words from the verse individualy. Since counting each word as separate result, the total figure for results is higher (in this case 15). Also note that the found items (i.e. individual words) are coloured yellow. The argument `\"condensed=True\"` combines all found items, limiting the display to just one instance of the verse (since all results are from the same verse). Would the argument `\"condensed=False\"` be suplied, the same verse would be printed 15 times, each time with the next consequent word coloured in yellow."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "7bfc5821-a5a6-43da-a022-6c1a7a2ca6e3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.09s 7 results\n"
]
},
{
"data": {
"text/html": [
"verse 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse:147146 Mark 1:1
sentence:139200 #1 (start: Mark 1:1)
wg:168001 #2: cl Verbless P2CL
wg:168002 #3: np p NPofNP
wg:168003 #4: np DetNP
wg:168004 #5: np NPofNP
wg:168005 #6: apposition np Np-Appos
wg:168006 #7: apposition np Np-Appos
wg:168007 #8: np NPofNP apposition
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Define the query template\n",
"AltVerseQuery = '''\n",
"word book=Mark chapter=1 verse=1\n",
"'''\n",
"\n",
"# The following will create a list containing ordered tuples consisting of node numbers of the items as they appear in the query\n",
"AltVerseResult = N1904.search(AltVerseQuery)\n",
"\n",
"# Print some of the results\n",
"N1904.show(AltVerseResult, start=1, end=15, condensed=True, multiFeatures=False, withNodes=True)"
]
},
{
"cell_type": "markdown",
"id": "a5583155-be42-4577-a88d-788c24a0b8d9",
"metadata": {},
"source": [
"## 3.3 - Available output formats \n",
"##### [Back to TOC](#TOC)\n",
"\n",
"To check the available formats to display the text:"
]
},
{
"cell_type": "markdown",
"id": "40368900-b40a-4a39-9882-964ef52b0433",
"metadata": {},
"source": [
"The same result (although formatted different) can be obtained by the following call:"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "67344b12-6a53-447d-89c8-19cc62ad498c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'text-critical': 'word',\n",
" 'text-normalized': 'word',\n",
" 'text-orig-full': 'word',\n",
" 'text-transliterated': 'word',\n",
" 'text-unaccented': 'word'}"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T.formats"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "b963ca04-3c61-45e1-943b-6649885218b2",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"format | level | template\n",
"--- | --- | ---\n",
"`text-critical` | **word** | `{unicode} `\n",
"`text-normalized` | **word** | `{normalized}{after}`\n",
"`text-orig-full` | **word** | `{word}{after}`\n",
"`text-transliterated` | **word** | `{wordtranslit}{after}`\n",
"`text-unaccented` | **word** | `{wordunacc}{after}`\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"N1904.showFormats()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "fed33b4e-2af3-49a7-839b-6b6f8a0e2504",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ Χριστοῦ (Υἱοῦ Θεοῦ). '"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T.text(139200,fmt='text-critical')"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "da796693-2acc-41d2-9196-03ab4cce86a7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Ἀρχή τοῦ εὐαγγελίου Ἰησοῦ Χριστοῦ Υἱοῦ Θεοῦ. '"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T.text(139200,fmt='text-normalized')"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "302e77f6-7483-4b74-a4c9-829b332ed303",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ Χριστοῦ Υἱοῦ Θεοῦ. '"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T.text(139200,fmt='text-orig-full')"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "b871acc4-4230-4a7c-b1e0-6059c4aafa1b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Αρχη του ευαγγελιου Ιησου Χριστου Υιου Θεου. '"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T.text(139200,fmt='text-unaccented')"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "6482c844-1a29-43ee-be5b-c27e25a657d3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Arkhe tou euaggeliou Iesou Khristou Uiou Theou. '"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T.text(139200,fmt='text-transliterated')"
]
},
{
"cell_type": "markdown",
"id": "595549d4-f2eb-4f18-848e-4d0cdaa38624",
"metadata": {
"tags": []
},
"source": [
"#### Remark regarding data"
]
},
{
"cell_type": "markdown",
"id": "b9ab279f-991b-4456-9bab-bd6d83ebc5fc",
"metadata": {},
"source": [
"Note that this data originates from file `otext.tf`:\n",
"\n",
"> \n",
"```\n",
"@config\n",
"...\n",
"@fmt:text-orig-full={word}{after}\n",
"...\n",
"```\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}