hassil icon indicating copy to clipboard operation
hassil copied to clipboard

Having a wildcard at the end of sentence creates weird results

Open salleq opened this issue 1 year ago • 0 comments

#tests #1
language: fi
tests:
  - sentences:
      - laita omena minun ostoslistalleni
      - laita omena listalle
      - lisää omena ostoslistalle
# Below sentences create an error
      - lisää mun ostoslistalle omena
      - laita miun ostoslistalle omena

    intent:
      name: HassShoppingListAddItem
      slots:
        item: "omena "
    response: "omena lisätty"
#sentence
language: "fi"
intents:
  HassShoppingListAddItem:
    data:
      - sentences:
          - (lisää|laita) <item> <my_list>
          - (lisää|laita) <my_list> <item>
        response: item_added
        expansion_rules:
          my_list: "[minun|mun|miun] [ostos]lista[lle|lleni|llemme] "
          item: "{shopping_list_item:item}"

This is the error I get when running tests with:

pytest tests --language fi -k HassShoppingListAdd
E                           AssertionError: Expected omena, got omena  for slot item for: lisää mun ostoslistalle omena
E                           assert 'omena ' == 'omena'
E                             - omena
E                             + omena 
E                             ?      +

I would expect all test go through, but the sentences where the word "omena" ("apple") is last, it needs to be added without the whitespace at end. The below works:

#tests #2
language: fi
tests:
  - sentences:
      - laita omena minun ostoslistalleni
      - laita omena listalle
      - lisää omena ostoslistalle

    intent:
      name: HassShoppingListAddItem
      slots:
        item: "omena "
    response: "omena lisätty"

  # Below sentences only work when the item is given without the whitespace in the end.
  - sentences:
      - lisää mun ostoslistalle omena
      - laita miun ostoslistalle omena

    intent:
      name: HassShoppingListAddItem
      slots:
        item: "omena"
    response: "omena lisätty"

salleq avatar Jan 04 '24 20:01 salleq