Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve misclassifciations #62

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions ovos_persona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ def match_high(self, utterances: List[str], lang: Optional[str] = None,
LOG.info(f"Persona intent exact match: {match}")
entities = match.matches if hasattr(match, "matches") else match.get("entities", {})
persona = entities.get("persona")
if name == "summon.intent":
query = entities.get("query")
if name == "summon.intent" and persona: # if persona name not in match, its a misclassification
return IntentHandlerMatch(match_type='persona:summon',
match_data={"persona": persona},
skill_id="persona.openvoiceos",
Expand All @@ -303,9 +304,9 @@ def match_high(self, utterances: List[str], lang: Optional[str] = None,
match_data={"lang": lang},
skill_id="persona.openvoiceos",
utterance=utterances[0])
elif name == "ask.intent" and "entities" in match: # if "entities" not in match, its a misclassification
elif name == "ask.intent" and persona: # if persona name not in match, its a misclassification
persona = self.get_persona(persona)
if persona and "query" in match["entities"]: # else the name isnt a valid persona, or its a misclassification
if persona and query: # else its a misclassification
utterance = match["entities"].pop("query")
return IntentHandlerMatch(match_type='persona:query',
match_data={"utterance": utterance,
Expand All @@ -314,10 +315,10 @@ def match_high(self, utterances: List[str], lang: Optional[str] = None,
skill_id="persona.openvoiceos",
utterance=utterances[0])

# override regular intent parsing, handle utterance until persona is released
if self.active_persona:
LOG.debug(f"Persona is active: {self.active_persona}")
return self.match_low(utterances, lang, message)
# override regular intent parsing, handle utterance until persona is released
if self.active_persona:
LOG.debug(f"Persona is active: {self.active_persona}")
return self.match_low(utterances, lang, message)

def match_medium(self, utterances: List[str], lang: str, message: Message) -> None:
return self.match_high(utterances, lang, message)
Expand Down
Loading