Update app.py
Browse files
app.py
CHANGED
@@ -45,17 +45,17 @@ def score(main_product, main_url, product_count, link_count, search, logger, log
|
|
45 |
data = {}
|
46 |
similar_products = extract_similar_products(main_product)[:product_count]
|
47 |
|
48 |
-
if search == '
|
49 |
|
50 |
def process_product(product, search_function, main_product):
|
51 |
search_result = search_function(product)
|
52 |
-
return filtering(search_result, main_product, product)
|
53 |
|
54 |
|
55 |
search_functions = {
|
56 |
'google': search_google,
|
57 |
'duckduckgo': search_duckduckgo,
|
58 |
-
'archive': search_archive,
|
59 |
'github': search_github,
|
60 |
'wikipedia': search_wikipedia
|
61 |
}
|
@@ -81,26 +81,20 @@ def score(main_product, main_url, product_count, link_count, search, logger, log
|
|
81 |
for product in similar_products:
|
82 |
|
83 |
if search == 'google':
|
84 |
-
data[product] = filtering(search_google(product), main_product, product)
|
85 |
elif search == 'duckduckgo':
|
86 |
-
data[product] = filtering(search_duckduckgo(product), main_product, product)
|
87 |
elif search == 'archive':
|
88 |
-
data[product] = filtering(search_archive(product), main_product, product)
|
89 |
elif search == 'github':
|
90 |
-
data[product] = filtering(search_github(product), main_product, product)
|
91 |
elif search == 'wikipedia':
|
92 |
-
data[product] = filtering(search_wikipedia(product), main_product, product)
|
93 |
|
94 |
logger.write("\n\nFiltered Links ------------------>\n")
|
95 |
logger.write(str(data) + "\n")
|
96 |
log_area.text(logger.getvalue())
|
97 |
|
98 |
-
if len(data[product]) == 0:
|
99 |
-
logger.write("\n\nNo Product links Found Increase No of Links or Change Search Source\n")
|
100 |
-
log_area.text(logger.getvalue())
|
101 |
-
|
102 |
-
return [[product,'No Product links Found Increase Number of Links or Change Search Source',0,0]], False
|
103 |
-
|
104 |
logger.write("\n\nCreating Main product Embeddings ---------->\n")
|
105 |
main_result, main_embedding = get_embeddings(main_url,tag_option)
|
106 |
log_area.text(logger.getvalue())
|
@@ -119,7 +113,7 @@ def score(main_product, main_url, product_count, link_count, search, logger, log
|
|
119 |
logger.write("\n\nNo Product links Found Increase No of Links or Change Search Source\n")
|
120 |
log_area.text(logger.getvalue())
|
121 |
|
122 |
-
cosine_sim_scores.append((product,'No Product links Found Increase Number of Links or Change Search Source',
|
123 |
|
124 |
else:
|
125 |
for link in data[product][:link_count]:
|
@@ -144,7 +138,7 @@ st.title("Check Infringement")
|
|
144 |
# Inputs
|
145 |
main_product = st.text_input('Enter Main Product Name', 'Philips led 7w bulb')
|
146 |
main_url = st.text_input('Enter Main Product Manual URL', 'https://www.assets.signify.com/is/content/PhilipsConsumer/PDFDownloads/Colombia/technical-sheets/ODLI20180227_001-UPD-es_CO-Ficha_Tecnica_LED_MR16_Master_7W_Dim_12V_CRI90.pdf')
|
147 |
-
search_method = st.selectbox('Choose Search Engine', ['duckduckgo', 'google', 'archive', 'github', 'wikipedia'
|
148 |
|
149 |
col1, col2 = st.columns(2)
|
150 |
with col1:
|
@@ -153,7 +147,7 @@ with col2:
|
|
153 |
link_count = st.number_input("Number of Links per product",min_value=1, step=1, format="%i")
|
154 |
|
155 |
|
156 |
-
tag_option = st.selectbox('Choose Similarity Method', ["
|
157 |
|
158 |
|
159 |
if st.button('Check for Infringement'):
|
@@ -168,7 +162,7 @@ if st.button('Check for Infringement'):
|
|
168 |
st.subheader("Cosine Similarity Scores")
|
169 |
|
170 |
# = score(main_product, main_url, search, logger, log_output)
|
171 |
-
if tag_option == '
|
172 |
tags = ['Details']
|
173 |
else:
|
174 |
tags = ['Introduction', 'Specifications', 'Product Overview', 'Safety Information', 'Installation Instructions', 'Setup and Configuration', 'Operation Instructions', 'Maintenance and Care', 'Troubleshooting', 'Warranty Information', 'Legal Information']
|
@@ -176,5 +170,5 @@ if st.button('Check for Infringement'):
|
|
176 |
for product, link, index, value in cosine_sim_scores:
|
177 |
if not index:
|
178 |
st.write(f"Product: {product}, Link: {link}")
|
179 |
-
if
|
180 |
st.write(f"{tags[index]:<20} - Similarity: {value:.2f}")
|
|
|
45 |
data = {}
|
46 |
similar_products = extract_similar_products(main_product)[:product_count]
|
47 |
|
48 |
+
if search == 'All':
|
49 |
|
50 |
def process_product(product, search_function, main_product):
|
51 |
search_result = search_function(product)
|
52 |
+
return filtering(search_result, main_product, product, link_count)
|
53 |
|
54 |
|
55 |
search_functions = {
|
56 |
'google': search_google,
|
57 |
'duckduckgo': search_duckduckgo,
|
58 |
+
# 'archive': search_archive,
|
59 |
'github': search_github,
|
60 |
'wikipedia': search_wikipedia
|
61 |
}
|
|
|
81 |
for product in similar_products:
|
82 |
|
83 |
if search == 'google':
|
84 |
+
data[product] = filtering(search_google(product), main_product, product, link_count)
|
85 |
elif search == 'duckduckgo':
|
86 |
+
data[product] = filtering(search_duckduckgo(product), main_product, product, link_count)
|
87 |
elif search == 'archive':
|
88 |
+
data[product] = filtering(search_archive(product), main_product, product, link_count)
|
89 |
elif search == 'github':
|
90 |
+
data[product] = filtering(search_github(product), main_product, product, link_count)
|
91 |
elif search == 'wikipedia':
|
92 |
+
data[product] = filtering(search_wikipedia(product), main_product, product, link_count)
|
93 |
|
94 |
logger.write("\n\nFiltered Links ------------------>\n")
|
95 |
logger.write(str(data) + "\n")
|
96 |
log_area.text(logger.getvalue())
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
logger.write("\n\nCreating Main product Embeddings ---------->\n")
|
99 |
main_result, main_embedding = get_embeddings(main_url,tag_option)
|
100 |
log_area.text(logger.getvalue())
|
|
|
113 |
logger.write("\n\nNo Product links Found Increase No of Links or Change Search Source\n")
|
114 |
log_area.text(logger.getvalue())
|
115 |
|
116 |
+
cosine_sim_scores.append((product,'No Product links Found Increase Number of Links or Change Search Source',None,None))
|
117 |
|
118 |
else:
|
119 |
for link in data[product][:link_count]:
|
|
|
138 |
# Inputs
|
139 |
main_product = st.text_input('Enter Main Product Name', 'Philips led 7w bulb')
|
140 |
main_url = st.text_input('Enter Main Product Manual URL', 'https://www.assets.signify.com/is/content/PhilipsConsumer/PDFDownloads/Colombia/technical-sheets/ODLI20180227_001-UPD-es_CO-Ficha_Tecnica_LED_MR16_Master_7W_Dim_12V_CRI90.pdf')
|
141 |
+
search_method = st.selectbox('Choose Search Engine', ['All','duckduckgo', 'google', 'archive', 'github', 'wikipedia'])
|
142 |
|
143 |
col1, col2 = st.columns(2)
|
144 |
with col1:
|
|
|
147 |
link_count = st.number_input("Number of Links per product",min_value=1, step=1, format="%i")
|
148 |
|
149 |
|
150 |
+
tag_option = st.selectbox('Choose Similarity Method', ["Complete Document Similarity","Field Wise Document Similarity"])
|
151 |
|
152 |
|
153 |
if st.button('Check for Infringement'):
|
|
|
162 |
st.subheader("Cosine Similarity Scores")
|
163 |
|
164 |
# = score(main_product, main_url, search, logger, log_output)
|
165 |
+
if tag_option == 'Complete Document Similarity':
|
166 |
tags = ['Details']
|
167 |
else:
|
168 |
tags = ['Introduction', 'Specifications', 'Product Overview', 'Safety Information', 'Installation Instructions', 'Setup and Configuration', 'Operation Instructions', 'Maintenance and Care', 'Troubleshooting', 'Warranty Information', 'Legal Information']
|
|
|
170 |
for product, link, index, value in cosine_sim_scores:
|
171 |
if not index:
|
172 |
st.write(f"Product: {product}, Link: {link}")
|
173 |
+
if value!=None:
|
174 |
st.write(f"{tags[index]:<20} - Similarity: {value:.2f}")
|