-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (53 loc) · 1.97 KB
/
main.py
File metadata and controls
63 lines (53 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import streamlit as st
from search_engine import SearchEngine
def main():
# Set page configuration
st.set_page_config(
page_title="Advanced Search Engine",
page_icon=":mag_right:",
layout="wide"
)
# Custom CSS
with open("static/styles.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
# Title and description
st.title("Advanced Search Engine")
st.markdown("### Powered by Natural Language Processing")
# Search input
search_query = st.text_input("Enter your search query", placeholder="Type your search here...")
# Search button
if st.button("Search"):
if search_query:
# Initialize search engine
search_engine = SearchEngine()
# Perform search
with st.spinner("Searching across web pages..."):
# Normalization results
st.subheader("Normalization Results")
norm_results = search_engine.normalize_search(search_query)
if norm_results:
for url in norm_results:
st.markdown(f"- {url}")
else:
st.warning("No results found using normalization.")
# TF-IDF results
st.subheader("TF-IDF Ranked Results")
tfidf_results = search_engine.tfidf_search(search_query)
if tfidf_results:
for url in tfidf_results:
st.markdown(f"- {url}")
else:
st.warning("No results found using TF-IDF ranking.")
else:
st.error("Please enter a search query.")
# Additional information
st.markdown("""
#### How It Works
- Tokenizes your search query
- Removes stop words
- Applies stemming
- Searches across predefined web pages
- Ranks results using normalization and TF-IDF
""")
if __name__ == "__main__":
main()