From d770679373d284a2ce23160d8c0d6b2e2961ad3f Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Wed, 4 Mar 2020 11:48:02 -0500 Subject: [PATCH] Fix first entity bug in Rasa NLU training --- rhasspy/intent_train.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rhasspy/intent_train.py b/rhasspy/intent_train.py index ec3871c5..30abf8d3 100755 --- a/rhasspy/intent_train.py +++ b/rhasspy/intent_train.py @@ -193,7 +193,8 @@ def train(self, intent_graph) -> None: entity = None sentence_tokens = [] entity_tokens = [] - for token in intent_sent["raw_tokens"]: + for raw_token in intent_sent["raw_tokens"]: + token = raw_token if entity and (raw_index >= entity["raw_end"]): # Finish current entity last_token = entity_tokens[-1] @@ -217,7 +218,7 @@ def train(self, intent_graph) -> None: # Add directly to sentence sentence_tokens.append(token) - raw_index += len(token) + 1 + raw_index += len(raw_token) + 1 if entity: # Finish final entity