Skip to content

Commit

Permalink
dense featurizers don't process not dense featurizable attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniiaraz committed Aug 5, 2020
1 parent 3be95ab commit 2934b10
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ def process(
attribute: Text = TEXT,
**kwargs: Any,
) -> None:
if attribute not in DENSE_FEATURIZABLE_ATTRIBUTES:
return

sequence_features, sentence_features = self._compute_features(
[message], tf_hub_module, attribute=attribute
)
Expand Down
3 changes: 3 additions & 0 deletions rasa/nlu/featurizers/dense_featurizer/lm_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def _get_doc(self, message: Message, attribute: Text) -> Any:
def process(self, message: Message, attribute: Text = TEXT, **kwargs: Any) -> None:
"""Sets the dense features from the language model doc to the incoming
message."""
if attribute not in DENSE_FEATURIZABLE_ATTRIBUTES:
return

self._set_lm_features(message, attribute)

def _set_lm_features(self, message: Message, attribute: Text = TEXT) -> None:
Expand Down
3 changes: 3 additions & 0 deletions rasa/nlu/featurizers/dense_featurizer/mitie_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def process_training_example(
self._set_features(example, sequence_features, sentence_features, attribute)

def process(self, message: Message, attribute: Text = TEXT, **kwargs: Any) -> None:
if attribute not in DENSE_FEATURIZABLE_ATTRIBUTES:
return

mitie_feature_extractor = self._mitie_feature_extractor(**kwargs)
tokens = message.get(TOKENS_NAMES[attribute])
sequence_features, sentence_features = self.features_for_tokens(
Expand Down
3 changes: 3 additions & 0 deletions rasa/nlu/featurizers/dense_featurizer/spacy_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def get_doc(self, message: Message, attribute: Text) -> Any:
return message.get(SPACY_DOCS[attribute])

def process(self, message: Message, attribute: Text = TEXT, **kwargs: Any) -> None:
if attribute not in DENSE_FEATURIZABLE_ATTRIBUTES:
return

self._set_spacy_features(message, attribute)

def _set_spacy_features(self, message: Message, attribute: Text = TEXT) -> None:
Expand Down

0 comments on commit 2934b10

Please sign in to comment.