chgrdj commited on
Commit
9b1ca0b
·
verified ·
1 Parent(s): a466fad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
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
- # Perform Semantic Search
26
- if domain:
27
- query_emb = model.encode(domain)
28
- print('QUERY',query_emb[:5])
29
- print('CORPUS',corpus_embeddings[:1,:5])
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)
 
 
 
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.")