3 from __future__
import print_function
6 from robocup_knowledge
import knowledge_loader
9 common = knowledge_loader.load_knowledge(
"common")
13 location_grammar =
"""
14 T[A] -> COURTESY_PREFIX VP[A] | VP[A]
16 COURTESY_PREFIX -> robot please | could you | could you please | please
19 for loc
in common.location_rooms:
20 location_grammar +=
'\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc)
22 for loc
in common.location_names:
23 location_grammar +=
'\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc)
25 for loc
in common.object_names:
27 if category
not in common.category_locations:
32 location_grammar +=
'\nLOCATION[{"id": "%s"}] -> %s' % (entity_id, loc)
34 location_grammar +=
'\nDET_LOCATION[Y] -> LOCATION[Y] | the LOCATION[Y]'
36 location_grammar +=
"""
37 V_GUIDE -> guide | bring | lead
39 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]
43 if __name__ ==
"__main__":
44 print(
"Where is this Grammar:\n\n{}\n\n".format(location_grammar))
46 from grammar_parser.cfgparser
import CFGParser
48 grammar_parser = CFGParser.fromstring(location_grammar)
49 grammar_parser.verify()
50 grammar_parser.check_rules()