-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #861 from tue-robotics/fix/where_is_this_knowledge
Add robotics_testlabs where_is_this knowledge
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...knowledge/src/robocup_knowledge/environments/robotics_testlabs/challenge_where_is_this.py
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,48 @@ | ||
# WHERE IS THIS KNOWLEDGE FILE ROBOTICS TESTLABS | ||
|
||
# TU/e Robotics | ||
from robocup_knowledge import knowledge_loader | ||
|
||
# Common knowledge | ||
common = knowledge_loader.load_knowledge("common") | ||
|
||
grammar_target = "T" | ||
|
||
location_grammar = """ | ||
T[A] -> COURTESY_PREFIX VP[A] | VP[A] | ||
COURTESY_PREFIX -> robot please | could you | could you please | please | ||
""" | ||
|
||
for loc in common.location_rooms: | ||
location_grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc) | ||
|
||
for loc in common.location_names: | ||
location_grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc) | ||
|
||
for loc in common.object_names: | ||
category = common.get_object_category(loc) | ||
if category not in common.category_locations: | ||
continue | ||
|
||
entity_id = common.get_object_category_location(category)[0] | ||
|
||
location_grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (entity_id, loc) | ||
|
||
location_grammar += '\nDET_LOCATION[Y] -> LOCATION[Y] | the LOCATION[Y]' | ||
|
||
location_grammar += """ | ||
V_GUIDE -> guide | bring | lead | ||
VP[{"target-location": Y}] -> DET_LOCATION[Y] | V_GUIDE me to DET_LOCATION[Y] | i want to go to DET_LOCATION[Y] | i would like to go to DET_LOCATION[Y] | i like to go to DET_LOCATION[Y] | tell me how to go to DET_LOCATION[Y] | tell me how to reach DET_LOCATION[Y] | ||
""" | ||
|
||
if __name__ == "__main__": | ||
print("Where is this Grammar:\n\n{}\n\n".format(location_grammar)) | ||
|
||
from grammar_parser.cfgparser import CFGParser | ||
|
||
grammar_parser = CFGParser.fromstring(location_grammar) | ||
grammar_parser.verify() | ||
grammar_parser.check_rules() |