def interpret_command(sentence_string): print "lol" G = kb_services.load_semantic_network() grounded_commands = interpretation.sentence_grounder(G, sentence_string) print "loll" print "grounded command: ", grounded_commands for each_command in grounded_commands: expression = interpretation.generate_dependency(G, each_command) print "generated expression to planner: ", expression print "lolll" # sentences = interpretation.break_sentence(sentence_string) # print "hi: ", sentences # for command in sentences[0:1]: # grounded_commands = interpretation.sentence_grounder(G, command) # print "grounded command: ", grounded_commands # # for each_command in grounded_commands: # expression = interpretation.generate_dependency(G, each_command) # print "output expression: ", expression # if commands != [False]: # interpreted_sentences # interpreted_sentences += 1 # commands[0] = re.sub(' \)', ')', commands[0]) # commands[0] = re.sub('_', ' ', commands[0]) return expression
file.close() print "lines: ", lines #lines = ["Drop the jar", "Put the can on the counter", "Find the glass in the living room", "Search for the glass in the kitchen", "Go to the dining room", "Move along the wall", "Take the cereal box", "Grab the mayo on the table", "remove the sheets from the bed"] inicio = 0 fin = len(lines) for iterator in range(inicio,fin): print "*********************************************" command = lines[iterator] command = re.sub('\n', '', command) print "" print "- OUT: ORIGINAL SENTENCE: ", command analized_sentences = interpretation.sentence_grounder(G, command) commands = [] for each_caracterized_sentence in analized_sentences: #print "" #print "- LOG: GROUNDED SENTENCE: ", each_caracterized_sentence["objects"] commands.append(interpretation.generate_dependency(G, each_caracterized_sentence)) if commands != [False]: interpreted_sentences interpreted_sentences += 1 commands[0] = re.sub(' \)', ')', commands[0]) commands[0] = re.sub('_', ' ', commands[0]) #print "- LOG: Enunciado generado: ", commands[0] file_report.write(command + ' | ' + commands[0] + '\n') file_report.close()
import re # drawing import networkx.drawing import matplotlib.pyplot as plt bateria_ejemplos = [ "place green pyramid on top of red brick" ] G = kb_services.load_semantic_network() for each_example in bateria_ejemplos: analized_sentences = interpretation.sentence_grounder(G, each_example) commands = [] for each_caracterized_sentence in analized_sentences: print "sentence ready to be matched:: ------------------------------------" print "generatiing meaning expressions from ", each_caracterized_sentence["objects"] commands.append(interpretation.generate_dependency(G, each_caracterized_sentence)) # print "commands to planner..." # for each in commands: # print "sent to planner: ", each # print "planner response:" # planner_bridge.launch_planner(each)
file.close() print "lines: ", lines #lines = ["Drop the jar", "Put the can on the counter", "Find the glass in the living room", "Search for the glass in the kitchen", "Go to the dining room", "Move along the wall", "Take the cereal box", "Grab the mayo on the table", "remove the sheets from the bed"] inicio = 0 fin = len(lines) for iterator in range(inicio, fin): print "*********************************************" command = lines[iterator] command = re.sub('\n', '', command) print "" print "- OUT: ORIGINAL SENTENCE: ", command analized_sentences = interpretation.sentence_grounder(G, command) commands = [] for each_caracterized_sentence in analized_sentences: #print "" #print "- LOG: GROUNDED SENTENCE: ", each_caracterized_sentence["objects"] commands.append( interpretation.generate_dependency(G, each_caracterized_sentence)) if commands != [False]: interpreted_sentences interpreted_sentences += 1 commands[0] = re.sub(' \)', ')', commands[0]) commands[0] = re.sub('_', ' ', commands[0]) #print "- LOG: Enunciado generado: ", commands[0] file_report.write(command + ' | ' + commands[0] + '\n') file_report.close()