Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/datasets/packaged_modules/text/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TextConfig(datasets.BuilderConfig):

features: Optional[datasets.Features] = None
encoding: str = "utf-8"
errors: Optional[str] = None
chunksize: int = 10 << 20 # 10MB
keep_linebreaks: bool = False
sample_by: str = "line"
Expand Down Expand Up @@ -70,7 +71,7 @@ def _generate_tables(self, files):
pa_table_names = list(self.config.features) if self.config.features is not None else ["text"]
for file_idx, file in enumerate(itertools.chain.from_iterable(files)):
# open in text mode, by default translates universal newlines ("\n", "\r\n" and "\r") into "\n"
with open(file, encoding=self.config.encoding) as f:
with open(file, encoding=self.config.encoding, errors=self.config.errors) as f:
if self.config.sample_by == "line":
batch_idx = 0
while True:
Expand Down