Spaces:
Sleeping
Sleeping
SmitaGautam
commited on
Commit
•
587b779
1
Parent(s):
b866aec
Update svm_predict.py
Browse files- svm_predict.py +5 -3
svm_predict.py
CHANGED
@@ -18,8 +18,10 @@ def predict(sentence):
|
|
18 |
for idx, word in enumerate(tokens):
|
19 |
current_tag = sent_pos_tags[idx][1]
|
20 |
current_idx = pos_tags.index(current_tag) if current_tag in pos_tags else -1
|
21 |
-
|
|
|
|
|
22 |
sent_features.append(word_features)
|
23 |
-
|
24 |
-
predictions = model.predict(
|
25 |
return tokens, predictions
|
|
|
18 |
for idx, word in enumerate(tokens):
|
19 |
current_tag = sent_pos_tags[idx][1]
|
20 |
current_idx = pos_tags.index(current_tag) if current_tag in pos_tags else -1
|
21 |
+
prev_word = tokens[idx-1] if idx!=0 else ""
|
22 |
+
next_word = tokens[idx+1] if idx<l-1 else ""
|
23 |
+
word_features = feature_vector(word, (idx+1)/l, current_idx, prev_word, next_word)
|
24 |
sent_features.append(word_features)
|
25 |
+
scaled_features = scaler.transform(sent_features)
|
26 |
+
predictions = model.predict(scaled_features)
|
27 |
return tokens, predictions
|