home-assistant / intents

Intents to be used with Home Assistant
https://developers.home-assistant.io/docs/voice/overview/
Creative Commons Attribution 4.0 International
455 stars 518 forks source link

Help with debugging - can't find error #1574

Closed andrejs2 closed 1 year ago

andrejs2 commented 1 year ago

Hi! Trying to find error in file test_light_HassTurnOff[sl] but this file doesn't have any (okn(o|a|i]) in.

ERROR tests/test_language_intents.py::test_light_HassTurnOff[sl] - hassil.parser.ParseError: Unable to find end of group ')' from index 0 in: (okn(o|a|i])
`
_____________________________ ERROR at setup of test_light_HassTurnOff[sl] ______________________________

language = 'sl'
language_sentences_yaml = {'_common.yaml': {'expansion_rules': {'area': '[v [prostoru] | na] {area} [sobi]', 'brightness': '{brightness} [procen...nces': [...], 'slots': {...}}, {'response': 'how_many', 'sentences': [...], 'slots': {...}}]}}, 'language': 'sl'}, ...}

    @pytest.fixture(name="language_sentences_common", scope="session")
    def language_sentences_common_fixture(
        language: str,
        language_sentences_yaml: dict[str, Any],
    ) -> Intents:
        """Loads the common language intents."""
        language_sentences_yaml["_common.yaml"].setdefault("intents", {})
>       return Intents.from_dict(language_sentences_yaml["_common.yaml"])

tests/conftest.py:50: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/vscode/.local/lib/python3.10/site-packages/hassil/intents.py:260: in from_dict
    slot_lists={
/home/vscode/.local/lib/python3.10/site-packages/hassil/intents.py:261: in <dictcomp>
    list_name: _parse_list(list_dict)
/home/vscode/.local/lib/python3.10/site-packages/hassil/intents.py:296: in _parse_list
    text_in=_maybe_parse_template(value["in"], allow_template),
/home/vscode/.local/lib/python3.10/site-packages/hassil/intents.py:331: in _maybe_parse_template
    return parse_sentence(text)
/home/vscode/.local/lib/python3.10/site-packages/hassil/parse_expression.py:194: in parse_sentence
    chunk = next_chunk(text)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

text = '(okn(o|a|i])', start_index = 0

    def next_chunk(text: str, start_index: int = 0) -> Optional[ParseChunk]:
        """Gets the next parsable chunk from text."""
        next_type = peek_type(text, start_index)

        if next_type == ParseType.WORD:
            # Single word
            word_end_index = find_end_word(text, start_index)
            if word_end_index is None:
                raise ParseError(
                    f"Unable to find end of word from index {start_index} in: {text}"
                )

            word_text = remove_escapes(text[start_index:word_end_index])

            return ParseChunk(
                text=word_text,
                start_index=start_index,
                end_index=word_end_index,
                parse_type=ParseType.WORD,
            )

        if next_type == ParseType.GROUP:
            # Skip '('
            group_start_index = skip_text(text, start_index, GROUP_START)
            group_end_index = find_end_delimiter(
                text, group_start_index, GROUP_START, GROUP_END
            )
            if group_end_index is None:
>               raise ParseError(
                    f"Unable to find end of group ')' from index {start_index} in: {text}"
                )
E               hassil.parser.ParseError: Unable to find end of group ')' from index 0 in: (okn(o|a|i])

/home/vscode/.local/lib/python3.10/site-packages/hassil/parser.py:207: ParseError
======================================== short test summary info ========================================
ERROR tests/test_language_intents.py::test_light_HassTurnOff[sl] - hassil.parser.ParseError: Unable to find end of group ')' from index 0 in: (okn(o|a|i])
ERROR tests/test_language_sentences.py::test_light_HassTurnOff[sl] - hassil.parser.ParseError: Unable to find end of group ')' from index 0 in: (okn(o|a|i])
=================================== 43 deselected, 2 errors in 0.42s ====================================

 *  The terminal process "/bin/bash '-c', 'script/test_file sentences/sl/light_HassTurnOff.yaml'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

The file (under tests) light_HassTurnOff

language: sl
intents:
  HassTurnOff:
    data:
      - sentences:
          - "<izključi> (<luč[i|ke|ko|ki]|svetilo|razsvetljavo|svetilko>) [v|na] [sobi|prostoru] <area>"
          - "<izključi> [vse] [luči|svetilke] [v] <area>"
          - "<izključi> [vsa] [svetila] [v] <area>"
          - "<izključi> [vso] [razsvetljavo] [v] <area>"
        slots:
          domain: "light"
        response: lights_area
andrejs2 commented 1 year ago

Found in common file...