Skip to content

Commit

Permalink
Merge pull request #164 from neulab/rename-cls
Browse files Browse the repository at this point in the history
use cls_name for metrics and tokenizer
  • Loading branch information
lyuyangh authored May 10, 2022
2 parents be021cc + af9867a commit 27c545b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
16 changes: 6 additions & 10 deletions backend/src/impl/default_controllers_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from explainaboard.loaders.loader_registry import get_supported_file_types_for_loader
from explainaboard.metric import MetricStats
from explainaboard.processors.processor_registry import get_metric_list_for_processor
from explainaboard.utils.tokenizer import get_default_tokenizer
from explainaboard.utils import tokenizer as exb_tokenzier
from explainaboard_web.impl.auth import get_user
from explainaboard_web.impl.db_utils.dataset_db_utils import DatasetDBUtils
from explainaboard_web.impl.db_utils.system_db_utils import SystemDBUtils
Expand Down Expand Up @@ -267,21 +267,17 @@ def systems_analyses_post(body: SystemsAnalysesBody):
system_output_info.features[feature_name] = feature

metric_configs = [
getattr(exb_metric, metric_config_dict["cls"])(**metric_config_dict)
getattr(exb_metric, metric_config_dict["cls_name"])(**metric_config_dict)
for metric_config_dict in system_output_info.metric_configs
]

system_output_info.metric_configs = metric_configs

# The order of getting the processor first then setting
# the tokenizer is unnatural, but in the SDK get_default_tokenizer
# relies on the processor's TaskType inforamtion

processor = get_processor(TaskType(system_output_info.task_name))
system_output_info.tokenizer = get_default_tokenizer(
task_type=TaskType(system_output_info.task_name), lang=system_info.language
cls_name = system_output_info.tokenizer.pop("cls_name")
system_output_info.tokenizer = getattr(exb_tokenzier, cls_name)(
**system_output_info.tokenizer
)

processor = get_processor(TaskType(system_output_info.task_name))
metric_stats = [MetricStats(stat) for stat in system.metric_stats]

# Get the entire system outputs
Expand Down
2 changes: 1 addition & 1 deletion backend/templates/requirements.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Flask-PyMongo
swagger-ui-bundle >= 0.0.9
python-dotenv
pyjwt[crypto] == 2.3.0
explainaboard == 0.8.14
explainaboard == 0.8.15
en_core_web_sm@https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0-py3-none-any.whl
pre-commit
marisa_trie
6 changes: 3 additions & 3 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,14 @@ components:
language:
type: string
nullable: True
cls:
cls_name:
type: string
additionalProperties: true
required: [name, cls]
required: [name, cls_name]
tokenizer:
type: object
properties:
cls:
cls_name:
type: string
example: "SingleSpaceTokenizer"
features:
Expand Down

0 comments on commit 27c545b

Please sign in to comment.