Update app.py
Browse files
app.py
CHANGED
@@ -22,19 +22,21 @@ st.write("Enter a potential typosquatted domain and select the number of top res
|
|
22 |
domain = st.text_input("Potential Typosquatted Domain")
|
23 |
top_k = st.number_input("Top K Results", min_value=1, max_value=len(corpus_domains), value=5, step=1)
|
24 |
|
25 |
-
#
|
26 |
-
if
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
22 |
domain = st.text_input("Potential Typosquatted Domain")
|
23 |
top_k = st.number_input("Top K Results", min_value=1, max_value=len(corpus_domains), value=5, step=1)
|
24 |
|
25 |
+
# Button to trigger search
|
26 |
+
if st.button("Search for Legitimate Domains"):
|
27 |
+
if domain:
|
28 |
+
# Perform Semantic Search
|
29 |
+
query_emb = model.encode(domain)
|
30 |
+
semantic_res = util.semantic_search(query_emb, corpus_embeddings, top_k=top_k)[0]
|
31 |
+
ids = [r['corpus_id'] for r in semantic_res]
|
32 |
+
scores = [r['score'] for r in semantic_res]
|
33 |
+
|
34 |
+
# Create a DataFrame for the results
|
35 |
+
res_df = domains_df.iloc[ids].copy()
|
36 |
+
res_df['score'] = scores
|
37 |
+
|
38 |
+
# Display the result DataFrame
|
39 |
+
st.write("Mined Domains:")
|
40 |
+
st.dataframe(res_df)
|
41 |
+
else:
|
42 |
+
st.warning("Please enter a domain to perform the search.")
|