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

support of hf dataset for jsl and spacy #521

Merged
merged 2 commits into from
Jun 15, 2023
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
20 changes: 20 additions & 0 deletions nlptest/nlptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ def __init__(
data.get('subset', None)
) if data is not None else None

elif type(data) is dict and hub == "johnsnowlabs" and task == "text-classification":
self.data = HuggingFaceDataset(data['name']).load_data(
data.get('feature_column', 'text'),
data.get('target_column', 'label'),
data.get('split', 'test'),
data.get('subset', None)
) if data is not None else None

elif type(data) is dict and hub == "spacy" and task == "text-classification":
self.data = HuggingFaceDataset(data['name']).load_data(
data.get('feature_column', 'text'),
data.get('target_column', 'label'),
data.get('split', 'test'),
data.get('subset', None)
) if data is not None else None
if model == 'textcat_imdb':
model = resource_filename("nlptest", "data/textcat_imdb")
else:
raise ValueError(f"Unsupported model '{model}'! Only 'textcat_imdb' is supported.")

elif data is None and (task, model, hub) not in self.DEFAULTS_DATASET.keys():
raise ValueError("You haven't specified any value for the parameter 'data' and the configuration you "
"passed is not among the default ones. You need to either specify the parameter 'data' "
Expand Down