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

Mismatched intent for garage doors #1472

Open
tetele opened this issue Jul 28, 2023 · 0 comments
Open

Mismatched intent for garage doors #1472

tetele opened this issue Jul 28, 2023 · 0 comments

Comments

@tetele
Copy link
Contributor

tetele commented Jul 28, 2023

The issue is for Romanian, but if I try hard enough, I can also get it replicated for English as well. There is a conflict between the device class name garage door and the commonly named garage area.

A sentence like is there any garage door open? would match the English-equivalent is there any <area> <domain/device_class> <state>? given area=garage, device_class=door and state=open

I have the following:

sentences/ro/binary_sensor_HassGetState.yaml

intents:
  HassGetState:
    data:
      - sentences:
          - "<exista_class_state_in_zona>"
        expansion_rules:
          class_singular: "<usa>" # the door
          class_plural: "<usile>" # the doors
          state_singular: "{bs_door_states_singular:state}"
          state_plural: "{bs_door_states_plural:state}"
        response: any
        slots:
          domain: binary_sensor
          device_class: door
      - sentences:
          - "<exista_class_state_in_zona>"
        expansion_rules:
          class_singular: "(<usa>|<poarta>) [(de [la] garaj|garajului)]" # the garage door/gate
          class_plural: "(<usile>|<portile>) [(de [la] garaj|garajului)]" # the garage doors/gates
          state_singular: "{bs_door_states_singular:state}"
          state_plural: "{bs_door_states_plural:state}"
        response: any
        slots:
          domain: binary_sensor
          device_class: garage_door

sentences/ro/_common.yaml

lists:
  bs_door_states_singular:
    values:
      - in: "<deschis>"
        out: "on"
      - in: "<inchis>"
        out: "off"
  bs_door_states_plural:
    values:
      - in: "<deschise>"
        out: "on"
      - in: "<inchise>"
        out: "off"
expansion_rules:
  # (is|are) there any <class> <state> in <area>
  exista_class_state_in_zona: "(<exista> ([<vreun>] <class_singular>; <state_singular>; [<din> <area>]) | (sunt | exist(ă|a)) (<class_plural>; <state_plural>; [<din> <area>]))"
  este: "e[ste]" # is
  exista: "(<este>|exist(ă|a))" # exists
  usa: "u(ș|s)(ă|a)" # [the] door
  usile: "u(ș|s)i[le]" # [the] doors
  poarta: "poart(ă|a)" # [the] gate
  portile: "por(ț|t)i[le]" # [the] gates
  deschis: "(deschis[(ă|a)] | ridicat[(ă|a)])" # open
  deschise: "(deschise | ridicate)" # open (plural)
  inchis: "((î|i)nchis[(ă|a)] | coboar(â|a)t[(ă|a)])" # closed
  inchise: "((î|i)nchise | coboar(â|a)te)" #closed (plural)
  din: "(din | (î|i)n | pentru | [de] la | [de] pe | de)" # from/in - used particularly for areas
  area: "[(zona | regiunea | spa(ț|t)iul)] {area}"

tests/ro/_fixtures.yaml

areas:
  - name: "Garaj"
    id: garage
entities:
  - name: "Usa secundara garaj"
    id: binary_sensor.second_garage_door
    state:
      in: "inchis"
      out: "off"
    attributes:
      device_class: garage_door

tests/ro/binary_sensor_HassGetState.yaml

tests:
  - sentences:
      - "exista usi de garaj inchise?"
    intent:
      name: HassGetState
      slots:
        domain: binary_sensor
        device_class: garage_door
        state: "off"
    response: "Da, Usa secundara garaj"

The tests fail by matching the door intent sentence, instead of the garage_door sentence, due to the fact that I have a (very commonly named) Garaj area, which is also part of the garage_door device class name:

FAILED tests/test_language_sentences.py::test_binary_sensor_HassGetState[ro] - AssertionError: Missing slot area for: exista usi de garaj inchise? (value=Garaj)
@tetele ➜ /workspaces/intents (ro-binary-sensor-extra ✗) $ python3 -m script.intentfest parse --language ro --sentence 'exista usi de garaj inchise?'
{
  "text": "exista usi de garaj inchise?",
  "match": true,
  "intent": "HassGetState",
  "slots": {
    "area": "Garaj",
    "state": "off",
    "domain": "binary_sensor",
    "device_class": "door"
  },
  "context": {},
  "response_key": "any",
  "response": "Nu"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant