Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
add option to flip text and intent
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 committed Apr 17, 2019
1 parent 8f7a779 commit d2b9d86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion rasa_dialogflow_interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ def __init__(
service_account_json=None,
language_code="en",
raise_on_error=False,
flip_text_and_intent=False,
):
self.project_id = project_id
self.language_code = language_code
self.raise_on_error = raise_on_error
self.flip_text_and_intent = flip_text_and_intent

credentials = None
if service_account_json:
Expand Down Expand Up @@ -94,7 +96,9 @@ def parse(self, text):
return build_response(
response.query_result.query_text,
intent={
"name": response.query_result.intent.display_name,
"name": response.query_result.intent.display_name
if not self.flip_text_and_intent
else response.query_result.fulfillment_text,
"confidence": response.query_result.intent_detection_confidence,
},
entities=response.query_result.parameters,
Expand Down
3 changes: 1 addition & 2 deletions rasa_dialogflow_interpreter/tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
build_response,
build_entity,
DialogflowInterpreter,
UpstreamError
UpstreamError,
)
from google.api_core.exceptions import GoogleAPICallError



class TestBuildEntity(unittest.TestCase):
def test_default(self):
expected = {"entity": "things", "value": "many", "start": 0, "end": 0}
Expand Down

0 comments on commit d2b9d86

Please sign in to comment.