Example #1
0
 def changeResolution(self, width, height, full = True, debug = False, logpos = True):
     
     scene = None
     if(self.window.scene != None):
         scene = self.window.scene
     
     self.window.set_fullscreen(False)
     self.window.close()
     self.window = Frame(self, width, height, full, debug, logpos)
     
     if(scene != None):
         self.window.setScene(scene)
     
     setResol('./cnf/config.ini', width, height)
Example #2
0
    def PUSHFRAME(self):
        if not self._tmp_frame.defined:
            raise UndefinedFrameError()

        self._local_frame = self._tmp_frame
        self._local_frame_stack.append(self._local_frame)
        self._tmp_frame = Frame()
Example #3
0
    def __init__(self, source_file):
        self._source_file = source_file

        self._instr_list = dict()
        self._instr_order_list = list()
        self._jump_label_list = dict()

        self._instr_index = 0
        self._instr_args = list()

        self._tmp_frame = Frame(False)
        self._global_frame = Frame(True)
        self._local_frame = Frame(False)

        self._call_stack = list()
        self._data_stack = list()
        self._local_frame_stack = list()
Example #4
0
 def __init__(self):
     
     pyglet.resource.path = ['./res']
     pyglet.resource.reindex()
     
     self.db = DB('localhost', 3306, 'fisica', 'qwe123iop', 'fisica')
     
     platform = pyglet.window.get_platform()
     display = platform.get_default_display()
     self.MW = display.get_screens()[0].width
     self.MH = display.get_screens()[0].height
     
     pyglet.clock.schedule(self.timer)
     self.activateSuck()
     self.window = Frame(self, 400, 400, False, visible=False)
     self.window.set_location(int((self.MW-self.window.width)/2), int((self.MH-self.window.height)/2))
     self.window.setScene(AppLauncher())
     self.window.set_visible(True)
Example #5
0
 def process_row(self, row):
     for s in row:
         if s.startswith("B:") or s.startswith("I:"):
             annot = s.split(":")
             index = annot[len(annot) - 1]
             if annot[1] == "COREF-TARGET-INDIRECT" or annot[
                     1] == "COREF-TARGET-DIRECT" or annot[1] == "MENTION":
                 if index not in self.corefs:
                     self.corefs[index] = Coref(index, row[1])
                 if annot[1] == "COREF-TARGET-INDIRECT" or annot[
                         1] == "COREF-TARGET-DIRECT":
                     self.corefs[index].add_coref(row[3], row[4])
                 else:
                     self.corefs[index].add_mention(row[3])
             if annot[2] == "FE" or annot[2] == "TARGET":
                 semantic_frame = annot[1]
                 if (index, semantic_frame) not in self.frames:
                     self.frames[index, semantic_frame] = Frame(
                         index, semantic_frame)
                 self.frames[index, semantic_frame].add_word(row, annot)
