Mattral commited on
Commit
5f6939a
·
verified ·
1 Parent(s): 5a30ab4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -62,7 +62,7 @@ def find_exact_matches(df1, df2, column_name):
62
  return matches
63
 
64
 
65
- def find_similar_texts(df1, df2, column_name, exact_matches, threshold=0.5):
66
  # Find rows with similar texts in the specified column, excluding exact matches
67
  similar_texts = []
68
  exact_match_indices = set(exact_matches.index.tolist())
@@ -116,22 +116,24 @@ def main():
116
  warehouse_column = st.selectbox("Choose column from warehouse item stocks:", warehouse_columns)
117
  industry_column = st.selectbox("Choose column from industry item stocks:", industry_columns)
118
 
119
- # Find exact matches
120
- exact_matches = find_exact_matches(warehouse_df, industry_df, warehouse_column)
 
 
121
 
122
- # Find similar texts
123
- similar_texts = find_similar_texts(warehouse_df, industry_df, warehouse_column, exact_matches)
124
 
125
- # Display results
126
- st.header("Exact Matches")
127
- st.write(exact_matches)
128
 
129
- st.header("Similar Texts")
130
- for text_pair in similar_texts:
131
- st.write(f"Row {text_pair[0]} in warehouse item stocks is similar to Row {text_pair[1]} in industry item stocks:")
132
- st.write(f"Warehouse: {text_pair[2]}")
133
- st.write(f"Industry: {text_pair[3]}")
134
- st.write("")
135
 
136
  if __name__ == "__main__":
137
  main()
 
62
  return matches
63
 
64
 
65
+ def find_similar_texts(df1, df2, column_name, exact_matches, threshold=0.3):
66
  # Find rows with similar texts in the specified column, excluding exact matches
67
  similar_texts = []
68
  exact_match_indices = set(exact_matches.index.tolist())
 
116
  warehouse_column = st.selectbox("Choose column from warehouse item stocks:", warehouse_columns)
117
  industry_column = st.selectbox("Choose column from industry item stocks:", industry_columns)
118
 
119
+ # Compare button
120
+ if st.button("Compare"):
121
+ # Find exact matches
122
+ exact_matches = find_exact_matches(warehouse_df, industry_df, warehouse_column)
123
 
124
+ # Find similar texts
125
+ similar_texts = find_similar_texts(warehouse_df, industry_df, warehouse_column, exact_matches)
126
 
127
+ # Display results
128
+ st.header("Exact Matches")
129
+ st.write(exact_matches)
130
 
131
+ st.header("Similar Texts")
132
+ for text_pair in similar_texts:
133
+ st.write(f"Row {text_pair[0]} in warehouse item stocks is similar to Row {text_pair[1]} in industry item stocks:")
134
+ st.write(f"Warehouse: {text_pair[2]}")
135
+ st.write(f"Industry: {text_pair[3]}")
136
+ st.write("")
137
 
138
  if __name__ == "__main__":
139
  main()