Ejemplo n.º 1
0
def cmd_int(c):
	
	cadena  = cmdQ.popC()	
	cadena2 = str(cadena)
	content = cadena2.split("',")
	temp = content[0]
	temp1 = temp.lstrip("[('")

	interpreted_command = egprs_interpreter.interpret_command(temp1)

	print " "
	print "Comando Interpretado:"
	print interpreted_command
	cabecera = interpreted_command.split(' ')
	if interpreted_command == 'False' or cabecera[0] == '(task_to' :
		args = 'No_Interpretation'
		return Response.FromCommandObject(c, False, args)
	else:
		q.empty()
		separaTask(interpreted_command)
		args = temp1.replace(' ','_')
		#steps = q.lenC()
		#plan_name_id = randrange(10000)
		#args = "plan-" + str(plan_name_id) + " " + str(steps)
		#print '<-------------->'
		#print args
		#print '<-------------->'
		return Response.FromCommandObject(c, True, args)
Ejemplo n.º 2
0
def main():
  # print " test: ", egprs_interpreter.interpret_command("take the orange juice from the shelf and deliver it to carmen at the dining room")
  while True:
    nlStr = raw_input("Enter string: ")
    print nlStr
    print "Ok"
    cfr = egprs_interpreter.interpret_command(nlStr)
    print cfr
Ejemplo n.º 3
0
def process_string(request):
	#get the recognized string and send it to the reco function
	interpreted_command = egprs_interpreter.interpret_command(request.sentence)
	#convert the interpretation json-format to lists 
	jsonCFR = json.loads(interpreted_command)
	#send the response back
	response = parse_sentence_cfrResponse()
	response.cfr.command = jsonCFR["action"]
	for key in jsonCFR["params"].keys():
		response.cfr.params.append(CFRParams(key, jsonCFR["params"][key]))
		#response.cfr.params.frame_value.append(jsonCFR["params"][key])
	return response
Ejemplo n.º 4
0
def cmd_int(c):
    #agregamos el comando mediante un archivo, despues usaremos el gpsr
    filename = sys.argv[1]
    with open(filename) as f:
        content = f.read()

    interpreted_command = egprs_interpreter.interpret_command(content)

    print " "
    print "Comando Interpretado:"
    print interpreted_command
    separaTask(interpreted_command)
    return Response.FromCommandObject(c, True, "Completed")
Ejemplo n.º 5
0
def cmd_int_open(c):
    try:
        cadena = cmdQ.popC()
    except:
        return (0, "Cola_Vacia")

    cadena2 = str(cadena)
    try:
        content = cadena2.split("',")
    except:
        print 'Error the Command format is incorrect'
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)

    temp = content[0]
    temp1 = temp.lstrip("[('")
    if temp1 == 'explain the plan' or temp1 == 'where is the sugar' or temp1 == 'where is the milk' or temp1 == 'where is the juice' or temp1 == 'where is the soup' or temp1 == 'what happen with the soup' or temp1 == 'what happen with the sugar' or temp1 == 'what happen with the milk' or temp1 == 'what happen with the juice' or temp1 == 'who has the milk' or temp1 == 'who has the juice' or temp1 == 'who has the soup' or temp1 == 'who has the sugar':
        print 'No Interpretation of explain the plan'
        args = 'No_Interpretation'
        return (0, args)
    else:
        interpreted_command = egprs_interpreter.interpret_command(temp1)

    print " "
    print "Comando Interpretado:"
    print interpreted_command

    try:
        cabecera = interpreted_command.split(' ')
    except:
        print 'Error the Interpreted Command format is incorrect'
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)

    if interpreted_command == 'False' or cabecera[0] == '(task_to':
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)
    else:
        q.empty()
        planQ.empty()
        separaTask(interpreted_command)
        args = temp1.replace(' ', '_')
        #return Response.FromCommandObject(c, True, args)
        return (1, args)
