f = open(f, "rb")
for lineno, ln in enumerate(f, 1):
try:
line = ln.strip().decode("utf-8").lstrip("\ufeff")
if not line:
continue
tup = line.split(" ")
After Change
word, freq, tag = re_userdict.match(line).groups()
if freq is not None:
freq = freq.strip()
if tag is not None:
tag = tag.strip()
self.add_word(word, freq, tag)
def add_word(self, word, freq=None, tag=None):