"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.table(results, end=10, skipCols=\"1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is the first one in a pretty display:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"book 1_Samuel
book=Samuel_I
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, end=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We are going to do some more work where we want to skip column 1, so we make that the temporary default:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"A.displaySetup(skipCols=\"1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we show a few results without the book column:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"book 1_Samuel
book=Samuel_I
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"book 1_Samuel
book=Samuel_I
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, end=2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"or, stopping at the clause level:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"book 1_Samuel
book=Samuel_I
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Samuel_I
sentence 1
clause וַיְהִי֩ אִ֨ישׁ אֶחָ֜ד מִן־הָרָמָתַ֛יִם צֹופִ֖ים מֵהַ֣ר אֶפְרָ֑יִם
sentence 2
clause וּשְׁמֹ֡ו אֶ֠לְקָנָה בֶּן־יְרֹחָ֧ם בֶּן־אֱלִיה֛וּא בֶּן־תֹּ֥חוּ בֶן־צ֖וּף אֶפְרָתִֽי׃
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"book 1_Samuel
book=Samuel_I
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Samuel_I
sentence 1
clause וַיְהִי֩ אִ֨ישׁ אֶחָ֜ד מִן־הָרָמָתַ֛יִם צֹופִ֖ים מֵהַ֣ר אֶפְרָ֑יִם
sentence 2
clause וּשְׁמֹ֡ו אֶ֠לְקָנָה בֶּן־יְרֹחָ֧ם בֶּן־אֱלִיה֛וּא בֶּן־תֹּ֥חוּ בֶן־צ֖וּף אֶפְרָתִֽי׃
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, end=2, baseTypes={\"clause\"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can view result in phonetic representation as well:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"n | p | book | clause | word |
\n",
"1 | 1_Samuel 1:1 | | wayᵊhˌî ʔˌîš ʔeḥˈāḏ min-hārāmāṯˈayim ṣôfˌîm mēhˈar ʔefrˈāyim | ʔefrˈāyim |
\n",
"2 | 1_Samuel 1:1 | | ûšᵊmˈô ʔelqānˌā ben-yᵊrōḥˈām ben-ʔᵉlîhˈû ben-tˌōḥû ven-ṣˌûf ʔefrāṯˈî . | ʔelqānˌā |
\n",
"3 | 1_Samuel 1:1 | | ûšᵊmˈô ʔelqānˌā ben-yᵊrōḥˈām ben-ʔᵉlîhˈû ben-tˌōḥû ven-ṣˌûf ʔefrāṯˈî . | yᵊrōḥˈām |
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.table(results, end=3, fmt=\"text-phono-full\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:06.875859Z",
"start_time": "2018-05-24T07:47:06.757345Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"book 1_Samuel
book=Samuel_I
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, end=1, fmt=\"text-phono-full\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We are done with this query and its results. We reset the `skipCols` parameter."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"A.displayReset(\"skipCols\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Condense results\n",
"\n",
"There are two fundamentally different ways of presenting the results: condensed and uncondensed.\n",
"\n",
"In **uncondensed** view, all results are listed individually.\n",
"You can keep track of which parts belong to which results.\n",
"The display can become unwieldy.\n",
"\n",
"This is the default view, because it is the straightest, most logical, answer to your query.\n",
"\n",
"In **condensed** view all nodes of all results are grouped in containers first (e.g. verses), and then presented\n",
"container by container.\n",
"You loose the information of what parts belong to what result.\n",
"\n",
"Here is an example of the difference."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:14.547656Z",
"start_time": "2018-05-24T07:47:14.544433Z"
}
},
"outputs": [],
"source": [
"query = \"\"\"\n",
"book book=Genesis\n",
" chapter chapter=1\n",
" verse verse=1\n",
" sentence\n",
"% order is not important!\n",
" word nu=sg\n",
" word nu=pl\n",
"\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that you can have comments in a search template. Comment lines start with a `%`."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:18.913432Z",
"start_time": "2018-05-24T07:47:17.357992Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.45s 6 results\n"
]
}
],
"source": [
"results = A.search(query)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The book, chapter, verse columns are completely uninformative, so:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"A.displaySetup(skipCols=\"1 2 3\")"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:18.913432Z",
"start_time": "2018-05-24T07:47:17.357992Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"n | p | book | chapter | verse | sentence | word | word |
\n",
"1 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | רֵאשִׁ֖ית | אֱלֹהִ֑ים |
\n",
"2 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | רֵאשִׁ֖ית | שָּׁמַ֖יִם |
\n",
"3 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | בָּרָ֣א | אֱלֹהִ֑ים |
\n",
"4 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | בָּרָ֣א | שָּׁמַ֖יִם |
\n",
"5 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | אָֽרֶץ׃ | אֱלֹהִ֑ים |
\n",
"6 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | אָֽרֶץ׃ | שָּׁמַ֖יִם |
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.table(results, withPassage=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are two plural and three singular words in Genesis 1:1.\n",
"Search templates do not specify order, so all six combinations qualify as results.\n",
"\n",
"Let's expand the results display:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:21.573937Z",
"start_time": "2018-05-24T07:47:21.561079Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 4"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 5"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 6"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you see, the results are listed per result tuple, even if they occur all in the same verse.\n",
"This way you can keep track of what exactly belongs to each result.\n",
"\n",
"Now in condensed mode:"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:21.573937Z",
"start_time": "2018-05-24T07:47:21.561079Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"verse 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, condensed=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we have all words of all results in one display. But we cannot see that each results has two words, let alone which ones."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Custom highlighting\n",
"\n",
"Note that we can apply different highlight colours to different parts of the result.\n",
"The words in the pair are member 5 and 6 of the result tuples.\n",
"The members that we do not map, will not be highlighted.\n",
"The members that we map to the empty string will be highlighted with the default color.\n",
"\n",
"**NB:** Choose your colours from the\n",
"[CSS specification](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)."
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:25.094797Z",
"start_time": "2018-05-24T07:47:25.048277Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 4"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 5"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 6"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, condensed=False, colorMap={4: \"\", 5: \"cyan\", 6: \"magenta\"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Color mapping works best for uncondensed results. If you condense results, some nodes may occupy\n",
"different positions in different results. It is unpredictable which color will be used\n",
"for such nodes:"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:35.832254Z",
"start_time": "2018-05-24T07:47:35.821001Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"verse 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, condensed=True, colorMap={4: \"\", 5: \"cyan\", 6: \"magenta\"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can specify to what container you want to condense. By default, everything is condensed to verses.\n",
"\n",
"Let's change that to phrases:"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"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"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"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"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"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"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 4"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"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"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 5"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"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"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 6"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"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.show(\n",
" results,\n",
" condensed=False,\n",
" condenseType=\"phrase\",\n",
" colorMap={4: \"\", 5: \"cyan\", 6: \"magenta\"},\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Constraining order\n",
"You can stipulate an order on the words in your template.\n",
"You only have to put a relational operator between them.\n",
"Say we want only results where the plural follows the singular."
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:47:59.832291Z",
"start_time": "2018-05-24T07:47:59.827343Z"
}
},
"outputs": [],
"source": [
"query = \"\"\"\n",
"book book=Genesis\n",
" chapter chapter=1\n",
" verse verse=1\n",
" sentence\n",
" word nu=sg\n",
" < word nu=pl\n",
"\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that we keep the `skipCols=\"1 2 3\"` display setting in force, since it is relevant for this query as well."
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:48:04.746084Z",
"start_time": "2018-05-24T07:48:03.223548Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.44s 4 results\n"
]
},
{
"data": {
"text/html": [
"n | p | book | chapter | verse | sentence | word | word |
\n",
"1 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | רֵאשִׁ֖ית | אֱלֹהִ֑ים |
\n",
"2 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | רֵאשִׁ֖ית | שָּׁמַ֖יִם |
\n",
"3 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | בָּרָ֣א | אֱלֹהִ֑ים |
\n",
"4 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | בָּרָ֣א | שָּׁמַ֖יִם |
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"results = A.search(query)\n",
"A.table(results)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also require the words to be adjacent."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:49:20.315639Z",
"start_time": "2018-05-24T07:49:20.311979Z"
}
},
"outputs": [],
"source": [
"query = \"\"\"\n",
"book book=Genesis\n",
" chapter chapter=1\n",
" verse verse=1\n",
" sentence\n",
" word nu=sg\n",
" <: word nu=pl\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:49:25.158646Z",
"start_time": "2018-05-24T07:49:23.718047Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.41s 1 result\n"
]
},
{
"data": {
"text/html": [
"n | p | book | chapter | verse | sentence | word | word |
\n",
"1 | Genesis 1:1 | | | | בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ | בָּרָ֣א | אֱלֹהִ֑ים |
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"results = A.search(query)\n",
"colorMap = {5: \"lightsalmon\", 6: \"mediumaquamarine\"}\n",
"A.table(results, colorMap=colorMap)\n",
"A.show(results, condensed=False, colorMap=colorMap)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Custom feature display\n",
"\n",
"We would like to see the gender, number and person for words.\n",
"The way to do that, is to perform a `A.displaySetup(...)` first."
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:49:51.867815Z",
"start_time": "2018-05-24T07:49:51.864197Z"
}
},
"outputs": [],
"source": [
"A.displaySetup(\n",
" extraFeatures=\"ps gn nu\", colorMap={2: \"lightsalmon\", 3: \"mediumaquamarine\"}\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:49:53.189127Z",
"start_time": "2018-05-24T07:49:53.176377Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, condensed=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The features without meaningful values have been left out. We can also change that by passing a set of values\n",
"we think are not meaningful. The default set is\n",
"\n",
"```python\n",
"{None, 'NA', 'none', 'unknown'}\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:49:56.593302Z",
"start_time": "2018-05-24T07:49:56.579038Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"book Genesis
book=Genesischapter=gn=nu=ps=verse=
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1gn=nu=ps=verse=
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1gn=nu=ps=verse=1
sentence 1
book=chapter=gn=nu=ps=verse=
clause xQtX NA
book=chapter=gn=nu=ps=verse=
phrase PP Time
book=chapter=gn=nu=ps=verse=
book=chapter=gn=NAnu=NAps=NAverse=
book=chapter=gn=fnu=sgps=NAverse=
phrase VP Pred
book=chapter=gn=nu=ps=verse=
book=chapter=gn=mnu=sgps=p3verse=
phrase NP Subj
book=chapter=gn=nu=ps=verse=
book=chapter=gn=mnu=plps=NAverse=
phrase PP Objc
book=chapter=gn=nu=ps=verse=
book=chapter=gn=NAnu=NAps=NAverse=
book=chapter=gn=NAnu=NAps=NAverse=
book=chapter=gn=mnu=plps=NAverse=
book=chapter=gn=NAnu=NAps=NAverse=
book=chapter=gn=NAnu=NAps=NAverse=
book=chapter=gn=NAnu=NAps=NAverse=
book=chapter=gn=unknownnu=sgps=NAverse=
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.displaySetup(noneValues=set())\n",
"A.show(results, condensed=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This makes clear that it is convenient to keep `None` in the `noneValues`:"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:50:03.094084Z",
"start_time": "2018-05-24T07:50:03.080237Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.displaySetup(noneValues={None})\n",
"A.show(results, condensed=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can even choose to suppress other values, e.g. the male gender values and the singular number values."
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:50:08.244221Z",
"start_time": "2018-05-24T07:50:08.232311Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.displaySetup(noneValues={None, \"NA\", \"unknown\", \"none\", \"m\", \"sg\"})\n",
"A.show(results, condensed=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the rest of the notebook we stick to our normal setup, so we reset the extra features."
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:50:18.030145Z",
"start_time": "2018-05-24T07:50:18.019245Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"chapter Genesis 1
book=Genesischapter=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
book=Genesischapter=1verse=1
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.displayReset(\"extraFeatures\")\n",
"A.show(results, condensed=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we completely reset the display customization."
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"A.displayReset()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Only display selected query features\n",
"\n",
"Sometimes you want to show only some query features, but not all.\n",
"\n",
"For example, after this query ..."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.20s 5992 results\n"
]
}
],
"source": [
"results = A.search(\"\"\"\n",
"word gn=f nu=pl sp=subs\n",
"\"\"\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"you want to show the `nu` feature, but not the `gn` and `sp` features:"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, end=1, condenseType=\"clause\", queryFeatures=False, extraFeatures=\"nu\") "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"An other way to achieve this is by means of `tupleFeatures`.\n",
"Before we do that, let's examine the value of `tupleFeatures` in the current display setup:"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"tupleFeatures = ((0, ('gn', 'nu', 'sp')),)\n"
]
}
],
"source": [
"A.displaySetup(\"tupleFeatures\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ah, here are the features stored in the last query."
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(results, end=1, condenseType=\"clause\", tupleFeatures=\"nu\") "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Show your own tuples\n",
"\n",
"So far we have show the results of searches with `show()`.\n",
"But you can also construct your own tuples and show them.\n",
"\n",
"Whereas you can use search to get a pretty good approximation of what you want, most of the times\n",
"you do not arrive precisely at your destination.\n",
"\n",
"Here is an example where we use search to come close, and then work our way to produce the end result.\n",
"\n",
"## Disagreement in number\n",
"\n",
"We look for clauses with a one-word subject that does not agree in number with its predicate.\n",
"\n",
"In our search templates we cannot formulate that a feature has different values on two nodes in the template.\n",
"We could spell out all possible combinations of values and make a search template for each of them,\n",
"but that is needlessly complex.\n",
"\n",
"Let's first use search to find all clauses containing a one word subject and a predicate.\n",
"And, to narrow down it further, we require that the word in the subject and the verb in the predicate are\n",
"marked for number.\n",
"\n",
"(You may want to consult the feature docs, see the link at the start of the notebook, where `Bhsa()` is called).\n",
"\n",
"Note that the order of the phrases does not matter."
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:51:05.187418Z",
"start_time": "2018-05-24T07:51:02.450365Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.83s 10638 results\n"
]
}
],
"source": [
"query = \"\"\"\n",
"clause\n",
" phrase function=Subj\n",
" =: word nu=sg|pl\n",
" :=\n",
" phrase function=Pred|PreO\n",
" word sp=verb\n",
" nu=sg|pl\n",
"\"\"\"\n",
"results = A.search(query)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now the hand coding begins. We are going to extract the tuples we want."
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:51:06.901462Z",
"start_time": "2018-05-24T07:51:06.878281Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"467 filtered results\n"
]
}
],
"source": [
"wantedResults = tuple(\n",
" (subj, pred)\n",
" for (clause, phraseS, subj, phraseV, pred) in results\n",
" if F.nu.v(subj) != F.nu.v(pred)\n",
")\n",
"print(f\"{len(wantedResults)} filtered results\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And now we can show them:"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((4, 3), (34, 33), (42, 41), (50, 49))"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wantedResults[0:4]"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.table(\n",
" wantedResults, start=1, end=4, colorMap={1: \"lightsalmon\", 2: \"mediumaquamarine\"}\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:51:11.465916Z",
"start_time": "2018-05-24T07:51:11.423636Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"result 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
sentence 1
clause xQtX NA
phrase PP Time
function=Time
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
phrase PP Objc
function=Objc
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
sentence 5
clause WayX NA
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
sentence 6
clause ZYqX NA
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
sentence 7
clause WayX NA
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
sentence 8
clause WayX NA
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
phrase PP Objc
function=Objc
clause xQt0 Objc
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
sentence 9
clause WayX NA
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
phrase PP Cmpl
function=Cmpl
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"result 4"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse
sentence 8
clause WayX NA
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
phrase PP Objc
function=Objc
clause xQt0 Objc
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
sentence 9
clause WayX NA
phrase CP Conj
function=Conj
phrase VP Pred
function=Pred
phrase NP Subj
function=Subj
phrase PP Cmpl
function=Cmpl
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(\n",
" wantedResults, start=1, end=4, colorMap={1: \"lightsalmon\", 2: \"mediumaquamarine\"}\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now suppose that we want to highlight the non-qal verb forms with a different color.\n",
"\n",
"We have to assign colours to the members of our tuples:"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:51:16.633433Z",
"start_time": "2018-05-24T07:51:16.628359Z"
}
},
"outputs": [],
"source": [
"highlights = {}\n",
"for (subj, pred) in wantedResults:\n",
" highlights[subj] = \"lightsalmon\"\n",
" highlights[pred] = \"mediumaquamarine\" if F.vs.v(pred) == \"qal\" else \"yellow\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can call show with the `highlights` parameter instead of the `colorMap` parameter."
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:51:19.423335Z",
"start_time": "2018-05-24T07:51:19.391463Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.table(wantedResults, start=1, end=4, highlights=highlights)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or in condensed pretty display:"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:51:19.423335Z",
"start_time": "2018-05-24T07:51:19.391463Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"verse 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse:1414392
sentence:1172315 8
clause:427566 WayX NA
phrase:651596 CP Conj
function=Conj
phrase:651597 VP Pred
function=Pred
phrase:651598 NP Subj
function=Subj
phrase:651599 PP Objc
function=Objc
clause:427567 xQt0 Objc
phrase:651600 CP Conj
function=Conj
phrase:651601 VP Pred
function=Pred
sentence:1172316 9
clause:427568 WayX NA
phrase:651602 CP Conj
function=Conj
phrase:651603 VP Pred
function=Pred
phrase:651604 NP Subj
function=Subj
phrase:651605 PP Cmpl
function=Cmpl
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A.show(\n",
" wantedResults,\n",
" condensed=True,\n",
" start=3,\n",
" end=3,\n",
" highlights=highlights,\n",
" extraFeatures=\"vs\",\n",
" withNodes=True,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you see, you have total control."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# All steps\n",
"\n",
"* **[start](start.ipynb)** your first step in mastering the bible computationally\n",
"* **[display](display.ipynb)** become an expert in creating pretty displays of your text structures\n",
"* **search** turbo charge your hand-coding with search templates\n",
"\n",
"---\n",
"\n",
"You know how to run queries and show off with their results.\n",
"\n",
"The next thing is to dive deeper into the power of templates:\n",
"\n",
"[advanced](searchAdvanced.ipynb)\n",
"[sets](searchSets.ipynb)\n",
"[relations](searchRelations.ipynb)\n",
"[quantifiers](searchQuantifiers.ipynb)\n",
"[from MQL](searchFromMQL.ipynb)\n",
"[rough](searchRough.ipynb)\n",
"[gaps](searchGaps.ipynb)\n",
"\n",
"---\n",
"\n",
"* **[export Excel](exportExcel.ipynb)** make tailor-made spreadsheets out of your results\n",
"* **[share](share.ipynb)** draw in other people's data and let them use yours\n",
"* **[export](export.ipynb)** export your dataset as an Emdros database\n",
"* **[annotate](annotate.ipynb)** annotate plain text by means of other tools and import the annotations as TF features\n",
"* **[map](map.ipynb)** map somebody else's annotations to a new version of the corpus\n",
"* **[volumes](volumes.ipynb)** work with selected books only\n",
"* **[trees](trees.ipynb)** work with the BHSA data as syntax trees\n",
"\n",
"CC-BY Dirk Roorda"
]
}
],
"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.12.0"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}