Skip to content

Commit

Permalink
prepare for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tabergma committed Feb 5, 2020
1 parent 8d29d9d commit 057a2f6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
6 changes: 3 additions & 3 deletions actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def run(self, dispatcher, tracker, domain):
dispatcher.utter_message(
"Found the following '{}' entities:".format(entity_type)
)
for i, e in enumerate(entities):
representation_string = to_str(e, entity_representation)
dispatcher.utter_message(f"{i + 1}: {representation_string}")
sorted_entities = sorted([to_str(e, entity_representation) for e in entities])
for i, e in enumerate(sorted_entities):
dispatcher.utter_message(f"{i + 1}: {e}")

# set slots
# set the entities slot in order to resolve references to one of the found
Expand Down
19 changes: 10 additions & 9 deletions domain.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
session_config:
session_expiration_time: 60.0
carry_over_slots_to_new_session: true
intents:
- affirm
- bye
Expand All @@ -9,7 +12,6 @@ intents:
- query_attribute
- query_entities
- resolve_entity

entities:
- account
- account_type
Expand All @@ -29,7 +31,6 @@ entities:
- phone_number
- reference
- transaction

slots:
account:
type: text
Expand Down Expand Up @@ -99,8 +100,7 @@ slots:
type: text
transaction:
type: text

responses:
templates:
utter_greet:
- text: Hi. I can give you some information about banks or I can give you some details
about the accounts you own. What do you want to know?
Expand All @@ -118,13 +118,14 @@ responses:
utter_help:
- text: I can tell you some facts about different banks. I can answer some questions
about your accounts. And I can show you your recent transactions.

actions:
- action_compare_entities
- action_query_attribute
- action_query_entities
- action_resolve_entity

session_config:
session_expiration_time: 60 # value in minutes, 0 means infinitely long
carry_over_slots_to_new_session: true # set to false to forget slots between sessions
- utter_greet
- utter_goodbye
- utter_ok
- utter_rephrase
- utter_out_of_scope
- utter_help
2 changes: 1 addition & 1 deletion graph_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_entities(
self,
entity_type: Text,
attributes: Optional[List[Dict[Text, Text]]] = None,
limit: int = 5,
limit: int = 10,
) -> List[Dict[Text, Any]]:
"""
Query the graph database for entities of the given type. Restrict the entities
Expand Down
24 changes: 24 additions & 0 deletions update_knowledge_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from grakn.client import GraknClient


def execute(graql_query):
print(graql_query)

with GraknClient(uri="localhost:48555") as client:
with client.session(keyspace="banking") as session:
with session.transaction().write() as transaction:
transaction.query(graql_query)
transaction.commit()


if __name__ == "__main__":
graql_insert_query = """
insert $b isa bank, has name 'KfW', has country 'Germany', has headquarters 'Frankfurt am Main';
"""
execute(graql_insert_query)

graql_delete_query = """
match $b isa bank, has name 'KfW'; delete $b;
"""
#execute(graql_delete_query)

0 comments on commit 057a2f6

Please sign in to comment.