Skip to content

Commit

Permalink
Y-Bot has a number of examples added, with full AIML and Python <exte…
Browse files Browse the repository at this point in the history
…nsion>'s to support external data retrieval and storage
  • Loading branch information
keiffster committed Mar 22, 2017
1 parent e892041 commit be21942
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 40 deletions.
40 changes: 0 additions & 40 deletions bots/y-bot/aiml/extensions/wine/recomender.aiml

This file was deleted.

35 changes: 35 additions & 0 deletions bots/y-bot/src/extensions/energy/usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Copyright (c) 2016 Keith Sterling
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

"""
This is an example extension that allow syou to call an external service to retreive the bank balance
of the customer. Currently contains no authentication
"""
import logging

class BankingBalanceExtension(object):

# execute() is the interface that is called from the <extension> tag in the AIML
def execute(self, data):
logging.debug ("Bank Balance - Calling external service for with extra data [%s]"%(data))

#
# Add the logic to receive the balance and format it into pounds and pence and either CREDIT|DEBIT
#
#

return "0 00 CREDIT"
File renamed without changes.
35 changes: 35 additions & 0 deletions bots/y-bot/src/extensions/survey/survey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Copyright (c) 2016 Keith Sterling
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

"""
This is an example extension that allow you to call an external service to retreive the energy consumption data
of the customer. Currently contains no authentication
"""
import logging

class EnergyUsageExtension(object):

# execute() is the interface that is called from the <extension> tag in the AIML
def execute(self, data):
logging.debug ("Energy Usage - Calling external service for with extra data [%s]"%(data))

#
# Add the logic to receive the balance and format it into KWh for Gas and Electricity consumption
#
#

return "0 0 KWh"
35 changes: 35 additions & 0 deletions bots/y-bot/src/extensions/telecoms/minutes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Copyright (c) 2016 Keith Sterling
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

"""
This is an example extension that allow syou to call an external service to retreive the bank balance
of the customer. Currently contains no authentication
"""
import logging

class BankingBalanceExtension(object):

# execute() is the interface that is called from the <extension> tag in the AIML
def execute(self, data):
logging.debug ("Bank Balance - Calling external service for with extra data [%s]"%(data))

#
# Add the logic to receive the balance and format it into pounds and pence and either CREDIT|DEBIT
#
#

return "0 00 CREDIT"
Empty file.
25 changes: 25 additions & 0 deletions bots/y-bot/src/test/extensions/energy/test_aiml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest
import os
from test.aiml_tests.client import TestClient
from programy.config.brain import BrainFileConfiguration


class BankBalanceTestsClient(TestClient):

def __init__(self):
TestClient.__init__(self, debug=True)

def load_configuration(self, arguments):
super(BankBalanceTestsClient, self).load_configuration(arguments)
self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(os.path.dirname(__file__)+"/../../../../aiml/extensions/banking", ".aiml", False)

class BankBalanceAIMLTests(unittest.TestCase):

def setUp (self):
BankBalanceAIMLTests.test_client = BankBalanceTestsClient()

def test_balance(self):
response = BankBalanceAIMLTests.test_client.bot.ask_question("testif", "WHAT IS MY BANK BALANCE")
self.assertIsNotNone(response)
self.assertEqual(response, 'Your bank balance is currently £0.00.')

14 changes: 14 additions & 0 deletions bots/y-bot/src/test/extensions/energy/test_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import unittest

from extensions.banking.balance import BankingBalanceExtension

class BankBalanceExtensionTests(unittest.TestCase):

def test_balance(self):

balance = BankingBalanceExtension()
self.assertIsNotNone(balance)

result = balance.execute("NOW")
self.assertIsNotNone(result)
self.assertEqual("0.00", result)
Empty file.
25 changes: 25 additions & 0 deletions bots/y-bot/src/test/extensions/survey/test_aiml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest
import os
from test.aiml_tests.client import TestClient
from programy.config.brain import BrainFileConfiguration


class TelecomsMinutesTestsClient(TestClient):

def __init__(self):
TestClient.__init__(self, debug=True)

def load_configuration(self, arguments):
super(TelecomsMinutesTestsClient, self).load_configuration(arguments)
self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(os.path.dirname(__file__)+"/../../../../aiml/extensions/telecoms", ".aiml", False)

class TelecomsMinutesAIMLTests(unittest.TestCase):

def setUp (self):
TelecomsMinutesAIMLTests.test_client = TelecomsMinutesTestsClient()

def test_balance(self):
response = TelecomsMinutesAIMLTests.test_client.bot.ask_question("testif", "HOW MANY MINUTES DO I HAVE LEFT")
self.assertIsNotNone(response)
self.assertEqual(response, 'This month you have 0 minutes available and have consumed 0 minutes.')

14 changes: 14 additions & 0 deletions bots/y-bot/src/test/extensions/survey/test_survey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import unittest

from extensions.telecoms.minutes import TelecomMinutesExtension

class BankBalanceExtensionTests(unittest.TestCase):

def test_balance(self):

minutes = TelecomMinutesExtension()
self.assertIsNotNone(minutes)

result = minutes.execute("NOW")
self.assertIsNotNone(result)
self.assertEqual("0 0", result)
Empty file.
25 changes: 25 additions & 0 deletions bots/y-bot/src/test/extensions/telecoms/test_aiml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest
import os
from test.aiml_tests.client import TestClient
from programy.config.brain import BrainFileConfiguration


class BankBalanceTestsClient(TestClient):

def __init__(self):
TestClient.__init__(self, debug=True)

def load_configuration(self, arguments):
super(BankBalanceTestsClient, self).load_configuration(arguments)
self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(os.path.dirname(__file__)+"/../../../../aiml/extensions/banking", ".aiml", False)

class BankBalanceAIMLTests(unittest.TestCase):

def setUp (self):
BankBalanceAIMLTests.test_client = BankBalanceTestsClient()

def test_balance(self):
response = BankBalanceAIMLTests.test_client.bot.ask_question("testif", "WHAT IS MY BANK BALANCE")
self.assertIsNotNone(response)
self.assertEqual(response, 'Your bank balance is currently £0.00.')

14 changes: 14 additions & 0 deletions bots/y-bot/src/test/extensions/telecoms/test_minutes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import unittest

from extensions.banking.balance import BankingBalanceExtension

class BankBalanceExtensionTests(unittest.TestCase):

def test_balance(self):

balance = BankingBalanceExtension()
self.assertIsNotNone(balance)

result = balance.execute("NOW")
self.assertIsNotNone(result)
self.assertEqual("0.00", result)

0 comments on commit be21942

Please sign in to comment.