salsabilapl commited on
Commit
bfa6667
1 Parent(s): 8188ef7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -9,8 +9,16 @@ dictionary = joblib.load('doc2bow.sav') # Load the dictionary
9
  lda_model = joblib.load('ldamodel.sav') # Load the LDA model
10
 
11
  # Function to preprocess input text and get topic distribution
 
 
 
 
 
 
 
 
12
  def get_topics(text):
13
- bow_vector = dictionary.doc2bow(text.split())
14
  topics = lda_model[bow_vector]
15
  return topics
16
 
 
9
  lda_model = joblib.load('ldamodel.sav') # Load the LDA model
10
 
11
  # Function to preprocess input text and get topic distribution
12
+ def preprocess(text):
13
+ # Define your preprocessing logic here, as it was in your original code
14
+ result = []
15
+ for token in gensim.utils.simple_preprocess(text):
16
+ if token not in gensim.parsing.preprocessing.STOPWORDS and token not in newStopWords and len(token) > 3:
17
+ result.append(lemmatize_stemming(token))
18
+ return result
19
+
20
  def get_topics(text):
21
+ bow_vector = dictionary.doc2bow(preprocess(text))
22
  topics = lda_model[bow_vector]
23
  return topics
24