Skip to content

Commit

Permalink
function comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ricwo committed Mar 13, 2018
1 parent 9b07fdb commit 09b30ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 13 additions & 4 deletions rasa_nlu/extractors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ def add_processor_name(self, entity):
entity["processors"].append(self.name)
else:
entity["processors"] = [self.name]

return entity

def filter_trainable_entities(self, entity_examples):
# type: (List[Message]) -> List[Message]
"""Filters out untrainable entity annotations.
Creates a copy of entity_examples in which entities that have
`extractor` set to something other than self.name (e.g. 'ner_crf')
are removed."""

filtered = []
for message in entity_examples:
entities = []
Expand All @@ -38,8 +45,10 @@ def filter_trainable_entities(self, entity_examples):
entities.append(ent)
data = message.data.copy()
data['entities'] = entities
filtered.append(Message(text=message.text,
data=data,
output_properties=message.output_properties,
time=message.time))
filtered.append(
Message(text=message.text,
data=data,
output_properties=message.output_properties,
time=message.time))

return filtered
3 changes: 0 additions & 3 deletions rasa_nlu/extractors/crf_entity_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import logging
import os
from copy import deepcopy

import typing
from typing import Any
Expand All @@ -18,7 +17,6 @@
from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.extractors import EntityExtractor
from rasa_nlu.model import Metadata
from rasa_nlu.tokenizers import Token
from rasa_nlu.training_data import Message
from rasa_nlu.training_data import TrainingData
from builtins import str
Expand All @@ -28,7 +26,6 @@
if typing.TYPE_CHECKING:
from spacy.language import Language
import sklearn_crfsuite
from spacy.tokens import Doc


class CRFEntityExtractor(EntityExtractor):
Expand Down

0 comments on commit 09b30ee

Please sign in to comment.