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

Bug: <set> tag in <pattern> is deleting the multi-word input #274

Open
afaji opened this issue Sep 7, 2020 · 2 comments
Open

Bug: <set> tag in <pattern> is deleting the multi-word input #274

afaji opened this issue Sep 7, 2020 · 2 comments

Comments

@afaji
Copy link

afaji commented Sep 7, 2020

Expected Behavior

Given the following AIML:

<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">

    <category>
        <pattern> <set>place</set> SUCKS </pattern>
        <template> That is unfortunate </template>
    </category>

    <category>
        <pattern> * </pattern>
        <template> <star/> </template>
    </category>

</aiml>

and place.txt as below, where entries with multiple words exist:

Rio de Janeiro
New York
Tokyo

By entering the query below:

Rio de Janeiro rocks

It should output

Rio de Janeiro rocks

Current Behavior

By entering the query below:

Rio de Janeiro rocks

The program outputs:

Janeiro rocks.

note that the 'Rio de' is deleted for some reason. (Also reproducible with 'New York')

When the input does not match the first pattern, the system works perfectly, for example:

I like Rio de Janeiro

Steps to Reproduce

  1. Use the above .aiml and .txt
  2. Run with the following python code:
from programy.clients.embed.basic import EmbeddedDataFileBot
import sys


files = {'aiml': ['./'],
		 'sets': ['./'],
		 }

my_bot = EmbeddedDataFileBot(files)

for line in sys.stdin:
	print(my_bot.ask_question(line))

Context (Environment)

  • Version of Program-y: 4.1
  • Version of Python: 3.6.1
  • Operating System ( inc Version ): Mac 10.11.6
@EdvinJakobsson
Copy link

EdvinJakobsson commented Oct 18, 2020

I have the same problem, it seems to be a bug.

I have narrowed it down to these two patterns:

    <category>
        <pattern>* THIS</pattern>
        <template>
            found THIS! star 1: <star index="1"/>
        </template>
    </category>

    <category>
        <pattern><set name="question_starter"/></pattern>
        <template>
            doesnt matter
        </template>
    </category>

The set question_starter contains the phrase 'show me', and when entering the query 'show me this', the reply is:
'Found THIS! star 1: me.'

where the 'show' has been removed. The log looks like this:

2020-10-18 16:06:27,559  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Question (flask): show me this
2020-10-18 16:06:27,559  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Pre Processed (3a91c0c2-8a0a-41dd-972b-06f30b03cf9f): show me this
2020-10-18 16:06:27,559  root       INFO    [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Creating new conversation for client 3a91c0c2-8a0a-41dd-972b-06f30b03cf9f
2020-10-18 16:06:27,559  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Event triggered [CONVERSATION_START]
2020-10-18 16:06:27,559  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Retrieving conversation for client 3a91c0c2-8a0a-41dd-972b-06f30b03cf9f
2020-10-18 16:06:27,559  root       INFO    [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Topic pattern = [*]
2020-10-18 16:06:27,560  root       INFO    [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - No That pattern default to [*]
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - AIML Parser matching sentence [show me this], topic=[*], that=[*]
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Matching [show me this __TOPIC__ * __THAT__ *]
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Wildcard _ matched show
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     Topic NOT matched me
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   No children, consume words until next break point
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -       Topic NOT matched me
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     No match for me, trying another path
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Wildcard _ matched me
2020-10-18 16:06:27,560  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -       Topic NOT matched this
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     No match for this, trying another path
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Wildcard _ matched this
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -       Topic matched __TOPIC__
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -           Wildcard * matched *
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -             That matched __THAT__
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -               No match for *, trying another path
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -           No children, consume words until next break point
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -               That matched __THAT__
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -                 No match for *, trying another path
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -              Looking for a __THAT__, none give, no match found!
2020-10-18 16:06:27,561  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -           Found a that at the wrong place....
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -         No match for *, trying another path
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -      Looking for a __TOPIC__, none give, no match found!
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Found a topic at the wrong place....
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Found word [show] in set [QUESTION_STARTER]
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Word matched show me
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     Topic NOT matched this
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   No match for this, trying another path
2020-10-18 16:06:27,562  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Wildcard ^ matched me
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     No match for this, trying another path
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Wildcard ^ matched this
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     No match for __TOPIC__, trying another path
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   No children, consume words until next break point
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     No match for __TOPIC__, trying another path
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Found a topic at the wrong place....
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Wildcard * matched me
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     Topic NOT matched this
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -   Wildcard child matched this
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -       Topic matched __TOPIC__
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -           Wildcard * matched *
2020-10-18 16:06:27,563  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -             That matched __THAT__
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -                 Wildcard * matched *
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -                 No more words
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -                   Found a template, success!
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -               Matched 1 or more star, success!
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -           Matched that, success!
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -         Matched 1 or more star, success!
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -     Matched topic, success!
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Matched 1 or more star, success!
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -      Matches...
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -              1: Match=(Word) Node=(ONEORMORE [*]) Matched=(me)
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -              2: Match=(Word) Node=(WORD [THIS]) Matched=(this)
2020-10-18 16:06:27,564  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -              3: Match=(Topic) Node=(ONEORMORE [*]) Matched=(*)
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -              4: Match=(That) Node=(ONEORMORE [*]) Matched=(*)
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] -      Match score 50.00
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - AIML Parser evaluating template [PTEMPLATE [*] [P(0)^(0)#(0)C(0)_(0)*(0)To(0)Th(0)Te(1)]]
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - [[WORD]found] resolved to [found]
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - [[WORD]THIS!] resolved to [THIS!]
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - [[WORD]star] resolved to [star]
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - [[WORD]1:] resolved to [1:]
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Retrieving conversation for client 3a91c0c2-8a0a-41dd-972b-06f30b03cf9f
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - [[WORD]1] resolved to [1]
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Star Node [[STAR[WORD]1]] resolved to [me]
2020-10-18 16:06:27,565  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - [[STAR[WORD]1]] resolved to [me]
2020-10-18 16:06:27,566  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - [[NODE]] resolved to [found THIS! star 1: me]
2020-10-18 16:06:27,566  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Raw Response (3a91c0c2-8a0a-41dd-972b-06f30b03cf9f): found THIS! star 1: me
2020-10-18 16:06:27,566  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Processed Response (3a91c0c2-8a0a-41dd-972b-06f30b03cf9f): found THIS! star 1: me
2020-10-18 16:06:27,566  root       DEBUG   Directory does not exist, creating ../../storage/conversations
2020-10-18 16:06:27,566  root       DEBUG   Writing conversation to [../../storage/conversations/flask_3a91c0c2-8a0a-41dd-972b-06f30b03cf9f.conv]
2020-10-18 16:06:27,566  root       DEBUG   [flask] [bot] [brain] [3a91c0c2-8a0a-41dd-972b-06f30b03cf9f] - Event triggered [QUESTION_ASKED]
2020-10-18 16:06:27,567  root       DEBUG   [flask] - {'response': {'query': 'show me this', 'userId': '3a91c0c2-8a0a-41dd-972b-06f30b03cf9f', 'timestamp': 1603037187.567025, 'text': 'Found THIS! star 1: me.'}, 'status': {'code': 200, 'message': 'success'}, 'meta': {'botName': 'Program-y', 'version': '1.0.0', 'copyright': 'Copyright 2016-2019 keithsterling.com', 'authors': ['Keith Sterling']}}

@keiffster
Copy link
Owner

keiffster commented Oct 19, 2020 via email

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

3 participants