-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Really basic interfaces for natlib, more to come in the next selected…
… push!
- Loading branch information
1 parent
9c9fdc5
commit 45cd9e1
Showing
7 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"version": "1.0.0", | ||
"apps": { | ||
"MotivationBot": "0.1.0", | ||
"HelloBot": "0.1.0", | ||
"TimeBot": "0.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Command(object): | ||
|
||
def __init__(self): | ||
super(Command, self).__init__() | ||
|
||
def getInstance(self): | ||
return self | ||
|
||
def run(self): | ||
pass | ||
|
||
def intent(self): | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from command import Command | ||
|
||
# | ||
# The Abstract Intent | ||
# Contains the default methods to define an intent | ||
# | ||
class Intent(object): | ||
|
||
def __init__(self, command): | ||
super(Intent, self).__init__() | ||
if type(command) is Command: | ||
self.command = command # command has to be final function that runs it. | ||
|
||
def hook(self, hook, command): | ||
pass | ||
|
||
def runCommand(self): | ||
return self.command() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from intent import Intent | ||
from collections import OrderedDict | ||
|
||
# Basic Pipeline | ||
# (TODO): Add basic LRU like features to find then most used intent in first few tests | ||
class Pipeline(object): | ||
def __init__(self): | ||
self._pipeline = OrderedDict(); | ||
self. | ||
|
||
def hook(self, key, intent): | ||
if type(intent) is Intent: | ||
self._pipeline[key] = { | ||
"instance": intent, | ||
"parsed": [] # for future, if we want to lookup which commands it parsed earlier.. | ||
} | ||
else: | ||
raise AttributeError("Invalid Intent") | ||
|
||
def unhook(self, key): | ||
intent = self._pipeline[key] | ||
del self._pipeline[key] | ||
return intent | ||
|
||
def findIntent(self, input): # returns the the intents which test positive in the pipeline to be executed! | ||
intents = [] | ||
for key, intent in self._pipeline: | ||
if intent["instance"].test(input): | ||
return intents | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Response(object): | ||
# Idea is we can send in message in a response, | ||
# and the response can then be handled in different ways via this interface | ||
def __init__(self, message): | ||
self.message = message | ||
|
||
# Hooks to the text to speech API to say things | ||
def speak(self): | ||
pass | ||
|
||
def say(self): | ||
print(self.message) |