Update app.py
Browse files
app.py
CHANGED
@@ -21,29 +21,24 @@ def main():
|
|
21 |
# Get user choice for number of results (slider)
|
22 |
num_results = st.slider("Number of Results", min_value=1, max_value=30, value=5, step=1)
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
keywords = kw_model.extract_keywords(doc, stop_words=None if remove_stopwords else "english")
|
27 |
-
|
28 |
-
if apply_mmr:
|
29 |
-
# Apply Maximal Marginal Relevance (MMR)
|
30 |
-
selected_keywords = []
|
31 |
-
selected_keywords.append(keywords[0]) # Select the top-scoring keyword
|
32 |
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
|
44 |
|
45 |
st.write(f"Top {num_results} Keywords:")
|
46 |
-
for keyword, score in
|
47 |
st.write(f"- {keyword} (Score: {score})")
|
48 |
|
49 |
# Run the app
|
|
|
21 |
# Get user choice for number of results (slider)
|
22 |
num_results = st.slider("Number of Results", min_value=1, max_value=30, value=5, step=1)
|
23 |
|
24 |
+
# Get user choice for minimum n-gram value (default textbox)
|
25 |
+
min_ngram = st.number_input("Minimum N-gram", value=1, min_value=1, max_value=10, step=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
# Get user choice for maximum n-gram value (default textbox)
|
28 |
+
max_ngram = st.number_input("Maximum N-gram", value=3, min_value=1, max_value=10, step=1)
|
29 |
|
30 |
+
# Extract keywords
|
31 |
+
if st.button("Extract Keywords"):
|
32 |
+
keywords = kw_model.extract_keywords(doc,
|
33 |
+
keyphrase_ngram_range=(min_ngram, max_ngram),
|
34 |
+
stop_words='english' if remove_stopwords else None,
|
35 |
+
use_mmr=apply_mmr,
|
36 |
+
diversity=0.2)
|
37 |
|
38 |
+
selected_keywords = keywords[:num_results]
|
39 |
|
40 |
st.write(f"Top {num_results} Keywords:")
|
41 |
+
for keyword, score in selected_keywords:
|
42 |
st.write(f"- {keyword} (Score: {score})")
|
43 |
|
44 |
# Run the app
|