Example #6
0
class Shell():
    
    window = None
    sucket = None
    MW = 0
    MH = 0
    
    
    def __init__(self):
        
        pyglet.resource.path = ['./res']
        pyglet.resource.reindex()
        
        self.db = DB('localhost', 3306, 'fisica', 'qwe123iop', 'fisica')
        
        platform = pyglet.window.get_platform()
        display = platform.get_default_display()
        self.MW = display.get_screens()[0].width
        self.MH = display.get_screens()[0].height
        
        pyglet.clock.schedule(self.timer)
        self.activateSuck()
        self.window = Frame(self, 400, 400, False, visible=False)
        self.window.set_location(int((self.MW-self.window.width)/2), int((self.MH-self.window.height)/2))
        self.window.setScene(AppLauncher())
        self.window.set_visible(True)
    
    
    def timer(self,data):
        
        if(self.window != None):
            
            if(self.window.scene != None):
                
                if(self.window.scene.MODE != 'LOCAL'):
                    self.switchScene()
                
                if(self.window.scene.SIZE != 'CURRENT'):
                    
                    if(self.window.scene.SIZE == 'WIN'):
                        self.window.set_fullscreen(False)
                        self.window.set_location(int((self.MW-self.window.width)/2), int((self.MH-self.window.height)/2))
                    
                    elif (self.window.scene.SIZE == 'LD'):
                        self.changeResolution(800, 600)
                    
                    elif (self.window.scene.SIZE == 'BD'):
                        self.changeResolution(1024, 768)
                    
                    elif (self.window.scene.SIZE == 'HD'):
                        self.changeResolution(1366, 768)
                    
                    self.window.scene.SIZE = 'CURRENT'
            
            self.window.timer(data)
    
    
    def activateSuck(self):
        self.sucket = pyglet.window.Window(self.MW, self.MH, fullscreen=True)
        self.sucket.set_visible(False)
    
    
    def run(self):
        pyglet.app.run()
    
    
    def switchScene(self):
        
        preData = self.window.scene.data
        
        if(self.window.scene.NAME == 'LAUNCHER'):
            
            if(self.window.scene.MODE == 'MENU'):
                w, h = getResol('./cnf/config.ini')
                self.window.scene = None
                self.changeResolution(w, h)
                self.window.setScene(Menu(preData))
        else:
                
            if(self.window.scene.MODE == 'AJUSTES'):
                self.window.setScene(Ajustes(preData))
                
            if(self.window.scene.MODE == 'PRINCIPAL'):
                self.window.setScene(Principal(preData))
                
            if(self.window.scene.MODE == 'AYUDA'):
                self.window.setScene(Ayuda(preData))
                
            if(self.window.scene.MODE == 'MENU'):
                self.window.setScene(Menu(preData))
                
            if(self.window.scene.MODE == 'REGISTRO'):
                preData['dbcon'] = self.db
                self.window.setScene(Registro(preData))
                
            if(self.window.scene.MODE == 'LOGIN'):
                preData['dbcon'] = self.db
                self.window.setScene(Login(preData))
            
            if(self.window.scene.MODE == 'NIVELES'):
                preData['dbcon'] = self.db
                self.window.setScene(Niveles(preData))
                
            if(self.window.scene.MODE == 'NIVEL1'):
                self.window.setScene(Nivel1(preData))
                
            if(self.window.scene.MODE == 'EJERCICIO2_N1'):
                self.window.setScene(Ejercicio2_n1(preData))
                
            if(self.window.scene.MODE == 'EJERCICIO3_N1'):
                self.window.setScene(Ejercicio3_n1(preData))
                
            if(self.window.scene.MODE == 'EJERCICIO1_N2'):
                self.window.setScene(Ejercicio1_n2(preData))
                
            if(self.window.scene.MODE == 'EJERCICIO2_N2'):
                self.window.setScene(Ejercicio2_n2(preData))
    
            if(self.window.scene.MODE == 'EJERCICIO3_N2'):
                self.window.setScene(Ejercicio3_n2(preData))
            
            if(self.window.scene.MODE == 'EJERCICIO1_N3'):
                self.window.setScene(Ejercicio1_n3(preData))    
                
            if(self.window.scene.MODE == 'EJERCICIO2_N3'):
                self.window.setScene(Ejercicio2_n3(preData))   
                
            if(self.window.scene.MODE == 'EJERCICIO3_N3'):
                self.window.setScene(Ejercicio3_n3(preData))   
                
    def changeResolution(self, width, height, full = True, debug = False, logpos = True):
        
        scene = None
        if(self.window.scene != None):
            scene = self.window.scene
        
        self.window.set_fullscreen(False)
        self.window.close()
        self.window = Frame(self, width, height, full, debug, logpos)
        
        if(scene != None):
            self.window.setScene(scene)
        
        setResol('./cnf/config.ini', width, height)
    
    
    def run_close(self):
        self.sucket.close()
 for dir in os.listdir(json_dir):
     dir1 = os.path.join(json_dir, dir)
     for f in os.listdir(dir1):
         file_name = os.path.join(dir1, f)
         data = json.load(io.open(file_name))
         for elem in data["annotations"]:
             result_file_name = "out/corpus/" + dir + '/question.' + str(
                 question_index) + '.json'
             question_index += 1
             id = elem["id"]
             lu_index = elem["lu_index"]
             if (id, lu_index) in natural_questions:
                 elem = natural_questions[(id, lu_index)]
                 del natural_questions[(id, lu_index)]
             frame_name = elem["frame"]
             frame = Frame(id, frame_name)
             for fe in elem["frame_elements"]:
                 fe["generated_questions_from_auto_patterns"] = []
                 fe["generated_questions_from_manual_patterns"] = []
                 fe_name = fe["name"]
                 frame.frame_elements[fe_name] = FrameElement(
                     fe_name, None, None, frame.semantic_frame)
                 frame.frame_elements[fe_name].words = fe["text"].split()
                 coref = fe["coref"]["text"]
                 if coref != "":
                     new_coref = Coref(None, None)
                     new_coref.coref = coref.split()
                     frame.frame_elements[fe_name].coref = new_coref
             questions, answers, _ = questionsGenerator_manual.generate(
                 frame, False, patterns_id=True)
             for i in range(len(questions)):