{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"\n",
"\n",
"---\n",
"\n",
"To get started: consult [start](start.ipynb)\n",
"\n",
"---\n",
"\n",
"# Export to Excel\n",
"\n",
"In a notebook, you can perform searches and view them in a tabular display and zoom in on items with\n",
"pretty displays.\n",
"\n",
"But there are times that you want to take your results outside Text-Fabric, outside a notebook, outside Python, and just\n",
"work with them in other programs, such as Excel.\n",
"\n",
"You want to do that not only with query results, but with all kinds of lists of tuples of nodes.\n",
"\n",
"There is a function for that, `A.export()`, and here we show what it can do."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T10:06:39.818664Z",
"start_time": "2018-05-24T10:06:39.796588Z"
}
},
"outputs": [],
"source": [
"import os\n",
"from tf.app import use"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"TF-app:~/text-fabric-data/Nino-cunei/oldbabylonian/app"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"data:~/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.6"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"This is Text-Fabric 9.2.2\n",
"Api reference : https://annotation.github.io/text-fabric/tf/cheatsheet.html\n",
"\n",
"67 features found and 0 ignored\n"
]
},
{
"data": {
"text/html": [
"Text-Fabric:Text-Fabric API 9.2.2, Nino-cunei/oldbabylonian/app v3, Search Reference Data:OLDBABYLONIAN, Character table, Feature docs Features: \n",
"Old Babylonian Letters 1900-1600: Cuneiform tablets\n",
"
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A = use(\"Nino-cunei/oldbabylonian\", hoist=globals())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Inspect the contents of a file\n",
"We write a function that can peek into file on your system, and show the first few lines.\n",
"We'll use it to inspect the exported files that we are going to produce."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"EXPORT_FILE = os.path.expanduser(\"~/Downloads/results.tsv\")\n",
"UPTO = 10\n",
"\n",
"\n",
"def checkout():\n",
" with open(EXPORT_FILE, encoding=\"utf_16\") as fh:\n",
" for (i, line) in enumerate(fh):\n",
" if i >= UPTO:\n",
" break\n",
" print(line.rstrip(\"\\n\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Encoding\n",
"\n",
"Our exported `.tsv` files open in Excel without hassle, even if they contain non-latin characters.\n",
"That is because TF writes such files in an\n",
"encoding that works well with Excel: `utf_16_le`.\n",
"You can just open them in Excel, there is no need for conversion before or after opening these files.\n",
"\n",
"Should you want to process these files by means of a (Python) program,\n",
"take care to read them with encoding `utf_16`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example query\n",
"\n",
"We first run a query in order to export the results."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:46:55.998382Z",
"start_time": "2018-05-24T07:46:55.137956Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.45s 1052 results\n"
]
}
],
"source": [
"query = \"\"\"\n",
"line ln<4\n",
" =: sign reading=um\n",
" <: sign reading=ma\n",
" < sign reading=ma\n",
"\"\"\"\n",
"results = A.search(query)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Bare export\n",
"\n",
"You can export the table of results to Excel.\n",
"\n",
"The following command writes a tab-separated file `results.tsv` to your downloads directory.\n",
"\n",
"You can specify arguments `toDir=directory` and `toFile=file name` to write to a different file.\n",
"If the directory does not exist, it will be created.\n",
"\n",
"We stick to the default, however."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"A.export(results)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check out the contents:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tTEXT1\tln1\tNODE2\tTYPE2\tTEXT2\treading2\tNODE3\tTYPE3\tTEXT3\treading3\tNODE4\tTYPE4\tTEXT4\treading4\n",
"1\tP509373\tobverse\t3\t230790\tline\tum-ma _{d}en-lil2_-sza-du-u2-ni-ma\t3\t11\tsign\tum-\tum\t12\tsign\tma \tma\t20\tsign\tma\tma\n",
"2\tP509374\tobverse\t3\t230826\tline\tum-[ma] _dingir_ x zi x [...] ma\t3\t359\tsign\tum-\tum\t360\tsign\t[ma] \tma\t366\tsign\tma\tma\n",
"3\tP509375\tobverse\t3\t230844\tline\t[um-ma x]-na-su-[x]-ma\t3\t509\tsign\t[um-\tum\t510\tsign\tma \tma\t515\tsign\tma\tma\n",
"4\tP481190\tobverse\t3\t230916\tline\tum-ma nu#-ur2#-i3-li2-szu-ma\t3\t1123\tsign\tum-\tum\t1124\tsign\tma \tma\t1130\tsign\tma\tma\n",
"5\tP510526\tobverse\t3\t231004\tline\tum-ma geme2-{d}utu-ma\t3\t1686\tsign\tum-\tum\t1687\tsign\tma \tma\t1691\tsign\tma\tma\n",
"6\tP510527\tobverse\t3\t231022\tline\tum-ma i-lu-ni-ma\t3\t1808\tsign\tum-\tum\t1809\tsign\tma \tma\t1813\tsign\tma\tma\n",
"7\tP510528\tobverse\t3\t231055\tline\t[um]-ma# i-lu-ni-ma\t3\t2161\tsign\t[um]-\tum\t2162\tsign\tma# \tma\t2166\tsign\tma\tma\n",
"8\tP510529\tobverse\t3\t231068\tline\tum-ma i-lu-ni-ma\t3\t2272\tsign\tum-\tum\t2273\tsign\tma \tma\t2277\tsign\tma\tma\n",
"9\tP510530\tobverse\t3\t231088\tline\t[um-ma {d}na-bi]-um#-na-s,i-ir-ma\t3\t2401\tsign\t[um-\tum\t2402\tsign\tma \tma\t2410\tsign\tma\tma\n"
]
}
],
"source": [
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You see the following columns:\n",
"\n",
"* *`R`* the sequence number of the result tuple in the result list\n",
"* *`S1 S2 S3`* the section as P-number, face, line number, in separate columns\n",
"* *`NODEi TYPEi`* the node and its type, for each node *`i`* in the result tuple\n",
"* *`TEXTi`* the full text of node *`i`*, if the node type admits a concise text representation\n",
"* *`reading2-4`* the value of feature *`reading`*, since our query mentions the feature `reading` on nodes 2-4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Poorer exports\n",
"\n",
"If you do not need the full text of the lines, you can leave them out by specifying a smaller *condense type*.\n",
"\n",
"The export function provides text for all nodes whose type is not too big.\n",
"What is too big is determined by the condense type.\n",
"\n",
"In this corpus, the default condense type is line. Node types bigger than lines will not get text.\n",
"\n",
"Now, if we change the condense type to something smaller than line, e.g. `word`, the line text will be suppressed."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tln1\tNODE2\tTYPE2\tTEXT2\treading2\tNODE3\tTYPE3\tTEXT3\treading3\tNODE4\tTYPE4\tTEXT4\treading4\n",
"1\tP509373\tobverse\t3\t230790\tline\t3\t11\tsign\tum-\tum\t12\tsign\tma \tma\t20\tsign\tma\tma\n",
"2\tP509374\tobverse\t3\t230826\tline\t3\t359\tsign\tum-\tum\t360\tsign\t[ma] \tma\t366\tsign\tma\tma\n",
"3\tP509375\tobverse\t3\t230844\tline\t3\t509\tsign\t[um-\tum\t510\tsign\tma \tma\t515\tsign\tma\tma\n",
"4\tP481190\tobverse\t3\t230916\tline\t3\t1123\tsign\tum-\tum\t1124\tsign\tma \tma\t1130\tsign\tma\tma\n",
"5\tP510526\tobverse\t3\t231004\tline\t3\t1686\tsign\tum-\tum\t1687\tsign\tma \tma\t1691\tsign\tma\tma\n",
"6\tP510527\tobverse\t3\t231022\tline\t3\t1808\tsign\tum-\tum\t1809\tsign\tma \tma\t1813\tsign\tma\tma\n",
"7\tP510528\tobverse\t3\t231055\tline\t3\t2161\tsign\t[um]-\tum\t2162\tsign\tma# \tma\t2166\tsign\tma\tma\n",
"8\tP510529\tobverse\t3\t231068\tline\t3\t2272\tsign\tum-\tum\t2273\tsign\tma \tma\t2277\tsign\tma\tma\n",
"9\tP510530\tobverse\t3\t231088\tline\t3\t2401\tsign\t[um-\tum\t2402\tsign\tma \tma\t2410\tsign\tma\tma\n"
]
}
],
"source": [
"A.export(results, condenseType=\"word\")\n",
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Richer exports\n",
"\n",
"If we want to see the text in another format, we can specify it:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tTEXT1\tln1\tNODE2\tTYPE2\tTEXT2\treading2\tNODE3\tTYPE3\tTEXT3\treading3\tNODE4\tTYPE4\tTEXT4\treading4\n",
"1\tP509373\tobverse\t3\t230790\tline\t𒌝𒈠 𒀭𒂗𒆤𒊭𒁺𒌑𒉌𒈠\t3\t11\tsign\t𒌝\tum\t12\tsign\t𒈠 \tma\t20\tsign\t𒈠\tma\n",
"2\tP509374\tobverse\t3\t230826\tline\t𒌝𒈠 𒀭 x 𒍣 x … 𒈠\t3\t359\tsign\t𒌝\tum\t360\tsign\t𒈠 \tma\t366\tsign\t𒈠\tma\n",
"3\tP509375\tobverse\t3\t230844\tline\t𒌝𒈠 x𒈾𒋢x𒈠\t3\t509\tsign\t𒌝\tum\t510\tsign\t𒈠 \tma\t515\tsign\t𒈠\tma\n",
"4\tP481190\tobverse\t3\t230916\tline\t𒌝𒈠 𒉡𒌫𒉌𒉌𒋗𒈠\t3\t1123\tsign\t𒌝\tum\t1124\tsign\t𒈠 \tma\t1130\tsign\t𒈠\tma\n",
"5\tP510526\tobverse\t3\t231004\tline\t𒌝𒈠 𒊩𒆳𒀭𒌓𒈠\t3\t1686\tsign\t𒌝\tum\t1687\tsign\t𒈠 \tma\t1691\tsign\t𒈠\tma\n",
"6\tP510527\tobverse\t3\t231022\tline\t𒌝𒈠 𒄿𒇻𒉌𒈠\t3\t1808\tsign\t𒌝\tum\t1809\tsign\t𒈠 \tma\t1813\tsign\t𒈠\tma\n",
"7\tP510528\tobverse\t3\t231055\tline\t𒌝𒈠 𒄿𒇻𒉌𒈠\t3\t2161\tsign\t𒌝\tum\t2162\tsign\t𒈠 \tma\t2166\tsign\t𒈠\tma\n",
"8\tP510529\tobverse\t3\t231068\tline\t𒌝𒈠 𒄿𒇻𒉌𒈠\t3\t2272\tsign\t𒌝\tum\t2273\tsign\t𒈠 \tma\t2277\tsign\t𒈠\tma\n",
"9\tP510530\tobverse\t3\t231088\tline\t𒌝𒈠 𒀭𒈾𒁉𒌝𒈾𒍢𒅕𒈠\t3\t2401\tsign\t𒌝\tum\t2402\tsign\t𒈠 \tma\t2410\tsign\t𒈠\tma\n"
]
}
],
"source": [
"A.export(results, fmt=\"text-orig-unicode\")\n",
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Additional features\n",
"\n",
"If we want to export additional features, we just have to mention them.\n",
"In order to do so and not change the result set, put a `*` behind the feature.\n",
"\n",
"The `*` means: *always true, no matter what's in the feature, even if there is nothing in there*.\n",
"\n",
"Lets ask for the flags on the first `ma`."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"ExecuteTime": {
"end_time": "2018-05-24T07:46:55.998382Z",
"start_time": "2018-05-24T07:46:55.137956Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.54s 1052 results\n"
]
}
],
"source": [
"query = \"\"\"\n",
"line ln<4\n",
" =: sign reading=um\n",
" <: sign reading=ma flags*\n",
" < sign reading=ma\n",
"\"\"\"\n",
"results = A.search(query)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The same number of results.\n",
"\n",
"We do the export again and peek at the results."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tln1\tNODE2\tTYPE2\tTEXT2\treading2\tNODE3\tTYPE3\tTEXT3\tflags3\treading3\tNODE4\tTYPE4\tTEXT4\treading4\n",
"1\tP509373\tobverse\t3\t230790\tline\t3\t11\tsign\tum-\tum\t12\tsign\tma \t\tma\t20\tsign\tma\tma\n",
"2\tP509374\tobverse\t3\t230826\tline\t3\t359\tsign\tum-\tum\t360\tsign\t[ma] \t\tma\t366\tsign\tma\tma\n",
"3\tP509375\tobverse\t3\t230844\tline\t3\t509\tsign\t[um-\tum\t510\tsign\tma \t\tma\t515\tsign\tma\tma\n",
"4\tP481190\tobverse\t3\t230916\tline\t3\t1123\tsign\tum-\tum\t1124\tsign\tma \t\tma\t1130\tsign\tma\tma\n",
"5\tP510526\tobverse\t3\t231004\tline\t3\t1686\tsign\tum-\tum\t1687\tsign\tma \t\tma\t1691\tsign\tma\tma\n",
"6\tP510527\tobverse\t3\t231022\tline\t3\t1808\tsign\tum-\tum\t1809\tsign\tma \t\tma\t1813\tsign\tma\tma\n",
"7\tP510528\tobverse\t3\t231055\tline\t3\t2161\tsign\t[um]-\tum\t2162\tsign\tma# \t#\tma\t2166\tsign\tma\tma\n",
"8\tP510529\tobverse\t3\t231068\tline\t3\t2272\tsign\tum-\tum\t2273\tsign\tma \t\tma\t2277\tsign\tma\tma\n",
"9\tP510530\tobverse\t3\t231088\tline\t3\t2401\tsign\t[um-\tum\t2402\tsign\tma \t\tma\t2410\tsign\tma\tma\n"
]
}
],
"source": [
"A.export(results, condenseType=\"word\")\n",
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you see, you have an extra column *`flags3`*.\n",
"\n",
"This gives you a lot of control over the generation of spreadsheets."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Not from queries\n",
"\n",
"You can also export lists of node tuples that are not obtained by a query:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(259163, 100001, 200001),\n",
" (259164, 100002, 200002),\n",
" (259165, 100003, 200003),\n",
" (259166, 100004, 200004),\n",
" (259167, 100005, 200005),\n",
" (259168, 100006, 200006),\n",
" (259169, 100007, 200007),\n",
" (259170, 100008, 200008),\n",
" (259171, 100009, 200009),\n",
" (259172, 100010, 200010)]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"words = F.otype.s(\"word\")[1000:1010]\n",
"signs1 = F.otype.s(\"sign\")[100000:100010]\n",
"signs2 = F.otype.s(\"sign\")[200000:200010]\n",
"tuples = list(zip(words, signs1, signs2))\n",
"\n",
"tuples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ten rows, each row has a word node and two sign nodes.\n",
"\n",
"The word and the signs in each row do not have any meaningful relationship!\n",
"\n",
"Let's do a bare export:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tTEXT1\tln1\tNODE2\tTYPE2\tTEXT2\treading2\tNODE3\tTYPE3\tTEXT3\tflags3\treading3\n",
"1\tP510530\tobverse\t19\t259163\tword\tgin2 \t\t100001\tsign\ts,i-\ts,i\t200001\tsign\tka\t\tka\n",
"2\tP510530\tobverse\t19\t259164\tword\tku3-babbar_\t\t100002\tsign\tbu-\tbu\t200002\tsign\tki-\t\tki\n",
"3\tP510530\tobverse\t20\t259165\tword\tid-di-nu-ni-ik-ku\t\t100003\tsign\ttam \ttam\t200003\tsign\tma \t\tma\n",
"4\tP510530\treverse\t1\t259166\tword\tu3 \t\t100004\tsign\tia \tia\t200004\tsign\tti-\t\tti\n",
"5\tP510530\treverse\t1\t259167\tword\tka-ni-ik \t\t100005\tsign\tir-\tir\t200005\tsign\tdu \t\tdu\n",
"6\tP510530\treverse\t1\t259168\tword\tszi-ma-tim \t\t100006\tsign\tszi\tszi\t200006\tsign\tma-\t\tma\n",
"7\tP510530\treverse\t1\t259169\tword\tta-ad-di-in\t\t100007\tsign\ti-\ti\t200007\tsign\tWI?-\t?\t\n",
"8\tP510530\treverse\t2\t259170\tword\tmi-nu-u2 \t\t100008\tsign\tnu-\tnu\t200008\tsign\ti-\t\ti\n",
"9\tP510530\treverse\t2\t259171\tword\ta-wa-tum-ma \t\t100009\tsign\tma \tma\t200009\tsign\tma\t\tma\n"
]
}
],
"source": [
"A.export(tuples)\n",
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Wait a minute: why are the `reading2` and `reading3` and `flags3` columns showing up?\n",
"\n",
"It is because we have run a query before where we asked for these features.\n",
"\n",
"If we do not want to be influenced by previous things we've run, we need to reset the display:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"A.displayReset(\"tupleFeatures\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Again:"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tTEXT1\tNODE2\tTYPE2\tTEXT2\tNODE3\tTYPE3\tTEXT3\n",
"1\tP510530\tobverse\t19\t259163\tword\tgin2 \t100001\tsign\ts,i-\t200001\tsign\tka\n",
"2\tP510530\tobverse\t19\t259164\tword\tku3-babbar_\t100002\tsign\tbu-\t200002\tsign\tki-\n",
"3\tP510530\tobverse\t20\t259165\tword\tid-di-nu-ni-ik-ku\t100003\tsign\ttam \t200003\tsign\tma \n",
"4\tP510530\treverse\t1\t259166\tword\tu3 \t100004\tsign\tia \t200004\tsign\tti-\n",
"5\tP510530\treverse\t1\t259167\tword\tka-ni-ik \t100005\tsign\tir-\t200005\tsign\tdu \n",
"6\tP510530\treverse\t1\t259168\tword\tszi-ma-tim \t100006\tsign\tszi\t200006\tsign\tma-\n",
"7\tP510530\treverse\t1\t259169\tword\tta-ad-di-in\t100007\tsign\ti-\t200007\tsign\tWI?-\n",
"8\tP510530\treverse\t2\t259170\tword\tmi-nu-u2 \t100008\tsign\tnu-\t200008\tsign\ti-\n",
"9\tP510530\treverse\t2\t259171\tword\ta-wa-tum-ma \t100009\tsign\tma \t200009\tsign\tma\n"
]
}
],
"source": [
"A.export(tuples)\n",
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Display setup\n",
"\n",
"When we exported query results, we could mention features in the query with a `*` so that they got exported.\n",
"If we do not have a previous query we can achieve the same effect by specifying the desired export features per column.\n",
"\n",
"The display option `tupleFeatures` takes care of that."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"A.displaySetup(\n",
" tupleFeatures=(\n",
" (0, \"atfpre atf atfpost\"),\n",
" (1, \"symr symu\"),\n",
" (2, \"symr symu\"),\n",
" )\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We assign extra features per member of the tuple.\n",
"\n",
"In the above case:\n",
"\n",
"* the first (`0`) member (the word node), gets features `atfpre` (preceding bracketing characters), `atf`, `atfpost` (subsequent clustering characters);\n",
"* the second and third member (the sign nodes), get features `symr` (subscript latin text) and `symu` (cuneiform unicode)."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tTEXT1\tatfpre1\tatf1\tatfpost1\tNODE2\tTYPE2\tTEXT2\tsymr2\tsymu2\tNODE3\tTYPE3\tTEXT3\tsymr3\tsymu3\n",
"1\tP510530\tobverse\t19\t259163\tword\tgin2 \t\tgin2\t\t100001\tsign\ts,i-\tṣi\t𒍢\t200001\tsign\tka\tka\t𒅗\n",
"2\tP510530\tobverse\t19\t259164\tword\tku3-babbar_\t\tku3-babbar_\t\t100002\tsign\tbu-\tbu\t𒁍\t200002\tsign\tki-\tki\t𒆠\n",
"3\tP510530\tobverse\t20\t259165\tword\tid-di-nu-ni-ik-ku\t\tid-di-nu-ni-ik-ku\t\t100003\tsign\ttam \ttam\t𒌓\t200003\tsign\tma \tma\t𒈠\n",
"4\tP510530\treverse\t1\t259166\tword\tu3 \t\tu3\t\t100004\tsign\tia \tia\t𒅀\t200004\tsign\tti-\tti\t𒋾\n",
"5\tP510530\treverse\t1\t259167\tword\tka-ni-ik \t\tka-ni-ik\t\t100005\tsign\tir-\tir\t𒅕\t200005\tsign\tdu \tdu\t𒁺\n",
"6\tP510530\treverse\t1\t259168\tword\tszi-ma-tim \t\tszi-ma-tim\t\t100006\tsign\tszi\tši\t𒅆\t200006\tsign\tma-\tma\t𒈠\n",
"7\tP510530\treverse\t1\t259169\tword\tta-ad-di-in\t\tta-ad-di-in\t\t100007\tsign\ti-\ti\t𒄿\t200007\tsign\tWI?-\tWI\t𒉿\n",
"8\tP510530\treverse\t2\t259170\tword\tmi-nu-u2 \t\tmi-nu-u2\t\t100008\tsign\tnu-\tnu\t𒉡\t200008\tsign\ti-\ti\t𒄿\n",
"9\tP510530\treverse\t2\t259171\tword\ta-wa-tum-ma \t\ta-wa-tum-ma\t\t100009\tsign\tma \tma\t𒈠\t200009\tsign\tma\tma\t𒈠\n"
]
}
],
"source": [
"A.export(tuples)\n",
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chained queries\n",
"\n",
"You can chain queries like this:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.17s 4 results\n",
" 0.17s 15 results\n"
]
}
],
"source": [
"results = (\n",
" A.search(\n",
" \"\"\"\n",
"line\n",
" cluster type=missing\n",
" sign reading=disz repeat>4\n",
"\"\"\"\n",
" )\n",
" + A.search(\n",
" \"\"\"\n",
"line\n",
" cluster type=langalt\n",
" sign reading=um\n",
"\"\"\"\n",
" )\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In such cases, it is better to setup the features yourself:"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"A.displaySetup(\n",
" tupleFeatures=(\n",
" (0, \"lnno\"),\n",
" (1, \"type\"),\n",
" (2, \"langalt missing\"),\n",
" ),\n",
" fmt=\"text-orig-rich\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can do a fine export:"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R\tS1\tS2\tS3\tNODE1\tTYPE1\tTEXT1\tlnno1\tNODE2\tTYPE2\tTEXT2\ttype2\tNODE3\tTYPE3\tTEXT3\tlangalt3\tmissing3\n",
"1\tP510754\tobverse\t11\t235994\tline\t5(diš) lu₂-meš an-nu-ti-in lu₂ la-ga-aš⁼ki-meš\t11\t207965\tcluster\t5(diš) lu₂-meš an-nu-ti-\tmissing\t39275\tsign\t5(diš) \t\t1\n",
"2\tP313375\tobverse\t10\t245175\tline\t1(u) 8(diš) gin₂ ku₃-babbar wa-at-ra-am\t10\t215367\tcluster\t1(u) 8(diš) \tmissing\t106850\tsign\t8(diš) \t\t1\n",
"3\tP373035\treverse\t3\t255006\tline\tša 5(diš) gin₂ ku₃-babbar gu₄ hi-a\t3\t223992\tcluster\tša 5(diš) \tmissing\t180799\tsign\t5(diš) \t1\t1\n",
"4\tP373044\tleft\t1:2\t255237\tline\t1(u) 5(diš) ma-na siki hi-a ši-na\t1:2\t224274\tcluster\t1(u) 5(diš) ma-na \tmissing\t182906\tsign\t5(diš) \t1\t1\n",
"5\tP509373\tobverse\t6\t230793\tline\tdiš⁼še-ep-d⁼suen a₂-gal₂ dumu um-mi-a-meš\t6\t203234\tcluster\td⁼suen a₂-gal₂ dumu um-mi-a-meš\tlangalt\t47\tsign\tum-\t1\t\n",
"6\tP510550\tobverse\t4\t231520\tline\taš-šum ha-za-nu-um⁼sar\t4\t203984\tcluster\tha-za-nu-um⁼sar\tlangalt\t5899\tsign\tum⁼\t1\t\n",
"7\tP510550\tobverse\t7\t231523\tline\tšum-ma ha-za-nu-um⁼sar la ba-aš-lu-ma\t7\t203987\tcluster\tha-za-nu-um⁼sar \tlangalt\t5924\tsign\tum⁼\t1\t\n",
"8\tP510550\tobverse\t9\t231525\tline\tha-za-nu-um⁼sar i-ka-am x x-al-la-x-ma\t9\t203989\tcluster\tha-za-nu-um⁼sar \tlangalt\t5941\tsign\tum⁼\t1\t\n",
"9\tP510550\treverse\t1\t231528\tline\ta-na mi-nim ha-za-nu-um⁼sar\t1\t203992\tcluster\tha-za-nu-um⁼sar\tlangalt\t5971\tsign\tum⁼\t1\t\n"
]
}
],
"source": [
"A.export(results)\n",
"checkout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"All chapters:\n",
"\n",
"* **[start](start.ipynb)** become an expert in creating pretty displays of your text structures\n",
"* **[display](display.ipynb)** become an expert in creating pretty displays of your text structures\n",
"* **[search](search.ipynb)** turbo charge your hand-coding with search templates\n",
"* **export Excel** make tailor-made spreadsheets out of your results\n",
"* **[share](share.ipynb)** draw in other people's data and let them use yours\n",
"* **[similarLines](similarLines.ipynb)** spot the similarities between lines\n",
"\n",
"---\n",
"\n",
"See the [cookbook](cookbook) for recipes for small, concrete tasks.\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.10.2"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}