Skip to content

Commit a868d35

Browse files
committed
Fix docstrings and add to HTML build
1 parent 5a6021a commit a868d35

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

docs/source/package_reference/main_classes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The base class :class:`datasets.Dataset` implements a Dataset backed by an Apach
3232
info, split, builder_name, citation, config_name, dataset_size,
3333
description, download_checksums, download_size, features, homepage,
3434
license, size_in_bytes, supervised_keys, version,
35-
from_csv, from_json, from_text,
35+
from_csv, from_json, from_text, prepare_for_task,
3636

3737
.. autofunction:: datasets.concatenate_datasets
3838

@@ -54,7 +54,7 @@ It also has dataset transform methods like map or filter, to process all the spl
5454
flatten_, cast_, remove_columns_, rename_column_,
5555
flatten, cast, remove_columns, rename_column, class_encode_column,
5656
save_to_disk, load_from_disk,
57-
from_csv, from_json, from_text,
57+
from_csv, from_json, from_text, prepare_for_task
5858

5959

6060
``Features``

src/datasets/arrow_dataset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,12 +1391,12 @@ def prepare_for_task(self, task: Union[str, TaskTemplate]) -> "Dataset":
13911391
Casts :attr:`datasets.DatasetInfo.features` according to a task-specific schema.
13921392
13931393
Args:
1394-
task (:obj:`Union[str, TaskTemplate]`): The task to prepare the dataset for during training and evaluation. If `str`, supported tasks include:
1394+
task (:obj:`Union[str, TaskTemplate]`): The task to prepare the dataset for during training and evaluation. If :obj:`str`, supported tasks include:
13951395
1396-
- :obj:`"text-clasification"`
1396+
- :obj:`"text-classification"`
13971397
- :obj:`"question-answering"`
13981398
1399-
If `TaskTemplate`, must be one of the task templates in `datasets.tasks`.
1399+
If :obj:`TaskTemplate`, must be one of the task templates in :obj:`datasets.tasks`.
14001400
"""
14011401
# TODO(lewtun): Add support for casting nested features like answers.text and answers.answer_start in SQuAD
14021402
if isinstance(task, str):

src/datasets/dataset_dict.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .features import Features
1414
from .filesystems import extract_path_from_uri, is_remote_filesystem
1515
from .table import Table
16+
from .tasks import TaskTemplate
1617
from .utils.deprecation_utils import deprecated
1718
from .utils.typing import PathLike
1819

@@ -791,16 +792,18 @@ def from_text(
791792
path_or_paths, features=features, cache_dir=cache_dir, keep_in_memory=keep_in_memory, **kwargs
792793
).read()
793794

794-
def prepare_for_task(self, task: str):
795+
def prepare_for_task(self, task: Union[str, TaskTemplate]):
795796
"""Prepare a dataset for the given task.
796797
797798
Casts :attr:`datasets.DatasetInfo.features` according to a task-specific schema.
798799
799800
Args:
800-
task (``str``): The task to prepare the dataset for during training and evaluation. Supported tasks include:
801+
task (:obj:`Union[str, TaskTemplate]`): The task to prepare the dataset for during training and evaluation. If :obj:`str`, supported tasks include:
801802
802-
- :obj:`"text-clasification"`
803+
- :obj:`"text-classification"`
803804
- :obj:`"question-answering"`
805+
806+
If :obj:`TaskTemplate`, must be one of the task templates in :obj:`datasets.tasks`.
804807
"""
805808
self._check_values_type()
806809
return DatasetDict({k: dataset.prepare_for_task(task=task) for k, dataset in self.items()})

0 commit comments

Comments
 (0)