"
]
},
"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": "markdown",
"id": "a29a3dc3-f727-458d-b90b-bee8e4545859",
"metadata": {},
"source": [
"# 3 - Performing the queries \n",
"##### [Back to TOC](#TOC)"
]
},
{
"cell_type": "markdown",
"id": "e5f5ec0c-c754-4d5a-9cb6-3b6249859ea1",
"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": 6,
"id": "7a6b5c40-7a4f-4a8e-bc8c-363c9691c40e",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.01s 1 result\n"
]
},
{
"data": {
"text/html": [
"verse 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Matthewchapter=1verse=8
clause #19
book=Matthewchapter=1clauserule=S-V-Overse=8
phrase #57
phrasefunction=S
Ἀσὰφ
book=Matthewchapter=1sp=nounverse=8
δὲ
book=Matthewchapter=1sp=conjverse=8
phrase #58
phrasefunction=V
ἐγέννησεν
book=Matthewchapter=1sp=verbverse=8
phrase #59
phrasefunction=O
τὸν
book=Matthewchapter=1sp=detverse=8
Ἰωσαφάτ,
book=Matthewchapter=1sp=nounverse=8
clause #20
book=Matthewchapter=1clauserule=S-V-Overse=8
phrase #60
phrasefunction=S
Ἰωσαφὰτ
book=Matthewchapter=1sp=nounverse=8
δὲ
book=Matthewchapter=1sp=conjverse=8
phrase #61
phrasefunction=V
ἐγέννησεν
book=Matthewchapter=1sp=verbverse=8
phrase #62
phrasefunction=O
τὸν
book=Matthewchapter=1sp=detverse=8
Ἰωράμ,
book=Matthewchapter=1sp=nounverse=8
clause #21
book=Matthewchapter=1clauserule=S-V-Overse=9
phrase #63
phrasefunction=S
Ἰωρὰμ
book=Matthewchapter=1sp=nounverse=8
δὲ
book=Matthewchapter=1sp=conjverse=8
phrase #64
phrasefunction=V
ἐγέννησεν
book=Matthewchapter=1sp=verbverse=8
phrase #65
phrasefunction=O
τὸν
book=Matthewchapter=1sp=detverse=8
Ὀζείαν,
book=Matthewchapter=1sp=nounverse=8
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Define the query template\n",
"VerseQuery = '''\n",
"book book=Matthew\n",
" chapter chapter=1\n",
" verse verse=8\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",
"VerseResult = N1904.search(VerseQuery)\n",
"\n",
"# Print some of the results\n",
"N1904.show(VerseResult, start=1, end=2, condensed=True, extraFeatures={'sp', 'clauserule', 'phrasefunction'}, multiFeatures=False)"
]
},
{
"cell_type": "markdown",
"id": "7f66a197-eab6-4f31-98c4-31161317ea96",
"metadata": {},
"source": [
"## 3.2 - Selecting individual words of the verse \n",
"##### [Back to TOC](#TOC)"
]
},
{
"cell_type": "markdown",
"id": "085fba5d-f0c4-4214-b6b3-b8381861e6d3",
"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": 7,
"id": "5bb83121-10cc-4430-95af-a558c5a5cc21",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.09s 15 results\n"
]
},
{
"data": {
"text/html": [
"verse 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Matthewchapter=1verse=8
clause #19
book=Matthewchapter=1verse=8
phrase #57
Ἀσὰφ
book=Matthewchapter=1verse=8
δὲ
book=Matthewchapter=1verse=8
phrase #58
ἐγέννησεν
book=Matthewchapter=1verse=8
phrase #59
τὸν
book=Matthewchapter=1verse=8
Ἰωσαφάτ,
book=Matthewchapter=1verse=8
clause #20
book=Matthewchapter=1verse=8
phrase #60
Ἰωσαφὰτ
book=Matthewchapter=1verse=8
δὲ
book=Matthewchapter=1verse=8
phrase #61
ἐγέννησεν
book=Matthewchapter=1verse=8
phrase #62
τὸν
book=Matthewchapter=1verse=8
Ἰωράμ,
book=Matthewchapter=1verse=8
clause #21
book=Matthewchapter=1verse=9
phrase #63
Ἰωρὰμ
book=Matthewchapter=1verse=8
δὲ
book=Matthewchapter=1verse=8
phrase #64
ἐγέννησεν
book=Matthewchapter=1verse=8
phrase #65
τὸν
book=Matthewchapter=1verse=8
Ὀζείαν,
book=Matthewchapter=1verse=8
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Define the query template\n",
"AltVerseQuery = '''\n",
"word book=Matthew chapter=1 verse=8\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)"
]
},
{
"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": "code",
"execution_count": 8,
"id": "b963ca04-3c61-45e1-943b-6649885218b2",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"format | level | template\n",
"--- | --- | ---\n",
"`text-orig-full` | **word** | `{word}{after}`\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"N1904.showFormats()"
]
},
{
"cell_type": "markdown",
"id": "2981185e-7e93-4ed1-998b-16830cc712d3",
"metadata": {},
"source": [
"The same result (although formatted different, since an ordered tuple is returned) can be obtained by the following call:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "30ffd6f5-a293-4edb-b4f9-d58927db5b14",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'text-orig-full': 'word'}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T.formats"
]
},
{
"cell_type": "markdown",
"id": "f8fe7723-e643-4f39-b368-c6c16ab56e61",
"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"
]
},
{
"cell_type": "markdown",
"id": "1d364cff-1b7e-42d0-aa32-cbf6e0ff1537",
"metadata": {},
"source": [
"# 4 - Attribution and footnotes\n",
"##### [Back to TOC](#TOC)\n",
"\n",
"N.A."
]
},
{
"cell_type": "markdown",
"id": "1aed70bc-570b-4175-a094-ef2d86b15334",
"metadata": {},
"source": [
"# 5 - Required libraries \n",
"##### [Back to TOC](#TOC)\n",
"\n",
"The scripts in this notebook require (beside `text-fabric`) the following Python libraries to be installed in the environment:\n",
"\n",
" {none}\n",
"\n",
"You can install any missing library from within Jupyter Notebook using either`pip` or `pip3`."
]
}
],
"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
}