Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
1efc208f
Commit
1efc208f
authored
Jan 06, 2020
by
Lysandre Debut
Browse files
Complete DataProcessor class
parent
c45d0cf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
src/transformers/data/processors/utils.py
src/transformers/data/processors/utils.py
+27
-0
No files found.
src/transformers/data/processors/utils.py
View file @
1efc208f
...
...
@@ -93,6 +93,33 @@ class InputFeatures(object):
class
DataProcessor
(
object
):
"""Base class for data converters for sequence classification data sets."""
def
get_example_from_tensor_dict
(
self
,
tensor_dict
):
"""Gets an example from a dict with tensorflow tensors
Args:
tensor_dict: Keys and values should match the corresponding Glue
tensorflow_dataset examples.
"""
raise
NotImplementedError
()
def
get_train_examples
(
self
,
data_dir
):
"""Gets a collection of `InputExample`s for the train set."""
raise
NotImplementedError
()
def
get_dev_examples
(
self
,
data_dir
):
"""Gets a collection of `InputExample`s for the dev set."""
raise
NotImplementedError
()
def
get_labels
(
self
):
"""Gets the list of labels for this data set."""
raise
NotImplementedError
()
def
tfds_map
(
self
,
example
):
"""Some tensorflow_datasets datasets are not formatted the same way the GLUE datasets are.
This method converts examples to the correct format."""
if
len
(
self
.
get_labels
())
>
1
:
example
.
label
=
self
.
get_labels
()[
int
(
example
.
label
)]
return
example
@
classmethod
def
_read_tsv
(
cls
,
input_file
,
quotechar
=
None
):
"""Reads a tab separated value file."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment