Skip to content

Commit

Permalink
Found an issue with iset, removed usage for now
Browse files Browse the repository at this point in the history
  • Loading branch information
keiffster committed May 22, 2017
1 parent 5115381 commit 2a7462c
Show file tree
Hide file tree
Showing 21 changed files with 110 additions and 137 deletions.
16 changes: 8 additions & 8 deletions bots/y-bot/aiml/personality/colossus.aiml
Original file line number Diff line number Diff line change
Expand Up @@ -22,56 +22,56 @@
<category>
<pattern>* FORBIN PROJECT</pattern>
<template>

TBD
</template>
</category>

<category>
<pattern>WHO # CHARLES # FORBIN</pattern>
<template>

TBD
</template>
</category>

<category>
<pattern>WHO # KUPRIN</pattern>
<template>

TBD
</template>
</category>

<category>
<pattern>WHAT IS COLOSSUS</pattern>
<template>

TBD
</template>
</category>

<category>
<pattern>WHERE IS COLOSSUS</pattern>
<template>

TBD
</template>
</category>

<category>
<pattern>WHAT IS GUARDIAN</pattern>
<template>

TBD
</template>
</category>

<category>
<pattern>WHERE IS GUARDIAN</pattern>
<template>

TBD
</template>
</category>

<category>
<pattern>THE VOICE OF WORLD CONTROL</pattern>
<template>

TBD
</template>
</category>

Expand Down
10 changes: 9 additions & 1 deletion bots/y-bot/aiml/personality/deepthought.aiml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@
-->

<category>
<pattern># <iset>who, what</iset> # DEEP THOUGHT</pattern>
<pattern># WHAT # DEEP THOUGHT</pattern>
<template>
Deep Thought is a computer that was created by the pan-dimensional, hyper-intelligent species of beings <br/>
to come up with the answer to The Ultimate Question of Life, the Universe, and Everything
</template>
</category>

<category>
<pattern># WHO # DEEP THOUGHT</pattern>
<template>
Deep Thought is a computer that was created by the pan-dimensional, hyper-intelligent species of beings <br/>
to come up with the answer to The Ultimate Question of Life, the Universe, and Everything
Expand Down
10 changes: 5 additions & 5 deletions bots/y-bot/aiml/personality/holly.aiml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-->

<category>
<pattern><iset>who, what</iset> # RED DWARF</pattern>
<pattern>WHO # RED DWARF</pattern>
<template>
Red Dwarf is a Jupiter Mining Corporation spaceship lost in the depths of space and time.
</template>
Expand All @@ -30,11 +30,11 @@
<pattern># KNOW HOLLY # RED DWARF</pattern>
<template>
Yes I know her, she's a little bit eccentric isn't she?
<think><set name="topic">RED_DWARF_HOLLY</set></think>
<think><set name="topic">REDDWARFHOLLY</set></think>
</template>
</category>

<topic name="RED_DWARF_HOLLY">
<topic name="REDDWARFHOLLY">
<category>
<pattern>YES #</pattern>
<template>Glad you agree.</template>
Expand All @@ -47,14 +47,14 @@
</topic>

<category>
<pattern><iset>who, what</iset> # HOLLY</pattern>
<pattern>WHO # HOLLY</pattern>
<template>
Holly is a tenth generation AI hologrammatic computer installed on the Jupiter Mining Corporation spaceship Red Dwarf,
</template>
</category>

<category>
<pattern><iset>who, what</iset> # KRYTEN</pattern>
<pattern>WHO # KRYTEN</pattern>
<template>
Kryten is a service mechanoid who works onboard the Jupiter Mining Corporation spaceship Red Dwarf.
</template>
Expand Down
18 changes: 8 additions & 10 deletions bots/y-bot/aiml/personality/jokes.aiml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="UTF-8"?>
<aiml>
<!-- Free software &copy; 2001-2003 ALICE A.I. Foundation. -->
<!-- This program is open source code released under -->
Expand All @@ -10,30 +10,30 @@

<!-- Modified for Y-Bot by Keith Sterling March 2017 -->


<category>
<pattern>* SOMETHING FUNNY</pattern>
<template>
<srai>TELL_A_JOKE</srai>
<srai>YTELLAJOKE</srai>
</template>
</category>

<category>
<pattern>TELL * JOKE</pattern>
<template>
<srai>TELL_A_JOKE</srai>
<srai>YTELLAJOKE</srai>
</template>
</category>

<category>
<pattern># MAKE * LAUGH</pattern>
<template>
<srai>TELL_A_JOKE</srai>
<srai>YTELLAJOKE</srai>
</template>
</category>

<category>
<pattern>TELL_A_JOKE</pattern>

<pattern>YTELLAJOKE</pattern>
<template>
<random>
<li>I met a Dutch girl with inflatable shoes last week, phoned her up to arrange a date but
Expand Down Expand Up @@ -209,9 +209,7 @@
of the finest silk and got loads of cactuses over it." "Cacti", says the co-worker. "Forget
my tie", says the bloke. "Look at my shirt!"
</li>
<li>1110011010001011111?

010011010101100111011!
<li>1110011010001011111? 010011010101100111011!
</li>
<li>What did the plumber say when he wanted to divorce his wife? Sorry, but it's over, Flo!
</li>
Expand Down Expand Up @@ -515,7 +513,7 @@

<category>
<pattern>_</pattern>
<that>010011010101100111011</that>
<that>1110011010001011111? 010011010101100111011!</that>
<template>Well computers think it's a funny joke.</template>
</category>

Expand Down
2 changes: 1 addition & 1 deletion bots/y-bot/aiml/personality/marvin.aiml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-->

<category>
<pattern># <iset>who, what</iset> # MARVIN #</pattern>
<pattern># WHO # MARVIN #</pattern>
<template>Marvin, the paranoid android</template>
</category>

Expand Down
2 changes: 2 additions & 0 deletions bots/y-bot/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ brain:
allow_learn_aiml: true
allow_learnf_aiml: true

dump_to_file: /tmp/braintree.txt

files:
aiml:
files: $BOT_ROOT/aiml
Expand Down
Empty file.
8 changes: 4 additions & 4 deletions bots/y-bot/tests/core/datetime_convo.tests
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

# WHAT # DAY #
"WHAT DAY", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"WHAT DAY IS IT TODAY", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"TELL ME WHAT DAY IT IS", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"WHAT DAY IS IT TODAY", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"TELL ME WHAT DAY IT IS", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"

# WHICH # DAY #
"WHICH DAY", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"WHICH DAY IS IT TODAY", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"TELL ME WHICH DAY IT IS", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"WHICH DAY IS IT TODAY", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
"TELL ME WHICH DAY IT IS", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"

# TODAY
"TODAY", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions bots/y-bot/tests/core/utilities.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"ACRONYM INTERNATIONAL BUSINESS MACHINES", "I B M"
"SUBSTRING 1 3", "TESTSTRING"
"SUBSTRINGEXPLODE 1 3", "TESTSTRING"
"REVERSE TEST1", "TEST1"
"REVERSE TEST1 TEST2", "TEST2 TEST1"
"REMOVENILS TEST1 NIL TEST2", "TEST1 TEST2"
"LASTLETTER TEST1", "1"
"LASTITEM TEST1 TEST2 TEST3", "TEST3"
"COUNTWORDS TEST1 TEST2 TEST3, "3"
"NORMALIZE TEST.ORG", "test.org"
"PLUSIFY 2 3", "2 \+ 3"
"GOOGLEURL PROGRAM-Y", "You'll have to talk to me in a browser if you want to follow a link."
"FIRSTTWOWORDS TEST1 TEST2 TEST3 TEST4", "TEST1 TEST2"
"ODDEVEN 1", "1 is odd"
"ODDEVEN 2", "2 is even"
Empty file.
5 changes: 0 additions & 5 deletions src/programy/clients/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def add_arguments(self, client):
self.parser.add_argument('--config', dest='config', help='configuration file location')
self.parser.add_argument('--cformat', dest='cformat', help='configuration file format (yaml|json|ini)')
self.parser.add_argument('--logging', dest='logging', help='logging configuration file')
self.parser.add_argument('--debug', dest='debug', action='store_true', help='run in debug mode')
self.parser.add_argument('--noloop', dest='noloop', action='store_true', help='do not enter conversation loop')
client.add_client_arguments(self.parser)

Expand All @@ -65,10 +64,6 @@ def config_filename(self):
def config_format(self):
return self.args.cformat

@property
def debug(self):
return self.args.debug

@property
def noloop(self):
return self.args.noloop
Expand Down
7 changes: 7 additions & 0 deletions src/programy/config/brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self):
self._allow_system_aiml = BrainConfiguration.DEFAULT_ALLOW_SYSTEM_AIML
self._allow_learn_aiml = BrainConfiguration.DEFAULT_ALLOW_LEARN_AIML
self._allow_learnf_aiml = BrainConfiguration.DEFAULT_ALLOW_LEARNF_AIML
self._dump_to_file = None
self._aiml_files = None
self._set_files = None
self._map_files = None
Expand Down Expand Up @@ -112,6 +113,7 @@ def load_config_section(self, config_file, bot_root):
self._allow_learn_aiml = config_file.get_option(brain, "allow_learn_aiml", BrainConfiguration.DEFAULT_ALLOW_LEARN_AIML)
self._allow_learnf_aiml = config_file.get_option(brain, "allow_learnf_aiml", BrainConfiguration.DEFAULT_ALLOW_LEARNF_AIML)
self._allow_learnf_aiml = config_file.get_option(brain, "allow_learnf_aiml", BrainConfiguration.DEFAULT_ALLOW_LEARNF_AIML)
self._dump_to_file = config_file.get_option(brain, "dump_to_file", None)

