Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,7 @@ def find_similar(vector_representation, all_representations, threshold=0.5):
|
|
| 18 |
|
| 19 |
# Find indices where similarity is above the threshold
|
| 20 |
similar_indices = np.where(similarities > threshold)[0]
|
|
|
|
| 21 |
|
| 22 |
return similar_indices.tolist()
|
| 23 |
|
|
@@ -31,9 +32,9 @@ def process_pdf(doc, diff_line):
|
|
| 31 |
for line in block["lines"]:
|
| 32 |
temp = []
|
| 33 |
data_page.append(page_num)
|
| 34 |
-
data_geom.append(line["
|
| 35 |
for word in line["words"]:
|
| 36 |
-
temp.append(word["
|
| 37 |
data_word.append(" ".join(temp))
|
| 38 |
|
| 39 |
data = {
|
|
@@ -47,8 +48,8 @@ def process_pdf(doc, diff_line):
|
|
| 47 |
y1_coor = []
|
| 48 |
y2_coor = []
|
| 49 |
for pos in df["posisi"]:
|
| 50 |
-
y1_coor.append(pos[1])
|
| 51 |
-
y2_coor.append(pos[
|
| 52 |
|
| 53 |
df["y1_coor"] = y1_coor
|
| 54 |
df["y2_coor"] = y2_coor
|
|
@@ -61,7 +62,7 @@ def process_pdf(doc, diff_line):
|
|
| 61 |
merge_y2 = []
|
| 62 |
merge_halaman = []
|
| 63 |
|
| 64 |
-
for i in range(df.shape[0]):
|
| 65 |
if i == 0:
|
| 66 |
temp_y2 = df["y2_coor"].iloc[i]
|
| 67 |
temp_y1 = df["y1_coor"].iloc[i]
|
|
|
|
| 18 |
|
| 19 |
# Find indices where similarity is above the threshold
|
| 20 |
similar_indices = np.where(similarities > threshold)[0]
|
| 21 |
+
sorted_indices = sorted(similar_indices, key=lambda i: similarities[i], reverse=True)
|
| 22 |
|
| 23 |
return similar_indices.tolist()
|
| 24 |
|
|
|
|
| 32 |
for line in block["lines"]:
|
| 33 |
temp = []
|
| 34 |
data_page.append(page_num)
|
| 35 |
+
data_geom.append(line["geometry"])
|
| 36 |
for word in line["words"]:
|
| 37 |
+
temp.append(word["value"])
|
| 38 |
data_word.append(" ".join(temp))
|
| 39 |
|
| 40 |
data = {
|
|
|
|
| 48 |
y1_coor = []
|
| 49 |
y2_coor = []
|
| 50 |
for pos in df["posisi"]:
|
| 51 |
+
y1_coor.append(pos[0][1])
|
| 52 |
+
y2_coor.append(pos[1][1])
|
| 53 |
|
| 54 |
df["y1_coor"] = y1_coor
|
| 55 |
df["y2_coor"] = y2_coor
|
|
|
|
| 62 |
merge_y2 = []
|
| 63 |
merge_halaman = []
|
| 64 |
|
| 65 |
+
for i in range(0, df.shape[0]):
|
| 66 |
if i == 0:
|
| 67 |
temp_y2 = df["y2_coor"].iloc[i]
|
| 68 |
temp_y1 = df["y1_coor"].iloc[i]
|