Spaces:
Sleeping
Sleeping
update interface
Browse files
app.py
CHANGED
@@ -30,13 +30,14 @@ nlp.vocab.add_flag(lambda s: s.lower() in spacy.lang.en.stop_words.STOP_WORDS, s
|
|
30 |
|
31 |
def preprocess_text(text):
|
32 |
"""Preprocess the input text using SpaCy and return word indices."""
|
33 |
-
|
34 |
word_seq = []
|
35 |
-
for
|
36 |
-
|
37 |
-
if token.
|
38 |
-
|
39 |
-
|
|
|
40 |
return word_seq
|
41 |
|
42 |
def classify_question(text):
|
@@ -60,7 +61,8 @@ def classify_question(text):
|
|
60 |
"Model 2 Probability": float(pred2),
|
61 |
"Model 3 Probability": float(pred3),
|
62 |
"Model 4 Probability": float(pred4),
|
63 |
-
"Average Probability": float(avg_pred)
|
|
|
64 |
}
|
65 |
|
66 |
return label, probs
|
|
|
30 |
|
31 |
def preprocess_text(text):
|
32 |
"""Preprocess the input text using SpaCy and return word indices."""
|
33 |
+
docs = nlp.pipe([text], n_process=1)
|
34 |
word_seq = []
|
35 |
+
for doc in docs:
|
36 |
+
for token in doc:
|
37 |
+
if token.pos_ != "PUNCT":
|
38 |
+
if token.text not in word_dict:
|
39 |
+
word_dict[token.text] = len(word_dict) + 1 # Increment index.
|
40 |
+
word_seq.append(word_dict[token.text])
|
41 |
return word_seq
|
42 |
|
43 |
def classify_question(text):
|
|
|
61 |
"Model 2 Probability": float(pred2),
|
62 |
"Model 3 Probability": float(pred3),
|
63 |
"Model 4 Probability": float(pred4),
|
64 |
+
"Average Probability": float(avg_pred),
|
65 |
+
"Sequence": seq
|
66 |
}
|
67 |
|
68 |
return label, probs
|