Spaces:
Running
Running
Update zeroshot.py
Browse files- zeroshot.py +7 -9
zeroshot.py
CHANGED
|
@@ -93,16 +93,14 @@ def filter_lexicon(lexicon, word_counts):
|
|
| 93 |
|
| 94 |
def load_words(filepath):
|
| 95 |
words = {}
|
| 96 |
-
num_sentences = 0
|
| 97 |
with open(filepath) as f:
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
words[w] += 1
|
| 106 |
return words, num_sentences
|
| 107 |
|
| 108 |
|
|
|
|
| 93 |
|
| 94 |
def load_words(filepath):
|
| 95 |
words = {}
|
|
|
|
| 96 |
with open(filepath) as f:
|
| 97 |
+
lines = f.readlines()
|
| 98 |
+
num_sentences = len(lines)
|
| 99 |
+
all_sentences = " ".join([l.strip() for l in lines])
|
| 100 |
+
norm_all_sentences = text_normalize(all_sentences)
|
| 101 |
+
for w in norm_all_sentences.split():
|
| 102 |
+
words.setdefault(w, 0)
|
| 103 |
+
words[w] += 1
|
|
|
|
| 104 |
return words, num_sentences
|
| 105 |
|
| 106 |
|