|
@@ -39,19 +39,19 @@ def ricerca_cooccorrenze (listaricerche, intervallo, periodo, ordinate, path):
|
|
|
for index1, row1 in listatesti.iterrows():
|
|
|
for index2, row2 in textlist.iterrows():
|
|
|
if ordinate == 0:
|
|
|
- if row1['ntx'] == row2['ntx'] and (row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and ((row1['mappa'] - row2['mappa']) != 0) and ((row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo)):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
elif ordinate == 1:
|
|
|
- if row1['ntx'] == row2['ntx'] and (row1['mappa'] - row2['mappa']) in range(intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and ((row2['mappa'] - row1['mappa']) > 0) and ((row2['mappa'] - row1['mappa']) <= intervallo):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
elif periodo == 1:
|
|
|
for index1, row1 in listatesti.iterrows():
|
|
|
for index2, row2 in textlist.iterrows():
|
|
|
if ordinate == 0:
|
|
|
- if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and (row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and ((row1['mappa'] - row2['mappa']) != 0) and ((row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo)):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
elif ordinate == 1:
|
|
|
- if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and (row1['mappa'] - row2['mappa']) in range(intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and ((row2['mappa'] - row1['mappa']) > 0) and ((row2['mappa'] - row1['mappa']) <= intervallo):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
listatesti = df_new
|
|
|
elif tipo == "1":
|
|
@@ -62,19 +62,19 @@ def ricerca_cooccorrenze (listaricerche, intervallo, periodo, ordinate, path):
|
|
|
for index1, row1 in listatesti.iterrows():
|
|
|
for index2, row2 in textlist.iterrows():
|
|
|
if ordinate == 0:
|
|
|
- if row1['ntx'] == row2['ntx'] and (row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and ((row1['mappa'] - row2['mappa']) != 0) and ((row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo)):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
if ordinate == 1:
|
|
|
- if row1['ntx'] == row2['ntx'] and (row1['mappa'] - row2['mappa']) in range(intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and ((row2['mappa'] - row1['mappa']) > 0) and ((row2['mappa'] - row1['mappa']) <= intervallo):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
elif periodo == 1:
|
|
|
for index1, row1 in listatesti.iterrows():
|
|
|
for index2, row2 in textlist.iterrows():
|
|
|
if ordinate == 0:
|
|
|
- if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and (row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and ((row1['mappa'] - row2['mappa']) != 0) and ((row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo)):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
if ordinate == 1:
|
|
|
- if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and (row1['mappa'] - row2['mappa']) in range(intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and ((row2['mappa'] - row1['mappa']) > 0) and ((row2['mappa'] - row1['mappa']) <= intervallo):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
listatesti = df_new
|
|
|
elif tipo == "2":
|
|
@@ -85,30 +85,30 @@ def ricerca_cooccorrenze (listaricerche, intervallo, periodo, ordinate, path):
|
|
|
for index1, row1 in listatesti.iterrows():
|
|
|
for index2, row2 in textlist.iterrows():
|
|
|
if ordinate == 0:
|
|
|
- if row1['ntx'] == row2['ntx'] and (row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and ((row1['mappa'] - row2['mappa']) != 0) and ((row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo)):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
if ordinate == 1:
|
|
|
- if row1['ntx'] == row2['ntx'] and (row1['mappa'] - row2['mappa']) in range(intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and ((row2['mappa'] - row1['mappa']) > 0) and ((row2['mappa'] - row1['mappa']) <= intervallo):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
elif periodo == 1:
|
|
|
for index1, row1 in listatesti.iterrows():
|
|
|
for index2, row2 in textlist.iterrows():
|
|
|
if ordinate == 0:
|
|
|
- if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and (row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and ((row1['mappa'] - row2['mappa']) != 0) and ((row1['mappa'] - row2['mappa']) in range(-intervallo,intervallo)):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
if ordinate == 1:
|
|
|
- if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and (row1['mappa'] - row2['mappa']) in range(intervallo):
|
|
|
+ if row1['ntx'] == row2['ntx'] and row1['numperiod'] == row2['numperiod'] and ((row2['mappa'] - row1['mappa']) > 0) and ((row2['mappa'] - row1['mappa']) <= intervallo):
|
|
|
df_new = pd.concat([df_new, row1.to_frame().T])
|
|
|
listatesti = df_new
|
|
|
contexts = findcontexts(listatesti, 30, 0, listOcc, path)
|
|
|
bibliocontexts = findbib(contexts, path)
|
|
|
- clean = bibliocontexts.drop_duplicates()
|
|
|
+ clean = bibliocontexts.drop_duplicates(subset="contesto")
|
|
|
return clean
|
|
|
|
|
|
|
|
|
|
|
|
-ricerca = [["mezzo", "2", 1, 0], ["gent*", "0", 0, 0]]
|
|
|
-cooccorrenze = ricerca_cooccorrenze(ricerca, 10, 1, 1, "../")
|
|
|
+ricerca = [["dovere", "1", 0, 0], ["avere", "1", 0, 0]]
|
|
|
+cooccorrenze = ricerca_cooccorrenze(ricerca, 1, 1, 1, "/Users/leonardocanova/Library/CloudStorage/OneDrive-ConsiglioNazionaledelleRicerche/TIGRO/Ricerche/flask_be/")
|
|
|
dtale.show(cooccorrenze)
|
|
|
-
|
|
|
|
|
|
+
|