test_cases.append(('LookForUser1', 0, """[('search', {'Theme': 'user_1', 'Location': 'library'}), ('search', {'Theme': 'user_1', 'Location': 'classroom'})]""")) test_cases.append(('GetBombDefuser', 0, """[('retrieve', {'Source': 'user_1', 'Theme': 'bomb_defuser'}), ('go', {'Theme': '*', 'Location': 'unknown_current_location'})]""")) test_cases.append(('EatSandwich', 0, """[('eat', {'Patient': 'sandwich'})]""")) test_cases.append(('WhereAreYou', 3, """I don't know.""")) test_cases.append(('GoOfficeDefuse', 0, """[('go', {'Location': 'office'}), ('defuse', {'Theme': 'bomb'}), ('see', {'Theme': 'bomb'})]""")) test_cases.append(('WhereIsUser1',3,""" """)); test_cases.append(('WhereIsHe',3, """ """)); if __name__ == '__main__': knowledge = Knowledge() library_entity = Entity({'EntityType':[Predicate('EntityType','room')]}, 'library') user1_entity = Entity({'Theme' : [Predicate('Theme', 'user1')], 'Location' : [Predicate('Location', library_entity)]}) knowledge.junior_known_entities[user1_entity.id] = user1_entity knowledge.commander_known_entities[user1_entity.id] = user1_entity for test in test_cases: answer = knowledge.process_parse_tree(phrase_dict[test[0]],'') if answer[2] is not None: result = str(answer[2][test[1]]) else: print 'Test ' + test[0] + ' failed. No output.' continue if not (test[2] == result): print 'Test ' + test[0] + ' failed.' print 'Expected: ' + test[2] print 'Got: ' + result knowledge.process_parse_tree('','execute')
##parse_tree_string = """((S (NP-SBJ-A (PRP I)) (VP (VBP am) (PP-LOC-PRD (IN in) (NP-A (NN room) (CD 2)))) (. .)))""" ##parse_tree_string = """((S (NP-SBJ-A (EX There)) (VP (VBP are) (NP-PRD-A (NP (QP (IN at) (JJS least) (CD 4)) (NNS hostages)) (PP-LOC (IN in) (NP-A (NN room) (CD 1))))) (. .))) """ ##parse_tree_string = """((SBARQ (WHNP-0 (WP What)) (SQ (VBP are) (NP-SBJ (PRP you)) (VP (VBG doing) (NP-0 (-NONE- *T*)))) (. ?)))""" #parse_tree_string = """((SQ (VBP Are) (NP-SBJ-0 (PRP you)) (VP (VBN flipped) (NP-A-0 (-NONE- *))) (. ?)))""" ##parse_tree_string = """((SINV (VP (VBP Are) (ADVP-LOC-PRD (RB there))) (NP-SBJ (DT any) (NNS hostages)) (. ?))) """ ##parse_tree_string = """((S (NP-SBJ-A (NNP Junior)) (, ,) (VP (VP-A (VB go) (PP-CLR (TO to) (NP-A (NN room) (CD 3)))) (. .))))""" ##parse_tree_string = """((S (VP (VP-A (VB Go) (PP-CLR (TO to) (NP-A (NN room) (CD 3)))) (. .))))""" ##parse_tree_string = """((S (NP-SBJ-A (-NONE- *)) (VP (VB Look) (PP-CLR (IN for) (NP-A (NNP User) (CD 1))) (PP (IN in) (NP-A (NP (DT the) (NN library)) (CC and) (NP (DT the) (NN classroom))))) (. .)))""" ##parse_tree_string = """((S (VP (VB Look) (PP-CLR (IN for) (NP-A (NNP User) (CD 1))) (PP (IN in) (NP-A (NP (DT the) (NN library)) (CC and) (NP (DT the) (NN classroom))))) (. .)))""" knowledge = Knowledge() print knowledge.process_parse_tree(demo_sentences['GoToLibrary'], '') #print knowledge.process_parse_tree(demo_sentences['WhereAreTheHostages'], '') print knowledge.watch_list print knowledge.commander_known_entities print knowledge.command_queue #print 'Watch list \n' + str(knowledge.watch_list) print '-------------' ##parse_tree_string = """((SBARQ (WHADVP-0 (WRB Where)) (SQ (VP (VBP are) (NP-PRD-A (DT the) (NNS hostages)) (ADVP-0 (-NONE- *T*)))) (. ?))) """ #parse_tree_string = """((S (NP-SBJ-A (-NONE- *)) (VP (VB Go) (PP-CLR (TO to) (NP-A (NP (DT the) (NN room)) (PP (IN with) (NP-A (DT the) (NNS hostages)))))) (. .))) """ ##parse_tree_string = """((SINV (VP (VBP Are) (ADVP-LOC-PRD (RB there))) (NP-SBJ (NP (DT any) (NNS hostages)) (PP-LOC (IN in) (NP-A (NN room) (CD 3)))) (. ?)))"""