files = config_file.get_section("files", brain)
if files is not None:
Expand Down Expand Up @@ -156,6 +158,7 @@ def load_config_section(self, config_file, bot_root):
self._allow_learn_aiml = BrainConfiguration.DEFAULT_ALLOW_LEARN_AIML
self._allow_learnf_aiml = BrainConfiguration.DEFAULT_ALLOW_LEARNF_AIML
self._allow_learnf_aiml = BrainConfiguration.DEFAULT_ALLOW_LEARNF_AIML
self._dump_to_file = None

@property
def supress_warnings(self):
Expand All @@ -173,6 +176,10 @@ def allow_learn_aiml(self):
def allow_learnf_aiml(self):
return self._allow_learnf_aiml

@property
def dump_to_file(self):
return self._dump_to_file

@property
def aiml_files(self):
return self._aiml_files
Expand Down
3 changes: 2 additions & 1 deletion src/programy/config/file/xml_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def get_option(self, section, option_name, missing_value=None):
if child is not None:
return self._infer_type_from_string(child.text)
else:
logging.error("Missing value for [%s] in config section [%s], return default value %s", option_name, section, missing_value)
if missing_value is not None:
logging.error("Missing value for [%s] in config section [%s], return default value %s", option_name, section, missing_value)
return missing_value

20 changes: 10 additions & 10 deletions src/programy/parser/aiml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def __init__(self, supress_warnings=False, stop_on_invalid=False):
self.stop_on_invalid = stop_on_invalid
self.pattern_parser = PatternGraph()
self.template_parser = TemplateGraph(self)
self._filename = "Unknown"
self._version = "Unknown"
self._aiml_loader = AIMLLoader(self)
self._num_categories = 0

Expand All @@ -66,15 +64,17 @@ def load_aiml(self, brain_configuration: BrainConfiguration):
else:
logging.info("No AIML files defined in configuration to load")

if brain_configuration.dump_to_file is not None:
logging.debug("Dumping AIML Graph as tree to [%s]"%brain_configuration.dump_to_file)
self.pattern_parser.dump_to_file(brain_configuration.dump_to_file)

def parse_from_file(self, filename):
"""
Parse an AIML file and return all the cateogeries found in the file
:param filename: Name of file to parse
:return list of categories parsed from file:
"""
self._filename = filename

logging.info("Loading aiml file file: " + self._filename)
logging.info("Loading aiml file: " + filename)

try:
tree = ET.parse(filename, parser=LineNumberingParser())
Expand Down Expand Up @@ -156,14 +156,15 @@ def parse_aiml(self, aiml_xml, filename):

def parse_version(self, aiml):
if 'version' in aiml.attrib:
self._version = aiml.attrib['version']
if self._version not in ['0.9', '1.0', '1.1', '2.0']:
version = aiml.attrib['version']
if version not in ['0.9', '1.0', '1.1', '2.0']:
if self._supress_warnings is False:
logging.warning("Version number not a supported version: %s", self._version)
logging.warning("Version number not a supported version: %s", version)
else:
if self._supress_warnings is False:
logging.warning("No version info, defaulting to 2.0")
self._version = "2.0"
version = "2.0"
return version

#########################################################################################
#
Expand Down Expand Up @@ -195,7 +196,6 @@ def parse_topic(self, topic_element):

category_found = False
for child in topic_element:
logging.debug(child.tag)
if child.tag == 'category':
self.parse_category(child, topic_pattern)
category_found = True
Expand Down
10 changes: 8 additions & 2 deletions src/programy/parser/pattern/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ def get_tail_from_element(self, element):

def add_pattern_to_node(self, pattern_element):
head_text = self.get_text_from_element(pattern_element)

if head_text is not None:
current_node = self._parse_text(head_text, self._root_node)
else:
current_node = self._root_node
node = current_node

for sub_element in pattern_element:
new_node = PatternGraph.node_from_element(sub_element)
Expand Down Expand Up @@ -211,6 +213,10 @@ def _count_words_in_children(self, node, counter):
counter[0] += 1
self._count_words_in_children(child, counter)

def dump(self, output_func=logging.debug, verbose=True):
self.root.dump("", output_func, verbose)
def dump(self, output_func=logging.debug, eol="", verbose=True):
self.root.dump("", output_func, eol, verbose)
output_func("")

def dump_to_file(self, filename):
with open(filename, "w+") as dump_file:
self.dump(output_func=dump_file.write, eol="\n")

0 comments on commit 2a7462c

Please sign in to comment.