|
@@ -10,6 +10,7 @@ import re
|
|
|
import pandas as pd
|
|
|
import dtale
|
|
|
import unicodedata
|
|
|
+import sys
|
|
|
|
|
|
|
|
|
|
|
@@ -47,9 +48,10 @@ def list_normalize(lista):
|
|
|
|
|
|
|
|
|
def counter (results):
|
|
|
- trovati= len(results.index)
|
|
|
- occorrenze= results['occ'].sum()
|
|
|
- return ("Trovati=" + str(trovati) + " Occorrenze=" + str(occorrenze))
|
|
|
+ if not results.empty:
|
|
|
+ trovati= len(results.index)
|
|
|
+ occorrenze= results['occ'].sum()
|
|
|
+ return ("Trovati=" + str(trovati) + " Occorrenze=" + str(occorrenze))
|
|
|
|
|
|
|
|
|
|
|
@@ -65,7 +67,11 @@ def ricercaforme (entries, path, espansa, raddoppiata):
|
|
|
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
|
|
|
else:
|
|
|
|
|
@@ -81,7 +87,11 @@ def ricercaforme (entries, path, espansa, raddoppiata):
|
|
|
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
|
|
|
"""if espansa == 0:
|
|
|
|
|
@@ -125,7 +135,11 @@ def ricercalemmi (entries, path, espansa, raddoppiata):
|
|
|
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
|
|
|
else:
|
|
|
data = " OR spec LIKE ".join(entries)
|
|
@@ -140,7 +154,11 @@ def ricercalemmi (entries, path, espansa, raddoppiata):
|
|
|
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
|
|
|
"""if espansa == 0:
|
|
|
|
|
@@ -182,7 +200,11 @@ def ricercaformelemmi (entries, path, espansa, raddoppiata):
|
|
|
theSimpleQuery = f"SELECT form.spec AS forma, lem.spec AS lemma, lem.cat AS cat_gr, lem.omo AS disambiguatore, pfl.nocc AS occ, form.cod FROM pfl INNER JOIN form ON form.cod = pfl.forma INNER JOIN lem ON lem.cod = pfl.lemma WHERE form.spec LIKE {data} ORDER BY form.idfor"
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
else:
|
|
|
data = " OR form.spec LIKE ".join(entries)
|
|
|
data_norm = " OR form.norm LIKE ".join(list_normalize(entries))
|
|
@@ -194,7 +216,11 @@ def ricercaformelemmi (entries, path, espansa, raddoppiata):
|
|
|
theSimpleQuery = f"SELECT DISTINCT form.spec AS forma, lem.spec AS lemma, lem.cat AS cat_gr, lem.omo AS disambiguatore, pfl.nocc AS occ, form.cod FROM pfl INNER JOIN form ON form.cod = pfl.forma INNER JOIN lem ON lem.cod = pfl.lemma WHERE (form.spec LIKE {data}) OR (form.norm LIKE {data_norm}) ORDER BY form.idfor"
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
|
|
|
"""if espansa == 0:
|
|
|
|
|
@@ -237,7 +263,11 @@ def ricercalemmiforme (entries, path, espansa, raddoppiata):
|
|
|
theSimpleQuery = f"SELECT lem.spec AS lemma, lem.cat AS cat_gr, form.spec AS forma, lem.omo AS disambiguatore, pfl.nocc AS occ, lem.cod FROM pfl INNER JOIN form ON form.cod = pfl.forma INNER JOIN lem ON lem.cod != 0 AND lem.cod = pfl.lemma WHERE lem.spec LIKE {data} ORDER BY lem.idlem"
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
else:
|
|
|
data = " OR lem.spec LIKE ".join(entries)
|
|
|
data_norm = " OR lem.norm LIKE ".join(list_normalize(entries))
|
|
@@ -249,7 +279,11 @@ def ricercalemmiforme (entries, path, espansa, raddoppiata):
|
|
|
theSimpleQuery = f"SELECT DISTINCT lem.spec AS lemma, lem.cat AS cat_gr, form.spec AS forma, lem.omo AS disambiguatore, pfl.nocc AS occ, lem.cod FROM pfl INNER JOIN form ON form.cod = pfl.forma INNER JOIN lem ON lem.cod = pfl.lemma WHERE (lem.spec LIKE {data}) OR (lem.norm LIKE {data_norm}) ORDER BY lem.idlem"
|
|
|
con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
- return answer_table
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
|
|
|
"""if espansa == 0:
|
|
|
|
|
@@ -281,10 +315,23 @@ def ricercalemmiforme (entries, path, espansa, raddoppiata):
|
|
|
answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
return answer_table"""
|
|
|
|
|
|
+
|
|
|
+def ricercacatgr (entry, path):
|
|
|
+ theSimpleQuery = f"SELECT spec AS lemma, cat AS cat_gr, omo AS disambiguatore, nocc AS occ, cod FROM lem WHERE cat = '{entry}' ORDER BY idlem"
|
|
|
+ con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
+ answer_table = pd.read_sql(theSimpleQuery, con)
|
|
|
+ if answer_table.empty:
|
|
|
+ print ("Nessun risultato")
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ return answer_table
|
|
|
+
|
|
|
|
|
|
-entry = "proferire*"
|
|
|
-print ("Ricerca di: " + entry)
|
|
|
-df=ricercalemmiforme(interpreter(entry), "/Users/leonardocanova/Library/CloudStorage/OneDrive-ConsiglioNazionaledelleRicerche/TIGRO/Ricerche/flask_be", 0, 0)
|
|
|
+path = "/Users/leonardocanova/Library/CloudStorage/OneDrive-ConsiglioNazionaledelleRicerche/TIGRO/Ricerche/flask_be"
|
|
|
+entry = "agg."
|
|
|
+df=ricercacatgr(entry, path)
|
|
|
+
|
|
|
print (counter(df))
|
|
|
dtale.show(df)
|
|
|
|
|
|
+
|