Beispiel #1
0
 def all_in_file(self, filename, event_dictionary=None):
     # Sanity check. Are all points from file inside the Hull?
     # It makes thing slower, speacially in big cases
     parser = XesParser(filename)
     parser.event_dictionary = event_dictionary or {}
     parser.parse()
     parser.parikhs_vector()
     return self.all_in(parser.pv_set)
Beispiel #2
0
 def all_in_file(self, filename, event_dictionary=None):
     # Esto es para chequear que no dejando a nadia afuera
     # hace todo más lento en ejemplos grandes
     parser = XesParser(filename)
     parser.event_dictionary = event_dictionary or {}
     parser.parse()
     parser.parikhs_vector()
     return self.all_in(parser.pv_set)
Beispiel #3
0
 def check_hull(self, log_file='', event_dictionary={}):
     if not (log_file.endswith('.xes')):
         print log_file, ' does not end in .xes. It should...'
         raise Exception('Filename does not end in .xes')
     if not isfile(log_file):
         raise Exception("No such file")
     # For every benchmark, check that the hull accepts the positive log
     parser = XesParser(log_file)
     parser.event_dictionary = event_dictionary or {}
     parser.parse()
     parser.parikhs_vector()
     for benchmark in ['no_smt', 'smt_iter', 'smt_matrix']:
         qhull = getattr(self,'qhull_'+benchmark)
         try:
             qhull.all_in(parser.pv_set)
         except Exception, err:
             logger.error("Error running check_hull for %s, file %s",benchmark, log_file, exc_info=True)
             raise
Beispiel #4
0
def parser_main():
    usage = """
        Usage: ./parser.py <LOG filename> [--verbose][--debug]
    """
    if not check_argv(sys.argv, minimum=1, maximum=4):
        print usage
        ret = -1
    else:
        ret = 0
        try:
            if '--debug' in sys.argv:
                pdb.set_trace()
            filename = sys.argv[1]
            if not (filename.endswith('.xes') or filename.endswith('.txt')):
                print filename, ' does not end in .xes nor .txt. It should...'
                raise Exception('Filename has wrong extension')
            if not isfile(filename):
                raise Exception("No such file")
            if filename.endswith('.xes'):
                obj = XesParser(filename)
            elif filename.endswith('.txt'):
                obj = AdHocParser(filename)
            obj.parse()
            if '--verbose' in sys.argv:
                print 'Parse done. Calcuting Parikhs vector'
            obj.parikhs_vector()
            print 'Se encontraron {0} puntos en un espacio de dimensión {1}'.format(
                    len(obj.pv_set), obj.dim)
            if '--verbose' in sys.argv:
                print "#"*15
        except Exception, err:
            ret = 1
            if hasattr(err, 'message'):
                print 'Error: ', err.message
            else:
                print 'Error: ', err
            logger.error('Error: %s' % err, exc_info=True)
            raise err
        return ret
Beispiel #5
0
 def parse_traces(self):
     if self.filename.endswith('.xes'):
         parser = XesParser(self.filename)
     elif self.filename.endswith('.txt'):
         parser = AdHocParser(self.filename)
     elif self.filename.endswith('.pnml'):
         parser = PnmlParser(self.filename)
     else:
         logger.error("Error in file %s extension. Only '.xes', '.pnml' and '.txt'"\
                 " are allowed!",(self.filename or ''))
         raise Exception("Error in file %s extension. Only '.xes', '.pnml' and '.txt'"\
                 " are allowed!"%(self.filename or ''))
     parser.parse()
     self.event_dictionary = parser.event_dictionary
     self.reversed_dictionary = rotate_dict(parser.event_dictionary)
     if self.filename.endswith('.pnml'):
         self.parsed_petrinet = parser.petrinet
     else:
         parser.parikhs_vector()
         self.pv_traces = parser.pv_traces
         self.pv_set = parser.pv_set
         self.pv_array = parser.pv_array
     self.dim = parser.dim