You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
7 years ago
|
from __future__ import unicode_literals
|
||
|
from .logic_adapter import LogicAdapter
|
||
|
|
||
|
|
||
|
class SpecificResponseAdapter(LogicAdapter):
|
||
|
"""
|
||
|
Return a specific response to a specific input.
|
||
|
|
||
|
:kwargs:
|
||
|
* *input_text* (``str``) --
|
||
|
The input text that triggers this logic adapter.
|
||
|
* *output_text* (``str``) --
|
||
|
The output text returned by this logic adapter.
|
||
|
"""
|
||
|
|
||
|
def __init__(self, **kwargs):
|
||
|
super(SpecificResponseAdapter, self).__init__(**kwargs)
|
||
|
from ..conversation import Statement
|
||
|
|
||
|
self.input_text = kwargs.get('input_text')
|
||
|
|
||
|
output_text = kwargs.get('output_text')
|
||
|
self.response_statement = Statement(output_text)
|
||
|
|
||
|
def can_process(self, statement):
|
||
|
if statement == self.input_text:
|
||
|
return True
|
||
|
|
||
|
return False
|
||
|
|
||
|
def process(self, statement):
|
||
|
|
||
|
if statement == self.input_text:
|
||
|
self.response_statement.confidence = 1
|
||
|
else:
|
||
|
self.response_statement.confidence = 0
|
||
|
|
||
|
return self.response_statement
|