Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set utf8 as default character encoding #272

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

packages=[
f"texar.{name}"
for name in setuptools.find_packages(where='texar/')
for name in setuptools.find_packages(where='texar')
],
platforms='any',

Expand Down
2 changes: 1 addition & 1 deletion texar/torch/data/data/text_data_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TextLineDataSource(DataSource[List[str]]):

def __init__(self, file_paths: MaybeList[str],
compression_type: Optional[str] = None,
encoding: Optional[str] = None,
encoding: Optional[str] = "utf-8",
delimiter: Optional[str] = None,
max_length: Optional[int] = None):
if compression_type is not None:
Expand Down
2 changes: 1 addition & 1 deletion texar/torch/data/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def read_words(filename: str, newline_token: Optional[str] = None) -> List[str]:
Returns:
A list of words.
"""
with open(filename, "r") as f:
with open(filename, "r", encoding="utf-8") as f:
if Py3:
if newline_token is None:
return f.read().split()
Expand Down
2 changes: 1 addition & 1 deletion texar/torch/data/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def load(self, filename: str) \
where and :attr:`token_to_id_map_py` are python `defaultdict`
instances.
"""
with open(filename, "r") as vocab_file:
with open(filename, "r", encoding="utf-8") as vocab_file:
vocab = list(line.strip() for line in vocab_file)

warnings.simplefilter("ignore", UnicodeWarning)
Expand Down