Update app.py
Browse files
app.py
CHANGED
|
@@ -76,7 +76,7 @@ def removeStopWords(text):
|
|
| 76 |
question_norm_and_stop = df['Normalized question'].apply(removeStopWords)
|
| 77 |
df.insert(3, 'Normalized and StopWords question', question_norm_and_stop, True)
|
| 78 |
|
| 79 |
-
tfidf = TfidfVectorizer() # initializing tf-idf
|
| 80 |
x_tfidf = tfidf.fit_transform(df['Normalized and StopWords question']).toarray() # oversimplifying this converts words to vectors
|
| 81 |
features_tfidf = tfidf.get_feature_names_out() # use function to get all the normalized words
|
| 82 |
df_tfidf = pd.DataFrame(x_tfidf, columns = features_tfidf) # create dataframe to show the 0, 1 value for each word
|
|
@@ -279,7 +279,7 @@ def chat_bert_context(question, history):
|
|
| 279 |
else:
|
| 280 |
memory_weights = np.array([0.3, 1.0])
|
| 281 |
|
| 282 |
-
history_sentence = np.zeros(shape=(len_history+1,
|
| 283 |
|
| 284 |
for ind, h in enumerate(history):
|
| 285 |
|
|
@@ -299,19 +299,6 @@ def chat_bert_context(question, history):
|
|
| 299 |
#------------------------------------------------------------------------------------------------#
|
| 300 |
# gradio part
|
| 301 |
def echo(message, history, model):
|
| 302 |
-
# print(model)
|
| 303 |
-
# print(history)
|
| 304 |
-
# if model=="TF-IDF":
|
| 305 |
-
# answer = chat_tfidf(message)
|
| 306 |
-
# return answer
|
| 307 |
-
|
| 308 |
-
# elif model=="W2V":
|
| 309 |
-
# answer = chat_word2vec(message)
|
| 310 |
-
# return answer
|
| 311 |
-
|
| 312 |
-
# elif model=="BERT":
|
| 313 |
-
# answer = chat_bert(message)
|
| 314 |
-
# return answer
|
| 315 |
|
| 316 |
if model=="TF-IDF":
|
| 317 |
# answer = chat_tfidf(message)
|
|
|
|
| 76 |
question_norm_and_stop = df['Normalized question'].apply(removeStopWords)
|
| 77 |
df.insert(3, 'Normalized and StopWords question', question_norm_and_stop, True)
|
| 78 |
|
| 79 |
+
tfidf = TfidfVectorizer(ngram_range=(1,3), max_features=5024) # initializing tf-idf
|
| 80 |
x_tfidf = tfidf.fit_transform(df['Normalized and StopWords question']).toarray() # oversimplifying this converts words to vectors
|
| 81 |
features_tfidf = tfidf.get_feature_names_out() # use function to get all the normalized words
|
| 82 |
df_tfidf = pd.DataFrame(x_tfidf, columns = features_tfidf) # create dataframe to show the 0, 1 value for each word
|
|
|
|
| 279 |
else:
|
| 280 |
memory_weights = np.array([0.3, 1.0])
|
| 281 |
|
| 282 |
+
history_sentence = np.zeros(shape=(len_history+1, 768))
|
| 283 |
|
| 284 |
for ind, h in enumerate(history):
|
| 285 |
|
|
|
|
| 299 |
#------------------------------------------------------------------------------------------------#
|
| 300 |
# gradio part
|
| 301 |
def echo(message, history, model):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
if model=="TF-IDF":
|
| 304 |
# answer = chat_tfidf(message)
|