|
@@ -0,0 +1,452 @@
|
|
|
+{
|
|
|
+ "cells": [
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "import sqlite3\n",
|
|
|
+ "import pandas as pd\n",
|
|
|
+ "import dtale\n",
|
|
|
+ "import unicodedata\n",
|
|
|
+ "from simple_query_test_pandas import ricercaforme\n",
|
|
|
+ "from simple_query_test_pandas import ricercalemmi\n",
|
|
|
+ "from simple_query_test_pandas import ricercaformelemmi \n",
|
|
|
+ "from simple_query_test_pandas import ricercalemmiforme\n",
|
|
|
+ "from simple_query_test_pandas import inizialeraddoppiata\n",
|
|
|
+ "from simple_query_test_pandas import interpreter\n",
|
|
|
+ "from test_occorrenzario_pandas import findtexts\n",
|
|
|
+ "from test_occorrenzario_pandas import findcontexts\n",
|
|
|
+ "from test_occorrenzario_pandas import findbib\n",
|
|
|
+ "from test_cooccorrenze import ricerca_cooccorrenze\n",
|
|
|
+ "from test_contesti_singoli import findbib, findcontexts, findlinks, findtexts, singlecontexts, singlefindbib\n",
|
|
|
+ "import warnings\n",
|
|
|
+ "warnings.filterwarnings('ignore')"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "<h1>Funzionamento della funzione ricerca di contesti singoli</h1>\n",
|
|
|
+ "\n",
|
|
|
+ "- visualizzazione dei contesti singoli a partire dalla lista dei contesti multipli\n",
|
|
|
+ "\n",
|
|
|
+ "- visualizzazione delle note e dei testi associati\n",
|
|
|
+ "\n",
|
|
|
+ "- possibilità di personalizzazione dell'ampiezza dei contesti singoli per numero di parole, periodi e brani associati\n",
|
|
|
+ "\n",
|
|
|
+ "- aggiornamento automatico dell'ampiezza dei brani associati, quando si raffina il contesto per parole e periodi"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "<h2>Ricerca di contesti singoli</h2>"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "- ricerca per forme di: filius (primo contesto utile)\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"filius\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type = 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# funzione di ricerca dei contesti singoli, con personalizzazione dell'ampiezza per parole o periodi\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 0, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "ricerca per forme di: tarda (primo contesto utile)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"tarda\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type= 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 0, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "ricerca per forme di: amistade (contesto n. 29)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"amistade\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type= 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 28, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "ricerca per forme di: orgoglia"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"orgoglia\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type= 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 0, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "ricerca per forme di: intradetta"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"intradetta\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type= 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 0, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "a contesto singolo (visualizzazione di 1 periodo)\n",
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"intradetta\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type= 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# visualizzazione di 1 periodo\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 0, 0, 1, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "\n",
|
|
|
+ "ricerca per forme di: pennace"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"pennace\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type= 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 0, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "ricerca per forme di: invitava (interessa solo il primo contesto di Buccio di Ranallo)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "Attenzione: riferimenti organici corretti nella prima immagine; controllare inoltre se c’è un doppio spazio o meno prima di “Quando…” (nel filgat c’è, e andrebbe bene con lo spazio - anche se lo spazio non ci dovrebbe essere)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"invitava\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type= 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 0, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "<h2>Esempi di ricerca di contesti con testi associati (note e trad)</h2>"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "<h3>ricerca per lemmi di: “altresì”</h3>"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "parola = \"altres*\"\n",
|
|
|
+ "path = \"/Users/federicaspinelli/TEAMOVI/Ricerche/db/first_db\"\n",
|
|
|
+ "# tipo di ricerca (0 per forme, 1 per lemmi, 2 per lemmi con opzione \"mostra occorrenze non lemmatizzate\")\n",
|
|
|
+ "type = 0\n",
|
|
|
+ "listOcc = [\"occ00001\", \"occ00002\", \"occ00003\"]\n",
|
|
|
+ "search=ricercaforme(interpreter(parola), path, 0, 0)\n",
|
|
|
+ "textlist=findtexts(type, search, listOcc, path)\n",
|
|
|
+ "contexts = findcontexts(textlist, 30, 0, listOcc, path)\n",
|
|
|
+ "# (textlist, index, parole, periodi, brani, listOcc, path)\n",
|
|
|
+ "context = singlecontexts(contexts, 2, 30, 0, 0, listOcc, path)\n",
|
|
|
+ "links = findlinks(context, path)\n",
|
|
|
+ "bibliocontext = singlefindbib(links, path)\n",
|
|
|
+ "dtale.show(bibliocontext)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "Visualizzazione del secondo brano secondo le stesse modalità. \n",
|
|
|
+ "\n",
|
|
|
+ "Attenzione: in questo caso al contesto sono associati un file note e un file trad e devono essere visualizzati entrambi."
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "attachments": {},
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "\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.9.0"
|
|
|
+ },
|
|
|
+ "vscode": {
|
|
|
+ "interpreter": {
|
|
|
+ "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "nbformat": 4,
|
|
|
+ "nbformat_minor": 2
|
|
|
+}
|