Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_classifier_config():
"""Tests that the default config is returned when an app specified config doesn't exist."""
actual = get_classifier_config("domain", APP_PATH)["param_selection"]
expected = {
"type": "k-fold",
"k": 10,
"grid": {"fit_intercept": [True, False], "C": [10, 100, 1000, 10000, 100000]},
}
assert actual == expected
def test_get_classifier_config_func():
"""Tests that the app config provider is called."""
actual = get_classifier_config(
"entity", APP_PATH, domain="domain", intent="intent"
)["params"]
expected = {"penalty": "l2", "C": 100}
assert actual == expected
):
"""Initializes an entity resolver
Args:
app_path (str): The application path
resource_loader (ResourceLoader): An object which can load resources for the resolver
entity_type: The entity type associated with this entity resolver
es_host (str): The Elasticsearch host server
"""
self._app_namespace = get_app_namespace(app_path)
self._resource_loader = resource_loader
self._normalizer = resource_loader.query_factory.normalize
self.type = entity_type
self._is_system_entity = Entity.is_system_entity(self.type)
self._exact_match_mapping = None
self._er_config = get_classifier_config("entity_resolution", app_path=app_path)
self._es_host = es_host
self._es_config = {"client": es_client, "pid": os.getpid()}
def _get_model_config(self, **kwargs): # pylint: disable=arguments-differ
"""Gets a machine learning model configuration
Returns:
ModelConfig: The model configuration corresponding to the provided config name
"""
kwargs["example_type"] = QUERY_EXAMPLE_TYPE
kwargs["label_type"] = ENTITIES_LABEL_TYPE
loaded_config = get_classifier_config(
self.CLF_TYPE,
self._resource_loader.app_path,
domain=self.domain,
intent=self.intent,
)
return super()._get_model_config(loaded_config, **kwargs)
def _get_model_config(self, **kwargs):
"""Gets a machine learning model configuration
Returns:
ModelConfig: The model configuration corresponding to the provided config name
"""
kwargs["example_type"] = QUERY_EXAMPLE_TYPE
kwargs["label_type"] = CLASS_LABEL_TYPE
loaded_config = get_classifier_config(
self.CLF_TYPE, self._resource_loader.app_path
)
return super()._get_model_config(loaded_config, **kwargs)
def _get_model_config(self, **kwargs):
"""Gets a machine learning model configuration
Returns:
ModelConfig: The model configuration corresponding to the provided config name
"""
kwargs["example_type"] = ENTITY_EXAMPLE_TYPE
kwargs["label_type"] = CLASS_LABEL_TYPE
loaded_config = get_classifier_config(
self.CLF_TYPE,
self._resource_loader.app_path,
domain=self.domain,
intent=self.intent,
entity=self.entity_type,
)
return super()._get_model_config(loaded_config, **kwargs)
def _get_model_config(self, **kwargs):
"""Gets a machine learning model configuration
Returns:
ModelConfig: The model configuration corresponding to the provided config name
"""
kwargs["example_type"] = QUERY_EXAMPLE_TYPE
kwargs["label_type"] = CLASS_LABEL_TYPE
loaded_config = get_classifier_config(
self.CLF_TYPE, self._resource_loader.app_path, domain=self.domain
)
return super()._get_model_config(loaded_config, **kwargs)