simple_query_test_pandas.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. # Questo NON è parte del codice: è un notebook Jupyter (nell'implementazione di VSCode)
  2. # che ho usato per fare dei test!
  3. # %%
  4. # Test code using Jupyter
  5. # %%
  6. import sqlite3
  7. import re
  8. import pandas as pd
  9. import dtale
  10. import unicodedata
  11. import sys
  12. #from test_occorrenzario_pandas import findtexts, get_tables_occ
  13. from test_sottocorpora import definiscisottocorpus
  14. def get_tables_occ(path):
  15. conn = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  16. cursor = conn.cursor()
  17. cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
  18. table_names = cursor.fetchall()
  19. occ_tables = [table[0] for table in table_names if table[0].startswith('Occ')]
  20. cursor.close()
  21. conn.close()
  22. return occ_tables
  23. #%% ha in input le funzioni di ricerca, cerca nell'occorrenziario i puntatori ai contesti e altri elementi ad essi associati.
  24. #l'attributo type definisce il tipo di ricerca in input (0 per forme, 1 per lemmi o categoria grammaticale, 2 per lemmi con opzione "mostra occorrenze non lemmatizzate")
  25. def findtexts(type, df, listOcc, path, subcorpus=None):
  26. textlist = pd.DataFrame()
  27. codlist = list(df["cod"])
  28. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  29. for table in listOcc:
  30. strlist = ",".join(str(c) for c in codlist)
  31. if type == 0:
  32. Query = f"SELECT tab.cod, tab.indlem, tab.ntx, tab.pitxt, tab.elemlen, tab.mappa, tab.numperiod, tab.links, tab.numorg, intbib.sigla, tab.vol, tab.pag, tab.riga, tab.col, tab.tipostanza, tab.stanza, tab.verso, tab.numbrano, lem.spec AS lemma, lem.cat AS cat_gr, lem.omo AS disambiguatore FROM {table} AS tab INNER JOIN intbib ON tab.ntx = intbib.ntx INNER JOIN lem ON tab.indlem = lem.cod WHERE tab.cod IN ({strlist})"
  33. extendequeryReponse = pd.read_sql(Query, con)
  34. textlist = pd.concat([textlist, extendequeryReponse])
  35. elif type == 1:
  36. Query = f"SELECT tab.cod, tab.indlem, tab.ntx, tab.pitxt, tab.elemlen, tab.mappa, tab.numperiod, tab.links, tab.numorg, intbib.sigla, tab.vol, tab.pag, tab.riga, tab.col, tab.tipostanza, tab.stanza, tab.verso, tab.numbrano, lem.spec AS lemma, lem.cat AS cat_gr, lem.omo AS disambiguatore FROM {table} AS tab INNER JOIN intbib ON tab.ntx = intbib.ntx INNER JOIN lem ON tab.indlem = lem.cod WHERE tab.indlem IN ({strlist})"
  37. extendequeryReponse = pd.read_sql(Query, con)
  38. textlist = pd.concat([textlist, extendequeryReponse])
  39. elif type == 2:
  40. subquery = f"SELECT DISTINCT lemma, forma FROM pfl WHERE lemma IN ({strlist})"
  41. subdf = pd.read_sql(subquery, con)
  42. formcodlist = list(subdf["forma"])
  43. strform = ",".join(str(c) for c in formcodlist)
  44. Query = f"SELECT tab.cod, tab.indlem, tab.ntx, tab.pitxt, tab.elemlen, tab.mappa, tab.numperiod, tab.links, tab.numorg, intbib.sigla, tab.vol, tab.pag, tab.riga, tab.col, tab.tipostanza, tab.stanza, tab.verso, tab.numbrano, lem.spec AS lemma, lem.cat AS cat_gr, lem.omo AS disambiguatore FROM {table} AS tab INNER JOIN intbib ON tab.ntx = intbib.ntx INNER JOIN lem ON tab.indlem = lem.cod WHERE tab.indlem IN ({strlist}) OR (tab.indlem = 0 AND tab.cod IN ({strform}))"
  45. extendequeryReponse = pd.read_sql(Query, con)
  46. textlist = pd.concat([textlist, extendequeryReponse])
  47. if subcorpus is not None:
  48. filter = textlist['sigla'].isin(subcorpus)
  49. textlist = textlist[filter]
  50. return textlist
  51. #%% funzione combinazioni <> è chiamata da interpreter
  52. def combinations(s):
  53. result = []
  54. start = s.find("<")
  55. end = s.find(">")
  56. if start == -1 or end == -1:
  57. return [s]
  58. items = s[start + 1:end].split(",")
  59. for item in items:
  60. result.extend([s[:start] + item + rest for rest in combinations(s[end + 1:])])
  61. return result
  62. #%% funzione interprete, sta alla base di ogni ricerca
  63. def interpreter (data):
  64. clean_data= "'"+data.replace("*", "%").replace("?", "_").replace(" ","").replace("'", "''").replace("’", "''") +"'"
  65. return combinations(clean_data)
  66. # %% funzione iniziale raddoppiata, è chiamata dalle funzioni di ricerca con iniziale raddoppiata
  67. def inizialeraddoppiata (data):
  68. doubleddata=[]
  69. for el in data:
  70. if el[1] != "%" and "_":
  71. doubleddata = doubleddata + ["'"+ el[1] + el[1:]]
  72. return doubleddata
  73. # %% funzione normalizza stringa (ricerca espansa), è chiamata dalle funzioni di ricerca espansa
  74. def normalize(stringa):
  75. return unicodedata.normalize('NFKD', stringa).encode('ASCII', 'ignore').decode('utf-8')
  76. def list_normalize(lista):
  77. return [normalize(stringa) for stringa in lista]
  78. # %% funzione counter, può essere chiamata sui risultati delle ricerche per visualizzare le forme/lemmi e il numero di occorrenze individuate
  79. def counter (results):
  80. if not results.empty:
  81. trovati= len(results.index)
  82. occorrenze= results['occ'].sum()
  83. return ("Trovati=" + str(trovati) + " Occorrenze=" + str(occorrenze))
  84. #%% Funzione ricerca per forme
  85. def ricercaforme (entries, path, espansa, raddoppiata, subcorpus=None):
  86. if espansa == 0:
  87. data=" OR spec LIKE ".join(entries)
  88. doubleddata=" OR spec LIKE ".join(inizialeraddoppiata(entries))
  89. if raddoppiata == 1:
  90. theSimpleQuery = f"SELECT spec AS forma, nocc AS occ, cod FROM form WHERE spec LIKE {data} OR spec LIKE {doubleddata} ORDER BY idfor"
  91. else:
  92. theSimpleQuery = f"SELECT spec AS forma, nocc AS occ, cod FROM form WHERE spec LIKE {data} ORDER BY idfor"
  93. else:
  94. data=" OR spec LIKE ".join(entries)
  95. data_norm=" OR norm LIKE ".join(list_normalize(entries))
  96. doubleddata_norm=" OR norm LIKE ".join(list_normalize(inizialeraddoppiata(entries)))
  97. doubleddata=" OR spec LIKE ".join(inizialeraddoppiata(entries))
  98. if raddoppiata == 1:
  99. theSimpleQuery = f"SELECT DISTINCT spec AS forma, nocc AS occ, cod FROM form WHERE (spec LIKE {data}) OR (norm LIKE {data_norm}) OR (spec LIKE {doubleddata}) OR (norm LIKE {doubleddata_norm}) ORDER BY idfor"
  100. else:
  101. theSimpleQuery = f"SELECT DISTINCT spec AS forma, nocc AS occ, cod FROM form WHERE (spec LIKE {data}) OR (norm LIKE {data_norm}) ORDER BY idfor"
  102. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  103. answer_table = pd.read_sql(theSimpleQuery, con)
  104. if answer_table.empty:
  105. print ("Nessun risultato")
  106. sys.exit(1)
  107. else:
  108. if subcorpus == None:
  109. return answer_table
  110. else:
  111. listOcc = get_tables_occ(path)
  112. textlist = findtexts(0, answer_table, listOcc, path, subcorpus)
  113. counts = textlist.groupby('cod').size().reset_index(name='count')
  114. answer_table = pd.merge(answer_table, counts, on='cod', how='left')
  115. answer_table['occ'] = answer_table['count'].fillna(answer_table['occ']).astype(int)
  116. answer_table = answer_table.dropna(subset=['count'])
  117. return answer_table
  118. #%% Funzione ricerca per lemmi
  119. def ricercalemmi (entries, path, espansa, raddoppiata, subcorpus=None):
  120. if espansa == 0:
  121. data = " OR spec LIKE ".join(entries)
  122. doubleddata = " OR spec LIKE ".join(inizialeraddoppiata(entries))
  123. if raddoppiata == 1:
  124. theSimpleQuery = f"SELECT spec AS lemma, cat AS cat_gr, omo AS disambiguatore, nocc AS occ, cod FROM lem WHERE spec LIKE {data} OR spec LIKE {doubleddata} ORDER BY idlem"
  125. else:
  126. theSimpleQuery = f"SELECT spec AS lemma, cat AS cat_gr, omo AS disambiguatore, nocc AS occ, cod FROM lem WHERE spec LIKE {data} ORDER BY idlem"
  127. else:
  128. data = " OR spec LIKE ".join(entries)
  129. data_norm = " OR norm LIKE ".join(list_normalize(entries))
  130. doubleddata_norm = " OR norm LIKE ".join(list_normalize(inizialeraddoppiata(entries)))
  131. doubleddata = " OR spec LIKE ".join(inizialeraddoppiata(entries))
  132. if raddoppiata == 1:
  133. theSimpleQuery = f"SELECT DISTINCT spec AS lemma, cat AS cat_gr, omo AS disambiguatore, nocc AS occ, cod FROM lem WHERE (spec LIKE {data}) OR (norm LIKE {data_norm}) OR (spec LIKE {doubleddata}) OR (norm LIKE {doubleddata_norm}) ORDER BY idlem"
  134. else:
  135. theSimpleQuery = f"SELECT DISTINCT spec AS lemma, cat AS cat_gr, omo AS disambiguatore, nocc AS occ, cod FROM lem WHERE (spec LIKE {data}) OR (norm LIKE {data_norm}) ORDER BY idlem"
  136. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  137. answer_table = pd.read_sql(theSimpleQuery, con)
  138. if answer_table.empty:
  139. print ("Nessun risultato")
  140. sys.exit(1)
  141. else:
  142. if subcorpus == None:
  143. return answer_table
  144. else:
  145. listOcc = get_tables_occ(path)
  146. textlist = findtexts(1, answer_table, listOcc, path, subcorpus)
  147. counts = textlist.groupby('indlem').size().reset_index(name='count')
  148. answer_table = pd.merge(answer_table, counts, left_on='cod', right_on='indlem')
  149. answer_table['occ'] = answer_table['count'].fillna(answer_table['occ']).astype(int)
  150. answer_table = answer_table.dropna(subset=['count'])
  151. return answer_table
  152. #%% Funzione ricerca di forme con vista lemmi
  153. def ricercaformelemmi (entries, path, espansa, raddoppiata):
  154. if espansa == 0:
  155. data = " OR form.spec LIKE ".join(entries)
  156. doubleddata = " OR form.spec LIKE ".join(inizialeraddoppiata(entries))
  157. if raddoppiata == 1:
  158. 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} OR form.spec LIKE {doubleddata} ORDER BY form.idfor"
  159. else:
  160. 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"
  161. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  162. answer_table = pd.read_sql(theSimpleQuery, con)
  163. if answer_table.empty:
  164. print ("Nessun risultato")
  165. sys.exit(1)
  166. else:
  167. return answer_table
  168. else:
  169. data = " OR form.spec LIKE ".join(entries)
  170. data_norm = " OR form.norm LIKE ".join(list_normalize(entries))
  171. doubleddata_norm = " OR form.norm LIKE ".join(list_normalize(inizialeraddoppiata(entries)))
  172. doubleddata = " OR form.spec LIKE ".join(inizialeraddoppiata(entries))
  173. if raddoppiata == 1:
  174. 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}) OR (form.spec LIKE {doubleddata}) OR (form.norm LIKE {doubleddata_norm}) ORDER BY form.idfor"
  175. else:
  176. 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"
  177. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  178. answer_table = pd.read_sql(theSimpleQuery, con)
  179. if answer_table.empty:
  180. print ("Nessun risultato")
  181. sys.exit(1)
  182. else:
  183. return answer_table
  184. #deprecated
  185. """if espansa == 0:
  186. data=" OR form.spec LIKE ".join(entries)
  187. doubleddata=" OR form.spec LIKE ".join(inizialeraddoppiata(entries))
  188. if raddoppiata == 1:
  189. theSimpleQuery = "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 + " OR form.spec LIKE " + doubleddata + " ORDER BY form.idfor"
  190. else:
  191. theSimpleQuery = "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"
  192. con = sqlite3.connect("file:" + path + "/db/test1.db" + "?mode=ro", uri=True)
  193. answer_table = pd.read_sql(theSimpleQuery, con)
  194. return answer_table
  195. else:
  196. data=" OR form.spec LIKE ".join(entries)
  197. data_norm=" OR form.norm LIKE ".join(list_normalize(entries))
  198. doubleddata_norm=" OR form.norm LIKE ".join(list_normalize(inizialeraddoppiata(entries)))
  199. doubleddata=" OR form.spec LIKE ".join(inizialeraddoppiata(entries))
  200. if raddoppiata == 1:
  201. theSimpleQuery = "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 + ") OR (form.spec LIKE " + doubleddata + ") OR (form.norm LIKE " + doubleddata_norm + ")" + " ORDER BY form.idfor"
  202. else:
  203. theSimpleQuery = "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"
  204. con = sqlite3.connect("file:" + path + "/db/test1.db" + "?mode=ro", uri=True)
  205. answer_table = pd.read_sql(theSimpleQuery, con)
  206. return answer_table"""
  207. #%% Funzione ricerca lemmi con vista forme
  208. def ricercalemmiforme (entries, path, espansa, raddoppiata):
  209. if espansa == 0:
  210. data = " OR form.spec LIKE ".join(entries)
  211. doubleddata = " OR form.spec LIKE ".join(inizialeraddoppiata(entries))
  212. if raddoppiata == 1:
  213. 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} OR form.spec LIKE {doubleddata} ORDER BY lem.idlem"
  214. else:
  215. 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"
  216. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  217. answer_table = pd.read_sql(theSimpleQuery, con)
  218. if answer_table.empty:
  219. print ("Nessun risultato")
  220. sys.exit(1)
  221. else:
  222. return answer_table
  223. else:
  224. data = " OR lem.spec LIKE ".join(entries)
  225. data_norm = " OR lem.norm LIKE ".join(list_normalize(entries))
  226. doubleddata_norm = " OR lem.norm LIKE ".join(list_normalize(inizialeraddoppiata(entries)))
  227. doubleddata = " OR lem.spec LIKE ".join(inizialeraddoppiata(entries))
  228. if raddoppiata == 1:
  229. 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}) OR (lem.spec LIKE {doubleddata}) OR (lem.norm LIKE {doubleddata_norm}) ORDER BY lem.idlem"
  230. else:
  231. 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"
  232. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  233. answer_table = pd.read_sql(theSimpleQuery, con)
  234. if answer_table.empty:
  235. print ("Nessun risultato")
  236. sys.exit(1)
  237. else:
  238. return answer_table
  239. #deprecated
  240. """if espansa == 0:
  241. data=" OR form.spec LIKE ".join(entries)
  242. doubleddata=" OR form.spec LIKE ".join(inizialeraddoppiata(entries))
  243. if raddoppiata == 1:
  244. theSimpleQuery = "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 + " OR form.spec LIKE " + doubleddata + " ORDER BY lem.idlem"
  245. else:
  246. theSimpleQuery = "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"
  247. con = sqlite3.connect("file:" + path + "/db/test1.db" + "?mode=ro", uri=True)
  248. answer_table = pd.read_sql(theSimpleQuery, con)
  249. return answer_table
  250. else:
  251. data=" OR lem.spec LIKE ".join(entries)
  252. data_norm=" OR lem.norm LIKE ".join(list_normalize(entries))
  253. doubleddata_norm=" OR lem.norm LIKE ".join(list_normalize(inizialeraddoppiata(entries)))
  254. doubleddata=" OR lem.spec LIKE ".join(inizialeraddoppiata(entries))
  255. if raddoppiata == 1:
  256. theSimpleQuery = "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 + ") OR (lem.spec LIKE " + doubleddata + ") OR (lem.norm LIKE " + doubleddata_norm + ")" + " ORDER BY lem.idlem"
  257. else:
  258. theSimpleQuery = "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"
  259. con = sqlite3.connect("file:" + path + "/db/test1.db" + "?mode=ro", uri=True)
  260. answer_table = pd.read_sql(theSimpleQuery, con)
  261. return answer_table"""
  262. # %% Ricerca per categorie grammaticali
  263. def ricercacatgr (entry, path):
  264. 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"
  265. con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
  266. answer_table = pd.read_sql(theSimpleQuery, con)
  267. if answer_table.empty:
  268. print ("Nessun risultato")
  269. sys.exit(1)
  270. else:
  271. return answer_table
  272. #%%
  273. path = "/Users/leonardocanova/Library/CloudStorage/OneDrive-ConsiglioNazionaledelleRicerche/TIGRO/Ricerche/db/first_db"
  274. entry = "come"
  275. conditions = {"IQ": "TS", "[Titolo Abbreviato]": ["Simintendi, a. 1333 (prat.)"]}
  276. conditions2 = {"[Autore]": ["Dante Alighieri", "Boccaccio, Giovanni"]}
  277. chronoconditions = {"[Anno iniziale]": 1320, "[Anno finale]": 1375}
  278. subcorpus = definiscisottocorpus(path,"datibib", conditions)
  279. print(subcorpus)
  280. #df=ricercacatgr(entry, path)
  281. df=ricercalemmi(interpreter(entry), path, 0, 0, subcorpus)
  282. dtale.show(df)
  283. # %%