Skip to content

Commit

Permalink
Merge pull request #521 from JohnSnowLabs/feature/support-of-hf-datas…
Browse files Browse the repository at this point in the history
…et-for-jsl

support of hf dataset for jsl and spacy
  • Loading branch information
ArshaanNazir committed Jun 15, 2023
2 parents 3651e27 + bda540f commit 1ae8295
Showing 1 changed file with 20 additions and 0 deletions.
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

0 comments on commit 1ae8295

Please sign in to comment.