keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
349 stars 137 forks source link

Setting SentenceSplitter on an embedded bot #294

Closed LazyRacc00n closed 3 years ago

LazyRacc00n commented 3 years ago

Hi, I need to disable and enable the sentence splitter like it is described here, but I don't see how can i set the dynamic variable splitter through the dictionary used to configure the bot.

I create the bot like in the following piece of code:

files = {'aiml': ['y-bot/storage/categories'], 'learnf': ['y-bot/storage/categories/learnf'], 'properties': 'y-bot/storage/properties/properties.txt', 'defaults': 'y-bot/storage/properties/defaults.txt', 'sets': ['y-bot/storage/sets'], 'maps': ['y-bot/storage/maps'], 'rdfs': ['y-bot/storage/rdfs'], 'denormals': 'y-bot/storage/lookups/denormal.txt', 'normals': 'y-bot/storage/lookups/normal.txt', 'genders': 'y-bot/storage/lookups/gender.txt', 'persons': 'y-bot/storage/lookups/person.txt', 'person2s': 'y-bot/storage/lookups/person2.txt', 'regexes': 'y-bot/storage/regex/regex-templates.txt', 'spellings': 'y-bot/storage/spelling/corpus.txt', 'preprocessors': 'y-bot/storage/processing/preprocessors.conf', 'postprocessors': 'y-bot/storage/processing/postprocessors.conf', 'postquestionprocessors': 'y-bot/storage/processing/postquestionprocessors.conf' }

chatbot = EmbeddedDataFileBot(files, defaults=True)

What can I do?

Thanks in advance

keiffster commented 3 years ago

Do you want to do it in Python or in AIML Grammar ?

On 8 Jun 2021, at 10:14, LazyRac00n @.***> wrote:

Hi, I need to disable and enable the sentence splitter like it is described here https://github.com/keiffster/program-y/wiki/Sentence-Splitting, but I don't see how can i set the dynamic variable splitter through the dictionary used to configure the bot.

I create the bot like in the following piece of code:

  files = {'aiml': ['y-bot/storage/categories'],
 'learnf': ['y-bot/storage/categories/learnf'],
 'properties': 'y-bot/storage/properties/properties.txt',
 'defaults': 'y-bot/storage/properties/defaults.txt',
 'sets': ['y-bot/storage/sets'],
 'maps': ['y-bot/storage/maps'],
 'rdfs': ['y-bot/storage/rdfs'],
 'denormals': 'y-bot/storage/lookups/denormal.txt',
 'normals': 'y-bot/storage/lookups/normal.txt',
 'genders': 'y-bot/storage/lookups/gender.txt',
 'persons': 'y-bot/storage/lookups/person.txt',
 'person2s': 'y-bot/storage/lookups/person2.txt',
 'regexes': 'y-bot/storage/regex/regex-templates.txt',
 'spellings': 'y-bot/storage/spelling/corpus.txt',
 'preprocessors': 'y-bot/storage/processing/preprocessors.conf',
 'postprocessors': 'y-bot/storage/processing/postprocessors.conf',
 'postquestionprocessors': 'y-bot/storage/processing/postquestionprocessors.conf'
 }

chatbot = EmbeddedDataFileBot(files, defaults=True) What can I do?

Thanks in advance

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/keiffster/program-y/issues/294, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCUFM2SOB3BPAWVFRRNZGTTRXNNXANCNFSM46JPA55A.

LazyRacc00n commented 3 years ago

I would like to do it in AIML grammar using such categories:


<category>
    <pattern>SET THE SPLITTER OFF</pattern>
    <template>
        <think>
            <set name="splitter">OFF</set>
        </think>
    </template>
</category>

<category>
    <pattern>SET THE SPLITTER ON</pattern>
    <template>
        <think>
            <set name="splitter">ON</set>
        </think>
    </template>
</category>

But loading the bot like I described before they don't work

Do you want to do it in Python or in AIML Grammar ? On 8 Jun 2021, at 10:14, LazyRac00n @.***> wrote: Hi, I need to disable and enable the sentence splitter like it is described here https://github.com/keiffster/program-y/wiki/Sentence-Splitting, but I don't see how can i set the dynamic variable splitter through the dictionary used to configure the bot. I create the bot like in the following piece of code: files = {'aiml': ['y-bot/storage/categories'], 'learnf': ['y-bot/storage/categories/learnf'], 'properties': 'y-bot/storage/properties/properties.txt', 'defaults': 'y-bot/storage/properties/defaults.txt', 'sets': ['y-bot/storage/sets'], 'maps': ['y-bot/storage/maps'], 'rdfs': ['y-bot/storage/rdfs'], 'denormals': 'y-bot/storage/lookups/denormal.txt', 'normals': 'y-bot/storage/lookups/normal.txt', 'genders': 'y-bot/storage/lookups/gender.txt', 'persons': 'y-bot/storage/lookups/person.txt', 'person2s': 'y-bot/storage/lookups/person2.txt', 'regexes': 'y-bot/storage/regex/regex-templates.txt', 'spellings': 'y-bot/storage/spelling/corpus.txt', 'preprocessors': 'y-bot/storage/processing/preprocessors.conf', 'postprocessors': 'y-bot/storage/processing/postprocessors.conf', 'postquestionprocessors': 'y-bot/storage/processing/postquestionprocessors.conf' } chatbot = EmbeddedDataFileBot(files, defaults=True) What can I do? Thanks in advance — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#294>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCUFM2SOB3BPAWVFRRNZGTTRXNNXANCNFSM46JPA55A.

keiffster commented 3 years ago

I have a suite of tests around this in the code and its working fine

program-y/test/programytest/aiml_tests/dynamic_tests/system/test_system_aiml.py

Can you provide some more detail, example AIML file etc

K

On 8 Jun 2021, at 13:32, LazyRac00n @.***> wrote:

I would like to do it in AIML grammar using such categories:

SET THE SPLITTER OFF SET THE SPLITTER ON
LazyRacc00n commented 3 years ago

I have an AIML file with only these categories

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

<category>
    <pattern>MY NAME IS *</pattern>
    <template>Nice to meet you, <set name="username"><star/></set></template>
</category>

<category>
    <pattern>SET THE SPLITTER OFF</pattern>
    <template>
        <think>
            <set name="splitter">OFF</set>
        </think>
    </template>
</category>

<category>
    <pattern>SET THE SPLITTER ON</pattern>
    <template>
        <think>
            <set name="splitter">ON</set>
        </think>
    </template>
</category>

<category>
    <pattern>*</pattern>
    <template> I don’t understand </template>
</category>

</aiml>

I create the bot in a python file in this way and I feed the chatbot with the following questions


# define folders containing the main files
    files = {'aiml': ['y-bot/storage/categories'],
         'learnf': ['y-bot/storage/categories/learnf'],
         'properties': 'y-bot/storage/properties/properties.txt',
         'defaults': 'y-bot/storage/properties/defaults.txt',
         'sets': ['y-bot/storage/sets'],
         'maps': ['y-bot/storage/maps'],
         'rdfs': ['y-bot/storage/rdfs'],
         'denormals': 'y-bot/storage/lookups/denormal.txt',
         'normals': 'y-bot/storage/lookups/normal.txt',
         'genders': 'y-bot/storage/lookups/gender.txt',
         'persons': 'y-bot/storage/lookups/person.txt',
         'person2s': 'y-bot/storage/lookups/person2.txt',
         'regexes': 'y-bot/storage/regex/regex-templates.txt',
         'spellings': 'y-bot/storage/spelling/corpus.txt',
         'preprocessors': 'y-bot/storage/processing/preprocessors.conf',
         'postprocessors': 'y-bot/storage/processing/postprocessors.conf',
         'postquestionprocessors': 'y-bot/storage/processing/postquestionprocessors.conf'
         }

    chatbot = EmbeddedDataFileBot(files, defaults=True) 

    chatbot.ask_question("set the splitter off")
    print(chatbot.ask_question("My name is alice.bob"))

the print shows up "Nice to meet you, alice. I don’t understand.", which means that the original sentence is divided into two pieces.

It seems that the dynamic variable "splitter" is not related to the sentence splitter

I have a suite of tests around this in the code and its working fine program-y/test/programytest/aiml_tests/dynamic_tests/system/test_system_aiml.py Can you provide some more detail, example AIML file etc K On 8 Jun 2021, at 13:32, LazyRac00n @.***> wrote: I would like to do it in AIML grammar using such categories: SET THE SPLITTER OFF SET THE SPLITTER ON