Update app.py
Browse files
app.py
CHANGED
@@ -27,13 +27,21 @@ def main():
|
|
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 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
selected_keywords = keywords[:num_results]
|
39 |
|
|
|
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 |
+
# Get user choice for keyword diversity (MMR only)
|
31 |
+
diversity = st.slider("Keyword Diversity (MMR)", min_value=0.0, max_value=1.0, value=0.2, step=0.1, format="%.1f")
|
32 |
+
|
33 |
# Extract keywords
|
34 |
if st.button("Extract Keywords"):
|
35 |
+
if apply_mmr:
|
36 |
+
keywords = kw_model.extract_keywords(doc,
|
37 |
+
keyphrase_ngram_range=(min_ngram, max_ngram),
|
38 |
+
stop_words='english' if remove_stopwords else None,
|
39 |
+
use_mmr=True,
|
40 |
+
diversity=diversity)
|
41 |
+
else:
|
42 |
+
keywords = kw_model.extract_keywords(doc,
|
43 |
+
keyphrase_ngram_range=(min_ngram, max_ngram),
|
44 |
+
stop_words='english' if remove_stopwords else None)
|
45 |
|
46 |
selected_keywords = keywords[:num_results]
|
47 |
|