Skip to content

Commit

Permalink
Merge pull request #6236 from AMR-KELEG/fix-entity-synonym-requirements
Browse files Browse the repository at this point in the history
Add EntityExtractor as a requirement for EntitySynonymMapper
  • Loading branch information
akelad authored Jul 22, 2020
2 parents 2665656 + f397c42 commit 26791a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/6198.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``EntityExtractor`` as a required component for ``EntitySynonymMapper`` in a pipeline.
4 changes: 3 additions & 1 deletion docs/nlu/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,8 @@ DIETClassifier
You can find the detailed description of the :ref:`diet-classifier` under the section
`Combined Entity Extractors and Intent Classifiers`.

.. _EntityExtractors:

Entity Extractors
-----------------

Expand Down Expand Up @@ -905,7 +907,7 @@ EntitySynonymMapper

:Short: Maps synonymous entity values to the same value.
:Outputs: Modifies existing entities that previous entity extraction components found.
:Requires: Nothing
:Requires: An extractor from :ref:`EntityExtractors`
:Description:
If the training data contains defined synonyms, this component will make sure that detected entity values will
be mapped to the same value. For example, if your training data contains the following examples:
Expand Down
7 changes: 6 additions & 1 deletion rasa/nlu/extractors/entity_synonyms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from typing import Any, Dict, Optional, Text
from typing import Any, Dict, List, Optional, Text, Type

from rasa.nlu.components import Component
from rasa.constants import DOCS_URL_TRAINING_DATA_NLU
from rasa.nlu.constants import ENTITIES
from rasa.nlu.config import RasaNLUModelConfig
Expand All @@ -13,6 +14,10 @@


class EntitySynonymMapper(EntityExtractor):
@classmethod
def required_components(cls) -> List[Type[Component]]:
return [EntityExtractor]

def __init__(
self,
component_config: Optional[Dict[Text, Any]] = None,
Expand Down

0 comments on commit 26791a9

Please sign in to comment.