Ejemplo n.º 6
0
def cmd_int(c):
	try:
		cadena  = cmdQ.popC()
	except:
		return (0, "Cola_Vacia")
			
	cadena2 = str(cadena)
	try:
		content = cadena2.split("',")
	except:
		print 'Error the Command format is incorrect'
		args = 'No_Interpretation'
		#return Response.FromCommandObject(c, False, args)
		return (0, args)
	
	temp = content[0]
	temp1 = temp.lstrip("[('")
	if temp1 == 'explain the plan' or temp1 == 'where is the sugar' or temp1 == 'where is the milk' or temp1 == 'where is the juice' or temp1 == 'where is the soup' or temp1 == 'what happen with the soup' or temp1 == 'what happen with the sugar' or temp1 == 'what happen with the milk' or temp1 == 'what happen with the juice' or temp1 == 'who has the milk' or temp1 == 'who has the juice' or temp1 == 'who has the soup' or temp1 == 'who has the sugar':
		print 'No Interpretation of explain the plan'
		args = 'No_Interpretation'
		return (0, args)
	else:
		interpreted_command = egprs_interpreter.interpret_command(temp1)

	print " "
	print "Comando Interpretado:"
	print interpreted_command
	
	try:
		cabecera = interpreted_command.split(' ')
	except:
		print 'Error the Interpreted Command format is incorrect'
		args = 'No_Interpretation'
		#return Response.FromCommandObject(c, False, args)
		return (0, args)
	
	if interpreted_command == 'False' or cabecera[0] == '(task_to' :
		args = 'No_Interpretation'
		#return Response.FromCommandObject(c, False, args)
		return (0, args)
	else:
		q.empty()
		separaTask(interpreted_command)
		args = temp1.replace(' ','_')
		#return Response.FromCommandObject(c, True, args)
		return (1, args)
Ejemplo n.º 7
0
def cmd_int(c):
	
	#cadena  = cmdQ.popC()	
	#cadena2 = str(cadena)
	#try:
	#	content = cadena2.split("',")
	#except:
	#	print 'Error the Command format is incorrect'
	#	args = 'No_Interpretation'
	#	return Response.FromCommandObject(c, False, args)
	#temp = content[0]
	#temp1 = temp.lstrip("[('")

	#agregamos el comando mediante un archivo, despues usaremos el gpsr
	filename = sys.argv[1]
	with open(filename) as f:
		content = f.read()

	interpreted_command = egprs_interpreter.interpret_command(content)

	print " "
	print "Comando Interpretado:"
	print interpreted_command
	
	try:
		cabecera = interpreted_command.split(' ')
	except:
		print 'Error the Interpreted Command format is incorrect'
		args = 'No_Interpretation'
		return Response.FromCommandObject(c, False, args)
	
	if interpreted_command == 'False' or cabecera[0] == '(task_to' :
		args = 'No_Interpretation'
		return Response.FromCommandObject(c, False, args)
	else:
		q.empty()
		separaTask(interpreted_command)
		args = temp1.replace(' ','_')
		#steps = q.lenC()
		#plan_name_id = randrange(10000)
		#args = "plan-" + str(plan_name_id) + " " + str(steps)
		#print '<-------------->'
		#print args
		#print '<-------------->'
		return Response.FromCommandObject(c, True, args)
Ejemplo n.º 8
0
def cmd_str_int(c):
    interpreted_command = ''
    interpreted_command = egprs_interpreter.interpret_command(c)
    print " "
    print "Comando Interpretado:"
    print interpreted_command

    try:
        cabecera = interpreted_command.split(' ')
    except:
        print 'Error the Interpreted Command format is incorrect'
        args = 'No_Interpretation'
        return (0, args)

    if cabecera[0] == '(task_to':
        args = 'No_Interpretation'
        return (0, args)
    else:
        return (1, interpreted_command)
    return (1, interpreted_command)
