|
@@ -11,7 +11,7 @@ def singlecontexts(textlist, index, parole, periodi, brani, listOcc, path):
|
|
|
context = textlist.iloc[index]
|
|
|
contexts = []
|
|
|
formats = []
|
|
|
- con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
+ con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
|
|
|
sigla = textlist.loc[index, "sigla"]
|
|
|
periodlocal = textlist.loc[index, "numperiod"]
|
|
|
ntxlocal = textlist.loc[index, "ntx"]
|
|
@@ -23,11 +23,11 @@ def singlecontexts(textlist, index, parole, periodi, brani, listOcc, path):
|
|
|
query = f"SELECT tab.pitxt, tab.elemlen FROM {table} AS tab WHERE tab.ntx = {ntxlocal} AND tab.mappa <= {mappalocal+int(parole/2)} AND tab.mappa >= {mappalocal-int(parole/2)}"
|
|
|
queryresponse = pd.read_sql(query, con)
|
|
|
pointerlist = pd.concat([pointerlist, queryresponse])
|
|
|
- with open(f"{path}/db/itxt/{sigla}", 'r', encoding="utf-32-le") as file1:
|
|
|
+ with open(f"{path}/itxt/{sigla}", 'r', encoding="utf-32-le") as file1:
|
|
|
file1.seek(4*pointerlist["pitxt"].min())
|
|
|
cont = file1.read(pointerlist["pitxt"].max()-pointerlist["pitxt"].min())
|
|
|
contexts.append(cont)
|
|
|
- with open(f"{path}/db/ftxt/{sigla}", 'rb') as file1:
|
|
|
+ with open(f"{path}/ftxt/{sigla}", 'rb') as file1:
|
|
|
file1.seek(pointerlist["pitxt"].min()-1)
|
|
|
formBytes = file1.read(pointerlist["pitxt"].max()-pointerlist["pitxt"].min())
|
|
|
form = [byte for byte in formBytes]
|
|
@@ -37,7 +37,7 @@ def singlecontexts(textlist, index, parole, periodi, brani, listOcc, path):
|
|
|
elif periodi != 0:
|
|
|
query = f"SELECT piniz, pfin FROM periodi WHERE ntx = {ntxlocal} AND numperiod <= {periodlocal+int(periodi/2)} AND numperiod >= {periodlocal-int(periodi/2)}"
|
|
|
queryresponse = pd.read_sql(query, con)
|
|
|
- with open(f"{path}/db/itxt/{sigla}", 'r', encoding="utf-32-le") as file1:
|
|
|
+ with open(f"{path}/itxt/{sigla}", 'r', encoding="utf-32-le") as file1:
|
|
|
file1.seek(4*queryresponse["piniz"].min())
|
|
|
cont = file1.read(queryresponse["pfin"].max()-queryresponse["piniz"].min())
|
|
|
contexts.append(cont)
|
|
@@ -50,7 +50,7 @@ def singlecontexts(textlist, index, parole, periodi, brani, listOcc, path):
|
|
|
numbranolocal = textlist.loc[index, "numbrano"]
|
|
|
query = f"SELECT piniz, pfin FROM linkbase WHERE {ntxlocal} = ntx AND tipo = 2 AND id BETWEEN {numbranolocal-int(brani/2)} AND {numbranolocal+int(brani/2)}"
|
|
|
queryresponse = pd.read_sql(query, con)
|
|
|
- with open(f"{path}/db/itxt/{sigla}", 'r', encoding="utf-32-le") as file1:
|
|
|
+ with open(f"{path}/itxt/{sigla}", 'r', encoding="utf-32-le") as file1:
|
|
|
file1.seek(4*queryresponse["piniz"].min())
|
|
|
cont = file1.read(queryresponse["pfin"].max()-queryresponse["piniz"].min())
|
|
|
contexts.append(cont)
|
|
@@ -63,7 +63,7 @@ def singlecontexts(textlist, index, parole, periodi, brani, listOcc, path):
|
|
|
|
|
|
|
|
|
def findlinks (context, path):
|
|
|
- con = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
+ con = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
|
|
|
linkslocal = context.loc[0, "links"]
|
|
|
siglalocal = context.loc[0, "sigla"]
|
|
|
ntxlocal = context.loc[0, "ntx"]
|
|
@@ -75,7 +75,7 @@ def findlinks (context, path):
|
|
|
if linkslocal == 1:
|
|
|
query = f"SELECT ta.ntx, ta.id, ta.piniz, ta.pfin, tb.mappain, tb.mappafin FROM linkbase AS tb INNER JOIN linknoteass AS ta ON tb.ntx = ta.ntx AND tb.id = ta.id WHERE (((tb.tipo= 1) AND (tb.ntx = {ntxlocal})) AND ((tb.piniz BETWEEN {pinizlocal} AND {pfinlocal}) OR ({pitxtlocal} BETWEEN tb.piniz AND tb.pfin)))"
|
|
|
queryresponse = pd.read_sql(query, con)
|
|
|
- with open(f"{path}/db/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file1:
|
|
|
+ with open(f"{path}/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file1:
|
|
|
file1.seek(4*queryresponse["piniz"].min())
|
|
|
cont = file1.read(queryresponse["pfin"].max()-queryresponse["piniz"].min()-1)
|
|
|
context['nota'] = cont
|
|
@@ -83,20 +83,20 @@ def findlinks (context, path):
|
|
|
if linkslocal == 2:
|
|
|
query = f"SELECT ta.ntx, ta.id, ta.piniz, ta.pfin, tb.mappain, tb.mappafin FROM linkbase AS tb INNER JOIN linknoteass AS ta ON tb.ntx = ta.ntx AND tb.id = ta.id WHERE (((tb.tipo= 2) AND (tb.ntx = {ntxlocal})) AND ((tb.piniz BETWEEN {pinizlocal} AND {pfinlocal}) OR ({pitxtlocal} BETWEEN tb.piniz AND tb.pfin)))"
|
|
|
queryresponse = pd.read_sql(query, con)
|
|
|
- with open(f"{path}/db/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file1:
|
|
|
+ with open(f"{path}/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file1:
|
|
|
file1.seek(4*queryresponse["piniz"].min())
|
|
|
cont = file1.read(queryresponse["pfin"].max()-queryresponse["piniz"].min()-1)
|
|
|
context['testo associato'] = cont
|
|
|
if linkslocal == 3:
|
|
|
query = f"SELECT ta.ntx, ta.id, ta.piniz, ta.pfin, tb.piniz AS iniz, tb.pfin AS fin, tb.mappain, tb.mappafin FROM linkbase AS tb INNER JOIN linknoteass AS ta ON tb.ntx = ta.ntx AND tb.id = ta.id WHERE (((tb.tipo= 1) AND (tb.ntx = {ntxlocal})) AND ((tb.piniz BETWEEN {pinizlocal} AND {pfinlocal}) OR ({pitxtlocal} BETWEEN tb.piniz AND tb.pfin)))"
|
|
|
queryresponse = pd.read_sql(query, con)
|
|
|
- with open(f"{path}/db/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file1:
|
|
|
+ with open(f"{path}/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file1:
|
|
|
file1.seek(4*queryresponse["piniz"].min())
|
|
|
cont = file1.read(queryresponse["pfin"].max()-queryresponse["piniz"].min()-1)
|
|
|
context['nota'] = cont
|
|
|
query2 = f"SELECT ta.ntx, ta.id, ta.piniz, ta.pfin, tb.piniz AS iniz, tb.pfin AS fin, tb.mappain, tb.mappafin FROM linkbase AS tb INNER JOIN linknoteass AS ta ON tb.ntx = ta.ntx AND tb.id = ta.id WHERE (((tb.tipo= 2) AND (tb.ntx = {ntxlocal})) AND ((tb.piniz BETWEEN {pinizlocal} AND {pfinlocal}) OR ({pitxtlocal} BETWEEN tb.piniz AND tb.pfin)))"
|
|
|
queryresponse2 = pd.read_sql(query2, con)
|
|
|
- with open(f"{path}/db/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file2:
|
|
|
+ with open(f"{path}/itxt/{siglalocal}", 'r', encoding="utf-32-le") as file2:
|
|
|
file2.seek(4*queryresponse2["piniz"].min())
|
|
|
cont2 = file2.read(queryresponse2["pfin"].max()-queryresponse2["piniz"].min()-1)
|
|
|
context['testo associato'] = cont2
|
|
@@ -107,11 +107,11 @@ def singlefindbib(contexts, path):
|
|
|
infobib = pd.DataFrame()
|
|
|
rif_org = pd.DataFrame()
|
|
|
for ind, row in contexts.iterrows():
|
|
|
- con = sqlite3.connect(f"file:{path}/db/bibliografia/BiblioTLIO.db?mode=ro", uri=True)
|
|
|
+ con = sqlite3.connect(f"file:{path}/bibliografia/BiblioTLIO.db?mode=ro", uri=True)
|
|
|
Query = f"SELECT [Anno iniziale], [Titolo Abbreviato], IQ FROM datibib WHERE Sigla='{row['sigla']}'"
|
|
|
bib = pd.read_sql(Query, con)
|
|
|
infobib = pd.concat([infobib, bib])
|
|
|
- con2 = sqlite3.connect(f"file:{path}/db/test1.db?mode=ro", uri=True)
|
|
|
+ con2 = sqlite3.connect(f"file:{path}/test1.db?mode=ro", uri=True)
|
|
|
Query2 = f"SELECT head AS Rif_organico, full AS Rif_completo FROM org WHERE (indice='{row['numorg']}' AND ntx='{row['ntx']}')"
|
|
|
rif = pd.read_sql(Query2, con2)
|
|
|
rif_org = pd.concat([rif_org, rif])
|
|
@@ -142,7 +142,7 @@ def singlefindbib(contexts, path):
|
|
|
|
|
|
|
|
|
parola = "filius"
|
|
|
-path = "/Users/leonardocanova/Library/CloudStorage/OneDrive-ConsiglioNazionaledelleRicerche/TIGRO/Ricerche/flask_be"
|
|
|
+path = "/Users/leonardocanova/Library/CloudStorage/OneDrive-ConsiglioNazionaledelleRicerche/TIGRO/Ricerche/db/first_db"
|
|
|
|
|
|
type= 0
|
|
|
listOcc = ["occ00001", "occ00002", "occ00003"]
|