diff --git a/ovos_padatious/padaos.py b/ovos_padatious/padaos.py index e1ba110..d8ee430 100644 --- a/ovos_padatious/padaos.py +++ b/ovos_padatious/padaos.py @@ -1,6 +1,6 @@ import re from threading import Lock -from typing import Dict, List, Optional, Tuple, Union +from typing import Dict, List, Optional, Union from ovos_utils.log import LOG @@ -207,7 +207,9 @@ def _compile(self) -> None: } self.must_compile = False - def _calc_entities(self, query: str, regexes: List[re.Pattern]) -> Dict[str, str]: +from typing import Dict, List, Optional, Union, Iterator + + def _calc_entities(self, query: str, regexes: List[re.Pattern]) -> Iterator[Dict[str, str]]: """ Calculates entities from a given query using the provided regex patterns. @@ -226,7 +228,9 @@ def _calc_entities(self, query: str, regexes: List[re.Pattern]) -> Dict[str, str for k, v in match.groupdict().items() if v } - def calc_intents(self, query: str) -> Union[Dict[str, Union[str, Dict[str, str]]], None]: +from typing import Dict, List, Optional, Union, Iterator + + def calc_intents(self, query: str) -> Iterator[Dict[str, Union[str, Dict[str, str]]]]: """ Calculates intents for a given query. @@ -247,7 +251,7 @@ def calc_intents(self, query: str) -> Union[Dict[str, Union[str, Dict[str, str]] 'entities': min(entities, key=lambda x: sum(map(len, x.values()))) } - def calc_intent(self, query: str) -> Union[str, None]: + def calc_intent(self, query: str) -> Dict[str, Union[str, Dict[str, str]]]: """ Calculates the most likely intent for a given query. @@ -255,7 +259,7 @@ def calc_intent(self, query: str) -> Union[str, None]: query (str): The input query to process. Returns: - Union[str, None]: The name of the matched intent or None if no match is found. + Dict[str, Union[str, Dict[str, str]]]: A dictionary containing the intent name and entities. """ return min( self.calc_intents(query), diff --git a/ovos_padatious/simple_intent.py b/ovos_padatious/simple_intent.py index 97e7e9d..b8d3f05 100644 --- a/ovos_padatious/simple_intent.py +++ b/ovos_padatious/simple_intent.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import List, Tuple, Optional +from typing import List, Optional from fann2 import libfann as fann from ovos_padatious.id_manager import IdManager