Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #184 from daniele-athome/rasa-min-confidence
Browse files Browse the repository at this point in the history
Rasa: min confidence parameter
  • Loading branch information
synesthesiam authored Mar 4, 2020
2 parents b68e5ca + 07d1cc4 commit 86e695a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rhasspy/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ def __init__(self) -> None:
RhasspyActor.__init__(self)
self.project_name = ""
self.parse_url = ""
self.min_confidence: float = 0

def to_started(self, from_state: str) -> None:
"""Transition to started state."""
Expand All @@ -397,6 +398,7 @@ def to_started(self, from_state: str) -> None:
self.project_name = rasa_config.get(
"project_name", f"rhasspy_{self.profile.name}"
)
self.min_confidence = rasa_config.get("min_confidence", 0)
self.parse_url = urljoin(url, "model/parse")

def in_started(self, message: Any, sender: RhasspyActor) -> None:
Expand All @@ -406,6 +408,15 @@ def in_started(self, message: Any, sender: RhasspyActor) -> None:
intent = self.recognize(message.text)
intent["intent"]["name"] = intent["intent"]["name"] or ""
logging.debug(repr(intent))
confidence = intent["intent"]["confidence"]
if confidence < self.min_confidence:
intent["intent"]["name"] = ""

self._logger.warning(
"Intent did not meet confidence threshold: %s < %s",
confidence,
self.min_confidence,
)
except Exception:
self._logger.exception("in_started")
intent = empty_intent()
Expand Down

0 comments on commit 86e695a

Please sign in to comment.