Skip to content

Commit

Permalink
fix remaining issues in rasa.nlu
Browse files Browse the repository at this point in the history
  • Loading branch information
m-vdb committed Mar 10, 2022
1 parent 7b418ab commit 4e5e82d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions rasa/nlu/emulators/luis.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ def _intents(self, data: Dict[Text, Any]) -> Dict[Text, Any]:

return {top[INTENT_NAME_KEY]: {"score": top[PREDICTED_CONFIDENCE_KEY]}}

def _entities(
self, data: Dict[Text, Any]
) -> Dict[Text, Dict[Text, List[Dict[Text, Any]]]]:
def _entities(self, data: Dict[Text, Any]) -> Dict[Text, Any]:
if ENTITIES not in data:
return {}

entities: Dict[Text, Dict[Text, List[Dict[Text, Any]]]] = {"$instance": {}}
entities: Dict[Text, Any] = {"$instance": {}}
for e in data[ENTITIES]:
# LUIS API v3 uses entity roles instead of entity names
# (it's possible because its roles are unique):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ def cleanup_tokens(
# remove empty strings
token_ids_string = [(id, string) for id, string in token_ids_string if string]

token_ids: List[int]
token_strings: List[Text]
# return as individual token ids and token strings
token_ids, token_strings = zip(*token_ids_string)
return token_ids, token_strings
# FIXME: zip official typing is not really properly set up
return token_ids, token_strings # type: ignore[return-value]


def bert_tokens_pre_processor(token_ids: List[int]) -> List[int]:
Expand Down

0 comments on commit 4e5e82d

Please sign in to comment.