Commit 9f6b552d authored by Wei Ho's avatar Wei Ho Committed by Facebook Github Bot
Browse files

Remove unused ignore_utf_errors option from Dictionary

Reviewed By: donhusa

Differential Revision: D18703314

fbshipit-source-id: 93a6b25a7de5e8a29879302ba23b9d6f60660b40
parent 181dc58e
......@@ -175,7 +175,7 @@ class Dictionary(object):
return self.unk_index
@classmethod
def load(cls, f, ignore_utf_errors=False):
def load(cls, f):
"""Loads the dictionary from a text file with the format:
```
......@@ -185,22 +185,18 @@ class Dictionary(object):
```
"""
d = cls()
d.add_from_file(f, ignore_utf_errors)
d.add_from_file(f)
return d
def add_from_file(self, f, ignore_utf_errors=False):
def add_from_file(self, f):
"""
Loads a pre-existing dictionary from a text file and adds its symbols
to this instance.
"""
if isinstance(f, str):
try:
if not ignore_utf_errors:
with open(f, 'r', encoding='utf-8') as fd:
self.add_from_file(fd)
else:
with open(f, 'r', encoding='utf-8', errors='ignore') as fd:
self.add_from_file(fd)
with open(f, 'r', encoding='utf-8') as fd:
self.add_from_file(fd)
except FileNotFoundError as fnfe:
raise fnfe
except UnicodeError:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment