vineelpratap commited on
Commit
56eee40
1 Parent(s): 2bc2fff

Update zeroshot.py

Browse files
Files changed (1) hide show
  1. 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
- for line in f:
99
- line = line.strip().lower()
100
- num_sentences += 1
101
- line = text_normalize(line, iso_code="xxx")
102
- # ignore invalid words.
103
- for w in line.split():
104
- words.setdefault(w, 0)
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