Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,9 @@ import os
|
|
4 |
from bertopic import BERTopic
|
5 |
from sklearn.feature_extraction.text import CountVectorizer
|
6 |
import numpy as np
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
# Retrieve the token from environment variables
|
@@ -27,7 +30,8 @@ bad_words = load_bad_words('badwords.txt') # Adjust the path to your bad words
|
|
27 |
topics_list = ['Aviation', 'Science', 'Education', 'Air Force Pilot', 'Space Exploration', 'Technology']
|
28 |
|
29 |
#Load BerTopic model
|
30 |
-
|
|
|
31 |
|
32 |
def is_inappropriate_or_offtopic(message, selected_topics):
|
33 |
# Assume bad_words loading and check_content function are defined here
|
|
|
4 |
from bertopic import BERTopic
|
5 |
from sklearn.feature_extraction.text import CountVectorizer
|
6 |
import numpy as np
|
7 |
+
from sentence_transformers import SentenceTransformer
|
8 |
+
|
9 |
+
|
10 |
|
11 |
|
12 |
# Retrieve the token from environment variables
|
|
|
30 |
topics_list = ['Aviation', 'Science', 'Education', 'Air Force Pilot', 'Space Exploration', 'Technology']
|
31 |
|
32 |
#Load BerTopic model
|
33 |
+
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
|
34 |
+
topic_model = BERTopic.load("MaartenGr/BERTopic_Wikipedia", embedding_model=embedding_model)
|
35 |
|
36 |
def is_inappropriate_or_offtopic(message, selected_topics):
|
37 |
# Assume bad_words loading and check_content function are defined here
|