Skip to content

Commit

Permalink
added location queries
Browse files Browse the repository at this point in the history
  • Loading branch information
spectre900 committed Feb 25, 2021
1 parent 36e775e commit ef5ff70
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 44 deletions.
54 changes: 52 additions & 2 deletions actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def location_utter_mapping():
"amul":"utter_open_close_time_amul",
"nescafe":"utter_open_close_time_nescafe",
"nandini":"utter_open_close_time_nandini",
"academic building":"utter_open_close_time_academic_building",
"main building":"utter_open_close_time_main_building",
"mudrika":"utter_open_close_time_printing",
"electrical shop":"utter_open_close_time_delivery",
"health care centre":"utter_open_close_time_health_care_centre",
Expand Down Expand Up @@ -197,7 +197,7 @@ def location_utter_mapping(self):

return {
"snacks":"utter_open_close_time_snacks",
"academic building":"utter_open_close_time_academic_building",
"main building":"utter_open_close_time_main_building",
"printing":"utter_open_close_time_printing",
"delivery":"utter_open_close_time_delivery",
"health care centre":"utter_open_close_time_health_care_centre",
Expand Down Expand Up @@ -229,3 +229,53 @@ def selectUtterStatment(self,location):
return self.location_utter_mapping()[location]
else:
return "utter_default"

class LocationQuery(Action):
def name(self):
return "location_query"

@staticmethod
def location_utter_mapping():

return {
"amul":"utter_location_amul",
"nescafe":"utter_location_nescafe",
"nandini":"utter_location_nandini",
"main building":"utter_location_main_building",
"mudrika":"utter_location_printing",
"electrical shop":"utter_location_delivery",
"health care centre":"utter_location_health_care_centre",
"sports complex":"utter_location_sports_complex",
"bank":"utter_location_bank",
"central computer centre":"utter_location_central_computer_centre",
"central library":"utter_location_central_library",
}

def run(self, dispatcher, tracker, domain):
query_locations = []

for e in tracker.latest_message["entities"]:
if e["entity"]=="Location":
query_locations.append(e["value"])
# making a list of locations detected

if len(query_locations)==1:
#single location found and recognised
location = query_locations[0]
dispatcher.utter_message(template=self.selectUtterStatment(location))

else:
#location missing or mulitple locations or location not recognized
dispatcher.utter_message(template="utter_default")

return []

def selectUtterStatment(self,location):

location=location.lower().replace("_"," ")

if location in self.location_utter_mapping().keys():
#location recognised
return self.location_utter_mapping()[location]
else:
return "utter_default"
56 changes: 45 additions & 11 deletions data/nlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,15 @@ nlu:
- where can i get something to eat.
- I need to get some [snacks](snacks), where should i go?
- where can i get something light to eat.
- intent: Academic_Building
examples: |
- where can I get my [Transcripts](Academic_Building)
- where is the [academic section](Academic_Building)?
- where can I apply for the [CSAB special round](Academic_Building)?
- where can I apply for [branch change](Academic_Building)?
- where can I get my [hostel refund](Academic_Building)?
- where can i get my [marksheet](Academic_Building)?
- I need my [Grade card](Academic_Building), where should I head to?
- intent: Main_Building
examples: |
- where can I get my [Transcripts](Main_Building)
- where is the [academic section](Main_Building)?
- where can I apply for the [CSAB special round](Main_Building)?
- where can I apply for [branch change](Main_Building)?
- where can I get my [hostel refund](Main_Building)?
- where can i get my [marksheet](Main_Building)?
- I need my [Grade card](Main_Building), where should I head to?
- intent: Printing
examples: |
- where can I get a [printout](Printing)?
Expand Down Expand Up @@ -659,13 +659,13 @@ nlu:
- When will the [sports complex](Location) open?
- [mudrika](Location) opening time.
- When can I go to the [nandini](Location)?
- What time does the [academic building](Location) close?
- What time does the [main building](Location) close?
- Is [amul](Location) open now?
- When will the [library](Location) close?
- When will the [ccc](Location) open?
- At what time is the [bank](Location) available?
- [nandini](Location) closing time.
- What are the timings of the [academic building](Location)?
- What are the timings of the [main building](Location)?
- What time will the [sports complex](Location) close?
- When can I go to the [hcc](Location)?
- What time does [central computer centre](Location) open?
Expand Down Expand Up @@ -2024,6 +2024,40 @@ nlu:
- Where are you from?
- Let me know about the origin of u
- your native?
- intent: Location_Query
examples: |
- Where is [mudrika](Location)?
- Wheres the [electrical shop](Location)?
- Where's the [central library](Location)?
- How do you get to the the [sports complex](Location)?
- [mudrika](Location) location.
- How can i go to [nandini](Location)?
- location of [main building](Location).
- How do i go to [amul](Location)
- Where exactly is the [library](Location).
- Where is the [ccc](Location)?
- How far is the [bank](Location).
- [nandini](Location) location in campus.
- Where is the [main building](Location)?
- How can i get to the [sports complex](Location)?
- where is the [hcc](Location)?
- [central computer centre](Location) location?
- How can i go to the [health care centre](Location)?
- wheres the [electric shop](Location)?
- [central library](Location)?
- [nescafe](Location)?
- [amul](Location).
- [bank](Location).
- [hcc](Location)
- [ccc](Location)?
- [health care centre](Location)
- [mudrika](Location)
- [electrical shop](Location)
- [sports complex](Location)?
- [nandini](Location)
- [main building](Location).
- [library](Location).
- [central computer centre](Location)
- synonym: health care centre
examples: |
- hcc
Expand Down
16 changes: 0 additions & 16 deletions data/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,3 @@ rules:
steps:
- intent: nlu_fallback
- action: utter_default

# - rule: request_restaurant
# steps:
# - intent: request_restaurant
# - action: restaurant_form
# - active_loop: restaurant_form

# - rule: submit form
# condition:
# - active_loop: restaurant_form
# steps:
# - action: restaurant_form
# - active_loop: null
# - action: utter_submit
# - action: utter_slots_values

24 changes: 20 additions & 4 deletions data/stories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ stories:
- intent: deny
- action: utter_cheer_up

- story: happy Academic_Building
- story: happy Main_Building
steps:
- intent: Academic_Building
- intent: Main_Building
- action: utter_go_to_MB
- action: set_context_location
- action: utter_did_that_help
- intent: affirm
- action: utter_happy

- story: sad Academic_Building
- story: sad Main_Building
steps:
- intent: Academic_Building
- intent: Main_Building
- action: utter_go_to_MB
- action: set_context_location
- action: utter_did_that_help
Expand Down Expand Up @@ -531,3 +531,19 @@ stories:
steps:
- intent: origin
- action: utter_origin

- story: Happy Location Query
steps:
- intent: Location_Query
- action: location_query
- action: utter_did_that_help
- intent: affirm
- action: utter_happy

- story: Sad Location Query
steps:
- intent: Location_Query
- action: location_query
- action: utter_did_that_help
- intent: deny
- action: utter_cheer_up
79 changes: 68 additions & 11 deletions domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ intents:
- request_restaurant
- cuisine
- snacks
- Academic_Building
- Main_Building
- Printing
- Delivery
- Health_Care_Centre
Expand Down Expand Up @@ -82,6 +82,7 @@ intents:
- sleepy
- residence
- origin
- Location_Query
entities:
- Academic_Building
- Central_Computer_Centre
Expand Down Expand Up @@ -137,12 +138,12 @@ responses:
- text: Hello!
- text: Greetings!
utter_cheer_up:
- text: 'Here is something to cheer you up:'
image: https://i.imgur.com/nGF1K8f.jpg
- text: Here is something to cheer you up
image: https://i.pinimg.com/originals/c9/88/d3/c988d35b9498f24afe6ea0fec75e1793.jpg
- text: Years of academy training wasted. Here is something that can cheer you up.
image: https://i.imgur.com/nGF1K8f.jpg
image: https://i.pinimg.com/originals/c9/88/d3/c988d35b9498f24afe6ea0fec75e1793.jpg
- text: I have failed you my master. Meanwhile here is something to cheer you up.
image: https://i.imgur.com/nGF1K8f.jpg
image: https://i.pinimg.com/originals/c9/88/d3/c988d35b9498f24afe6ea0fec75e1793.jpg
- text: Oh, don't be sad. Go do something you enjoy.
- text: Sad? Writing down what's troubling you may help.
- text: If you're feeling down, how about drawing or painting something?
Expand Down Expand Up @@ -367,13 +368,13 @@ responses:
title: CCC
utter_go_to_central_library:
- custom:
text: You can go to the Central Library which is behind the Main Building, besides the Pavillion.
text: You can go to the Central Library which is behind the Main Building, beside the Pavillion.
title: CentralLibrary
- custom:
text: You will find the Central Library besides the Pavillion, right behind the Main Building.
text: You will find the Central Library beside the Pavillion, right behind the Main Building.
title: CentralLibrary
- custom:
text: Central Library is what you are seeking, it is right behind the Main Building, besides the Pavillion.
text: Central Library is what you are seeking, it is right behind the Main Building, beside the Pavillion.
title: CentralLibrary
utter_open_close_time_snacks:
- text: Amul is open from 7:45 AM to 7:45 PM, Nandini is available from 8:30 AM to 10:30 PM and Nescafe from XX:XX AM to XX:XX PM all days of the week(to be updated).
Expand All @@ -383,8 +384,8 @@ responses:
- text: Nescafe is open from XX:XX AM to XX:XX PM (to be updated)
utter_open_close_time_nandini:
- text: Nandini is open from 8:30 AM to 10:30 PM all days of the week.
utter_open_close_time_academic_building:
- text: The Academic Building is open from XX:XX AM to XX:XX PM (to be updated)
utter_open_close_time_main_building:
- text: The Main Building is open from XX:XX AM to XX:XX PM (to be updated)
utter_open_close_time_printing:
- text: Mudrika is open from 8:30 AM to 6:30 PM all days of the week.
utter_open_close_time_delivery:
Expand Down Expand Up @@ -618,9 +619,54 @@ responses:
- text: Right here in this app. Whenever you need me.
utter_origin:
- text: I was born and raised at NITK.
utter_location_amul:
- custom:
text: Amul is located near the boys hostel, besides the sports complex.
title: Amul
utter_location_nescafe:
- custom:
text: Nescafe is right in front of the boys hostel.
title: Nescafe
utter_location_nandini:
- custom:
text: Nandini is right in front of the Mechanical Department.
title: Nandini
utter_location_main_building:
- custom:
text: The Main building is behind the Central Library, adjacent to the Pavillion.
title: MainBuilding
utter_location_printing:
- custom:
text: Mudrika is right beside the electric shop, near the students cooperative society.
title: Mudrika
utter_location_delivery:
- custom:
text: Yennar Electricals is adjacent to Mudrika.
title: Yennar
utter_location_health_care_centre:
- custom:
text: The Health Care Centre is in the center of the campus, right in front of the main playground.
title: HealthCareCentre
utter_location_sports_complex:
- custom:
text: The sports complex is near the main playground.
title: SportsComplex
utter_location_bank:
- custom:
text: SBI Bank is near Mudrika.
title: SBIBank
utter_location_central_computer_centre:
- custom:
text: The Central Computer Centre is behind the HCC, across the Silver Jubilee Auditorium (SJA).
title: CCC
utter_location_central_library:
- custom:
text: The Central Library beside the Pavillion, right behind the Main Building.
title: CentralLibrary
actions:
- direct_time_query
- indirect_time_query
- location_query
- set_context_location
- utter_age
- utter_angry
Expand Down Expand Up @@ -680,7 +726,7 @@ actions:
- utter_nice_to_meet_you
- utter_no_problem
- utter_noworries
- utter_open_close_time_academic_building
- utter_open_close_time_main_building
- utter_open_close_time_amul
- utter_open_close_time_bank
- utter_open_close_time_central_computer_centre
Expand Down Expand Up @@ -721,6 +767,17 @@ actions:
- utter_wrong_num_people
- utter_wrong_outdoor_seating
- validate_restaurant_form
- utter_location_amul
- utter_location_nescafe
- utter_location_nandini
- utter_location_main_building
- utter_location_printing
- utter_location_delivery
- utter_location_health_care_centre
- utter_location_sports_complex
- utter_location_bank
- utter_location_central_computer_centre
- utter_location_central_library
forms:
restaurant_form:
cuisine:
Expand Down

0 comments on commit ef5ff70

Please sign in to comment.