def do_GET(self):
     data = None;
     reset = False;
     if self.path[0:4] == "/new":
         print "NEW"
         data = self.path[4+5:];
         reset = True;
     elif self.path[0:7] == "/update":
         data = self.path[7+5:];            
     else:
         if self.path == '/':
             self.path = '/interface.html';
         
         return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self);
     
     # Since we are here, we need to process the string in data.
     
     data = urllib.unquote(data).strip().split();
     print data;
     if reset or not self.ip:
         if self.ip:
             self.ip.close();
         self.ip = IncrementalParser(sc);
     
     dist = self.ip.setTo(data);
     sendstr = ", ".join(str(ob) + ": " + str(dist["orange_" + str(ob)]) for ob in range(1, 8) if "orange_" + str(ob) in sc)
     
     self.send_response(200)
     self.send_header('Content-Type', 'text/plain')
     self.end_headers()
     
     self.wfile.write(sendstr);
     self.wfile.close();
Beispiel #2
0
def run():
    k = 0;
    scenes = load_scenes();

    split = load_data(OP_SPLIT_FN);
    tokens = load_data(OP_TOKEN_FN);
    img = load_data(OP_IMAGE_FN);
    
    rv = load();
    timing = [];
    starti = 0;
    if rv:
        starti = max(rv.iterkeys()) + 1;
    
    for i,(sp,tok,(sc,ob)) in enumerate(zip(split, tokens, img)):        
        if sp != "test":
            continue;
    
        if i < starti:
            continue;            
        
        print str(i) + ": " + " ".join(tok);
        
        k = (k + 1) % 10;
        if k == 0:
            save(rv, timing);


                
        ip = IncrementalParser(scenes[sc]);
        wlist = [];        
        for w in tok:
            print w;
            t = time.clock();
            dist = ip.next(w);
            timing.append(time.clock() - t);
            wlist.append(dist);
        
        ip.close();
        rv[i] = wlist;
        
    save(rv, timing);