Mattral commited on
Commit
c387786
·
verified ·
1 Parent(s): 413670f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -62,7 +62,7 @@ def find_exact_match(df1, df2, column_name):
62
  return matches
63
 
64
 
65
- def find_similar_texts(df1, df2, column_name, threshold=0.4):
66
  # Find rows with similar texts in the specified column, excluding exact matches
67
  similar_texts = []
68
  exact_matches = []
@@ -91,9 +91,9 @@ def find_similar_texts(df1, df2, column_name, threshold=0.4):
91
  max_length = max(len(row1[column_name]), len(row2[column_name]))
92
  similarity_score = 1 - (distance / max_length)
93
  if similarity_score >= threshold:
94
- if similarity == 1: # Exact match
95
  exact_matches.append((i, j, row1[column_name], row2[column_name]))
96
- else: # Similar but not the same
97
  similar_texts.append((i, j, row1[column_name], row2[column_name]))
98
 
99
  return similar_texts, exact_matches
@@ -101,6 +101,7 @@ def find_similar_texts(df1, df2, column_name, threshold=0.4):
101
 
102
 
103
 
 
104
  def main():
105
  st.title("Item Comparison App")
106
 
@@ -122,7 +123,7 @@ def main():
122
  st.header("Select Columns")
123
  warehouse_column = st.selectbox("Choose column from warehouse item stocks:", warehouse_columns)
124
  industry_column = st.selectbox("Choose column from industry item stocks:", industry_columns)
125
-
126
  # Compare button
127
  if st.button("Compare"):
128
  # Find exact matches
 
62
  return matches
63
 
64
 
65
+ def find_similar_texts(df1, df2, column_name, threshold=0.5):
66
  # Find rows with similar texts in the specified column, excluding exact matches
67
  similar_texts = []
68
  exact_matches = []
 
91
  max_length = max(len(row1[column_name]), len(row2[column_name]))
92
  similarity_score = 1 - (distance / max_length)
93
  if similarity_score >= threshold:
94
+ if similarity >= threshold and similarity < 1: # Exact match
95
  exact_matches.append((i, j, row1[column_name], row2[column_name]))
96
+ elif similarity > threshold: # Similar but not the same
97
  similar_texts.append((i, j, row1[column_name], row2[column_name]))
98
 
99
  return similar_texts, exact_matches
 
101
 
102
 
103
 
104
+
105
  def main():
106
  st.title("Item Comparison App")
107
 
 
123
  st.header("Select Columns")
124
  warehouse_column = st.selectbox("Choose column from warehouse item stocks:", warehouse_columns)
125
  industry_column = st.selectbox("Choose column from industry item stocks:", industry_columns)
126
+
127
  # Compare button
128
  if st.button("Compare"):
129
  # Find exact matches