Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,6 +30,10 @@ def extract_main_topic(text: str) -> str:
|
|
| 30 |
Returns:
|
| 31 |
str: The extracted main topic as keywords.
|
| 32 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
topics, probs = topic_model.transform([text])
|
| 34 |
|
| 35 |
if topic_id == -1: # BERTopic assigns -1 to noise (no topic detected)
|
|
|
|
| 30 |
Returns:
|
| 31 |
str: The extracted main topic as keywords.
|
| 32 |
"""
|
| 33 |
+
|
| 34 |
+
# Initialize BERTopic model
|
| 35 |
+
topic_model = BERTopic.load("MaartenGr/BERTopic_ArXiv")
|
| 36 |
+
|
| 37 |
topics, probs = topic_model.transform([text])
|
| 38 |
|
| 39 |
if topic_id == -1: # BERTopic assigns -1 to noise (no topic detected)
|