Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
Signed-off-by: ilyashn <[email protected]>
  • Loading branch information
ilyashnil authored and elronbandel committed Dec 18, 2023
1 parent 82345e6 commit 3e94aab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
52 changes: 26 additions & 26 deletions prepare/cards/clinc_oos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datasets import load_dataset_builder
from datasets import get_dataset_config_names, load_dataset_builder

from src.unitxt import add_to_catalog
from src.unitxt.blocks import (
Expand All @@ -10,31 +10,31 @@
)
from src.unitxt.test_utils.card import test_card

dataset_name = "clinc150"
subset = "plus" # TODO add imbalanced, small
ds_builder = load_dataset_builder("clinc_oos", subset)
classlabels = ds_builder.info.features["intent"]
dataset_name = "clinc_oos"

mappers = {}
for i in range(len(classlabels.names)):
mappers[str(i)] = classlabels.names[i]
for subset in get_dataset_config_names(dataset_name):
ds_builder = load_dataset_builder(dataset_name, subset)
classlabels = ds_builder.info.features["intent"]

mappers = {}
for i in range(len(classlabels.names)):
mappers[str(i)] = classlabels.names[i]

card = TaskCard(
loader=LoadHF(path="clinc_oos", name=subset),
preprocess_steps=[
RenameFields(field_to_field={"intent": "label"}),
MapInstanceValues(mappers={"label": mappers}),
AddFields(
fields={
"classes": mappers,
"text_type": "sentence",
"type_of_class": "intent",
}
),
],
task="tasks.classification.multi_class",
templates="templates.classification.multi_class.all",
)
test_card(card, debug=False)
add_to_catalog(artifact=card, name=f"cards.{dataset_name}.{subset}", overwrite=True)
card = TaskCard(
loader=LoadHF(path=dataset_name, name=subset),
preprocess_steps=[
RenameFields(field_to_field={"intent": "label"}),
MapInstanceValues(mappers={"label": mappers}),
AddFields(
fields={
"classes": classlabels.names,
"text_type": "sentence",
"type_of_class": "intent",
}
),
],
task="tasks.classification.multi_class",
templates="templates.classification.multi_class.all",
)
test_card(card, debug=False)
add_to_catalog(artifact=card, name=f"cards.{dataset_name}.{subset}", overwrite=True)
4 changes: 1 addition & 3 deletions prepare/cards/ledgar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

dataset_name = "ledgar"

ds_builder = load_dataset_builder(
"lex_glue", dataset_name
) # TODO should we take all from lex_glue?
ds_builder = load_dataset_builder("lex_glue", dataset_name)
classlabels = ds_builder.info.features["label"]

mappers = {}
Expand Down

0 comments on commit 3e94aab

Please sign in to comment.