Первый запуск
This commit is contained in:
24
Processor/Models/LogTemplate.py
Normal file
24
Processor/Models/LogTemplate.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from typing import List, Union
|
||||
|
||||
from Processor.Models.LogVariable import LogVariable
|
||||
|
||||
|
||||
class LogTemplate:
|
||||
def __init__(self, uid: int, tokens: List[Union[str, LogVariable]], representative_log: str):
|
||||
self.uid = uid
|
||||
self.tokens = tokens
|
||||
self.representative_log = representative_log
|
||||
self.embedding = None
|
||||
self.hits = 1
|
||||
self.local_var_counter = 1
|
||||
|
||||
def get_tokens_as_str_list(self) -> List[str]:
|
||||
return [str(t) if isinstance(t, LogVariable) else t for t in self.tokens]
|
||||
|
||||
def render(self) -> str:
|
||||
return "".join(str(t) for t in self.tokens)
|
||||
|
||||
def get_next_var_id(self) -> int:
|
||||
vid = self.local_var_counter
|
||||
self.local_var_counter += 1
|
||||
return vid
|
||||
12
Processor/Models/LogVariable.py
Normal file
12
Processor/Models/LogVariable.py
Normal file
@@ -0,0 +1,12 @@
|
||||
class LogVariable:
|
||||
def __init__(self, uid: int, initial_value: str = "", var_type: str = "VAR"):
|
||||
self.uid = uid
|
||||
self.initial_value = initial_value
|
||||
self.var_type = var_type
|
||||
|
||||
def __str__(self):
|
||||
return f"<{self.var_type}_{self.uid}>"
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
Reference in New Issue
Block a user