from train_network import Trainer if __name__ == '__main__': file = open('points_data', 'r') # file = open('multi', 'r') #file = open('A.txt', 'r') lines = file.readlines() currCharacter = 'a' multiple = False count = 0 strokes = [] points = [] trainer = Trainer() first = True i = 0 while i < len(lines): line = lines[i] if ".SEGMENT" in lines[i]: if not first: if currCharacter[0] < 'A' or currCharacter[0] > 'Z': trainer.addTrainingSetEntry(strokes, currCharacter, False) currCharacter = line.strip().split(' ')[-1].strip('"') if currCharacter == '%3C': currCharacter = '<' elif currCharacter == '%3E': currCharacter = '>' elif currCharacter == '^': currCharacter = '#' elif currCharacter == 'eq':
#!/usr/bin/python from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer from os import curdir, sep import cgi import json from train_network import Trainer import urlparse PORT_NUMBER = 8000 trainer = Trainer() trainer.trainNetwork() class myHandler(BaseHTTPRequestHandler): #Handler for the POST requests def do_POST(self): global trainer result = urlparse.urlparse(self.path) if result.path=="/test": print "in post method, test" self.data_string = self.rfile.read(int(self.headers['Content-Length'])) self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') self.end_headers() #data = json.loads(self.data_string) #print data print "after json data" ans = trainer.testNetwork(self.data_string)