Ejemplo n.º 9
0
def cmd_str_int(c):
        interpreted_command = ''
	interpreted_command = egprs_interpreter.interpret_command(c)
	print " "
	print "Comando Interpretado:"
	print interpreted_command
	
	try:
		cabecera = interpreted_command.split(' ')
	except:
		print 'Error the Interpreted Command format is incorrect'
		args = 'No_Interpretation'
		return (0, args)
	
	if cabecera[0] == '(task_to' :
		args = 'No_Interpretation'
		return (0, args)
	else:
		return (1, interpreted_command)
        return (1, interpreted_command)
Ejemplo n.º 10
0
def process_string(c):
  interpreted_command = egprs_interpreter.interpret_command(c.params)
  return Response.FromCommandObject(c, True, interpreted_command)
Ejemplo n.º 11
0
def cmd_int(c):
    try:
        cadena = cmdQ.popC()
    except:
        return (0, "Cola_Vacia")

    cadena2 = str(cadena)
    cadena2 = re.sub('"', "'", cadena2)
    try:
        content = cadena2.split("',")
    except:
        print 'Error the Command format is incorrect'
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)

    temp = content[0]
    tempx = temp.lstrip("[('")

    x = tempx.find("Robot ")
    tempy = tempx.lstrip("Robot")
    temp1 = tempy.lstrip("robot")

    ##### you(may | can | will) find
    f = temp1.find("you may find")
    f1 = temp1.find("you can find")
    f2 = temp1.find("you will find")

    ####split command in task divided for ','
    if f == -1 and f1 == -1 and f2 == -1:
        firstRecoSplit = temp1.split(',')
    else:
        firstRecoSplit = [temp1]
    if len(firstRecoSplit) < 2:
        lastRecoSplit = temp1.split(' and ')
    else:
        lastRecoSplit = firstRecoSplit
    result = ''

    for j in lastRecoSplit:
        interpreted_command = ''
        interpreted_command = egprs_interpreter.interpret_command(j)
        ic = str(interpreted_command)
        result = result + ic

    if temp1 == 'robot yes' or temp1 == 'robot no':
        result = 'False'

    print " "
    print "Comando Interpretado:"
    print result

    try:
        cabecera = result.split(' ')
    except:
        print 'Error the Interpreted Command format is incorrect'
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)

    if result == 'False' or cabecera[
            0] == '(task_to' or result == 'FalseFalse' or result == 'FalseFalseFalse' or result == 'FalseFalseFalseFalse':
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)
    else:
        q.empty()
        separaTask(result)
        args = temp1.replace(' ', '_')
        #return Response.FromCommandObject(c, True, args)
        return (1, args)
Ejemplo n.º 12
0
def cmd_int(c):
	try:
		cadena  = cmdQ.popC()
	except:
		return (0, "Cola_Vacia")
			
	cadena2 = str(cadena)
	cadena2 = re.sub('"',"'",cadena2)
	try:
		content = cadena2.split("',")
	except:
		print 'Error the Command format is incorrect'
		args = 'No_Interpretation'
		#return Response.FromCommandObject(c, False, args)
		return (0, args)
	
	temp = content[0]
	tempx = temp.lstrip("[('")

	x = tempx.find("Robot ")
	tempy = tempx.lstrip("Robot")
	temp1 = tempy.lstrip("robot")
	
	##### you(may | can | will) find
	f = temp1.find("you may find")
	f1 = temp1.find("you can find")
	f2 = temp1.find("you will find")
		
	####split command in task divided for ','
	if f == -1 and f1 == -1 and f2 == -1 : 	
		firstRecoSplit = temp1.split(',')
	else:
		firstRecoSplit = [temp1];
	if len(firstRecoSplit) < 2:
		lastRecoSplit = temp1.split(' and ')
	else:
		lastRecoSplit = firstRecoSplit
	result = ''	
	
	for j in lastRecoSplit:
		interpreted_command = ''
		interpreted_command = egprs_interpreter.interpret_command(j)
		ic = str(interpreted_command)
		result = result + ic
	
	if temp1 == 'robot yes' or temp1 == 'robot no':
		result = 'False'

	print " "
	print "Comando Interpretado:"
	print result
	
	try:
		cabecera = result.split(' ')
	except:
		print 'Error the Interpreted Command format is incorrect'
		args = 'No_Interpretation'
		#return Response.FromCommandObject(c, False, args)
		return (0, args)
	
	if result == 'False' or cabecera[0] == '(task_to' or result == 'FalseFalse' or result == 'FalseFalseFalse' or result == 'FalseFalseFalseFalse':
		args = 'No_Interpretation'
		#return Response.FromCommandObject(c, False, args)
		return (0, args)
	else:
		q.empty()
		separaTask(result)
		args = temp1.replace(' ','_')
		#return Response.FromCommandObject(c, True, args)
		return (1, args)
