Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated implementation, making it more dynamic - Expansion for future plugins is easy now - Cleaned up evaluate_mathematically() tests
- Loading branch information
1 parent
d77669a
commit fee0369
Showing
6 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .plugin import PluginAdapter | ||
from .evaluate_mathematically import EvaluateMathematically | ||
from .plugin_chooser import PluginChooser |
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
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
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,28 @@ | ||
from evaluate_mathematically import EvaluateMathematically | ||
|
||
class PluginChooser(): | ||
|
||
def __init__( self, **kwargs ): | ||
""" | ||
Initializes all plugins & initial variables. | ||
""" | ||
|
||
self.plugins = [ | ||
EvaluateMathematically(**kwargs) | ||
] | ||
|
||
|
||
def choose( self, input_statement ): | ||
""" | ||
Used to determine whether a plugin should be used | ||
to "answer" or reply to the user input. | ||
""" | ||
|
||
# Testing each plugin to determine whether it should be used to answer user input | ||
for plugin in self.plugins: | ||
should_use = plugin.should_answer( input_statement.text ) | ||
|
||
if should_use: | ||
return plugin.process( input_statement.text ) | ||
|
||
return False |
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
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