Ejemplo n.º 13
0
def interpret(s):
  return egprs_interpreter.interpret_command(nlStr)
def cmd_int(c):
    try:
        cadena = cmdQ.popC()
    except:
        return (0, "Cola_Vacia")

    cadena2 = str(cadena)
    cadena2 = re.sub('"', "'", cadena2)
    try:
        content = cadena2.split("',")
    except:
        print 'Error the Command format is incorrect'
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)

    temp = content[0]
    tempx = temp.lstrip("[('")

    print "Temporal x: " + tempx

    x = tempx.find("Robot ")
    y = tempx.find("robot ")
    if x != -1:
        temp1 = tempx.lstrip("Robot")
    elif y != -1:
        temp1 = tempx.lstrip("robot")
    else:
        temp1 = tempx

    print "Temporal 1: " + temp1

    ##### you(may | can | will) find
    f = temp1.find("you may find")
    f1 = temp1.find("you can find")
    f2 = temp1.find("you will find")

    ####split command in task divided for ','
    if f == -1 and f1 == -1 and f2 == -1:
        firstRecoSplit = temp1.split(',')
    else:
        firstRecoSplit = [temp1]
    if len(firstRecoSplit) < 2:
        lastRecoSplit = temp1.split(' and ')
    else:
        lastRecoSplit = firstRecoSplit
    result = ''

    for j in lastRecoSplit:
        interpreted_command = ''
        interpreted_command = egprs_interpreter.interpret_command(j)
        ic = str(interpreted_command)
        result = result + ic

    if temp1 == 'robot yes' or temp1 == 'robot no':
        result = 'False'

    print " "
    print "Comando Interpretado:"
    print result

    try:
        cabecera = result.split(' ')
    except:
        print 'Error the Interpreted Command format is incorrect'
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)

    if result == 'False' or cabecera[
            0] == '(task_to' or result == 'FalseFalse' or result == 'FalseFalseFalse' or result == 'FalseFalseFalseFalse':
        args = 'No_Interpretation'
        #return Response.FromCommandObject(c, False, args)
        return (0, args)
    else:
        q.empty()
        instruction = 'false'
        if result.find('(inst') != -1:
            if result.find('(task') != -1:
                instruction = 'false'
            result = result.replace('(inst', '(task')
            instruction = 'true'
        separaTask(result)
        args = temp1.replace(' ', '_')
        if instruction == 'true':
            steps = q.lenC()
            plan_name_id = randrange(10000)
            args = "plan-" + str(plan_name_id) + " " + str(
                steps) + " " + temp1.replace(' ', '_')
        #return Response.FromCommandObject(c, True, args)
        return (1, args)
Ejemplo n.º 15
0
import time
import egprs_interpreter
import sys

filename = sys.argv[1]
with open(filename) as f:
    content = f.read()

interpreted_command = egprs_interpreter.interpret_command(content)

print " "
print "Comando Interpretado:"
print interpreted_command