Markopy
Utilizing Markov Models for brute forcing attacks
Python.Markopy.Evaluation.Evaluator Class Reference

Abstract class to evaluate and score integrity/validty. More...

Inheritance diagram for Python.Markopy.Evaluation.Evaluator:
Collaboration diagram for Python.Markopy.Evaluation.Evaluator:

Public Member Functions

None __init__ (self, str filename)
 default constructor for evaluator More...
 
bool evaluate (self)
 
def success (self, checkname)
 pass a test More...
 
def fail (self, checkname)
 fail a test More...
 
def finalize (self)
 

Public Attributes

 filename
 
 checks
 
 TEST_PASS_SYMBOL
 
 TEST_FAIL_SYMBOL
 
 all_checks_passed
 
 files
 
 check_funcs
 

Private Member Functions

list _evaluate (self, file)
 internal evaluation function for a single file More...
 

Detailed Description

Abstract class to evaluate and score integrity/validty.

Definition at line 22 of file evaluate.py.

Constructor & Destructor Documentation

◆ __init__()

None Python.Markopy.Evaluation.Evaluator.__init__ (   self,
str  filename 
)

default constructor for evaluator

Parameters
filenamefilename to evaluate. Can be a pattern

Reimplemented in Python.Markopy.Evaluation.CorpusEvaluator, and Python.Markopy.Evaluation.ModelEvaluator.

Definition at line 27 of file evaluate.py.

27  def __init__(self, filename: str) -> None:
28  """!
29  @brief default constructor for evaluator
30  @param filename filename to evaluate. Can be a pattern
31  """
32  self.filename = filename
33  self.checks = []
34  self.TEST_PASS_SYMBOL = b"\xe2\x9c\x85".decode()
35  self.TEST_FAIL_SYMBOL = b"\xe2\x9d\x8c".decode()
36  self.all_checks_passed = True
37  self.files = []
38  if("*" in filename):
39  self.files = glob.glob(filename)
40  else:
41  self.files.append(filename)
42  return True
43 

Member Function Documentation

◆ _evaluate()

list Python.Markopy.Evaluation.Evaluator._evaluate (   self,
  file 
)
private

internal evaluation function for a single file

Parameters
filefilename to evaluate

Reimplemented in Python.Markopy.Evaluation.CorpusEvaluator.

Definition at line 52 of file evaluate.py.

52  def _evaluate(self, file) -> list:
53  """!
54  @brief internal evaluation function for a single file
55  @param file filename to evaluate
56  """
57  if(not os.path.isfile(file)):
58  logging.pprint(f"Given file {file} is not a valid filename")
59  return False
60  else:
61  return open(file, "rb").read().split(b"\n")
62 
63 
64 

Referenced by Python.Markopy.Evaluation.Evaluator.evaluate(), and Python.Markopy.Evaluation.ModelEvaluator.evaluate().

Here is the caller graph for this function:

◆ evaluate()

bool Python.Markopy.Evaluation.Evaluator.evaluate (   self)

Reimplemented in Python.Markopy.Evaluation.CorpusEvaluator, and Python.Markopy.Evaluation.ModelEvaluator.

Definition at line 44 of file evaluate.py.

44  def evaluate(self) -> bool:
45  "! @brief base evaluation function"
46  for file in self.files:
47  self._evaluate(file)
48 
49  self.check_funcs = [func for func in dir(self) if (callable(getattr(self, func)) and func.startswith("check_"))]
50 

References Python.Markopy.Evaluation.Evaluator._evaluate(), Python.Markopy.Evaluation.CorpusEvaluator._evaluate(), and Python.Markopy.Evaluation.Evaluator.files.

Referenced by Python.Markopy.MarkopyCLI.parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fail()

def Python.Markopy.Evaluation.Evaluator.fail (   self,
  checkname 
)

fail a test

Parameters
checknametext to display with the check

Definition at line 72 of file evaluate.py.

72  def fail(self, checkname):
73  """!
74  @brief fail a test
75  @param checkname text to display with the check
76  """
77 
78  self.all_checks_passed = False
79  self.checks.append((checkname, self.TEST_FAIL_SYMBOL))
80 

References Python.Markopy.Evaluation.Evaluator.all_checks_passed, Python.Markopy.Evaluation.Evaluator.checks, and Python.Markopy.Evaluation.Evaluator.TEST_FAIL_SYMBOL.

Referenced by Python.Markopy.Evaluation.ModelEvaluator.check_dangling(), Python.Markopy.Evaluation.ModelEvaluator.check_lean(), Python.Markopy.Evaluation.ModelEvaluator.check_min(), Python.Markopy.Evaluation.ModelEvaluator.check_structure(), and Python.Markopy.Evaluation.CorpusEvaluator.evaluate().

Here is the caller graph for this function:

◆ finalize()

def Python.Markopy.Evaluation.Evaluator.finalize (   self)

Definition at line 81 of file evaluate.py.

81  def finalize(self):
82  "! @brief finalize an evaluation and print checks"
83  print("\n################ Checks ################ ")
84  for test in self.checks:
85  logging.pprint(f"{test[0]:30}:{test[1]} ")
86  print("\n")
87  self.checks = []
88  return self.all_checks_passed
89 

References Python.Markopy.Evaluation.Evaluator.all_checks_passed, and Python.Markopy.Evaluation.Evaluator.checks.

Referenced by Python.Markopy.Evaluation.CorpusEvaluator.evaluate().

Here is the caller graph for this function:

◆ success()

def Python.Markopy.Evaluation.Evaluator.success (   self,
  checkname 
)

pass a test

Parameters
checknametext to display with the check

Definition at line 65 of file evaluate.py.

65  def success(self, checkname):
66  """!
67  @brief pass a test
68  @param checkname text to display with the check
69  """
70  self.checks.append((checkname, self.TEST_PASS_SYMBOL))
71 

References Python.Markopy.Evaluation.Evaluator.checks, and Python.Markopy.Evaluation.Evaluator.TEST_PASS_SYMBOL.

Referenced by Python.Markopy.Evaluation.ModelEvaluator.check_dangling(), Python.Markopy.Evaluation.ModelEvaluator.check_lean(), Python.Markopy.Evaluation.ModelEvaluator.check_min(), Python.Markopy.Evaluation.ModelEvaluator.check_structure(), and Python.Markopy.Evaluation.CorpusEvaluator.evaluate().

Here is the caller graph for this function:

Member Data Documentation

◆ all_checks_passed

Python.Markopy.Evaluation.Evaluator.all_checks_passed

◆ check_funcs

Python.Markopy.Evaluation.Evaluator.check_funcs

Definition at line 49 of file evaluate.py.

◆ checks

Python.Markopy.Evaluation.Evaluator.checks

◆ filename

Python.Markopy.Evaluation.Evaluator.filename

Definition at line 32 of file evaluate.py.

◆ files

◆ TEST_FAIL_SYMBOL

Python.Markopy.Evaluation.Evaluator.TEST_FAIL_SYMBOL

Definition at line 35 of file evaluate.py.

Referenced by Python.Markopy.Evaluation.Evaluator.fail().

◆ TEST_PASS_SYMBOL

Python.Markopy.Evaluation.Evaluator.TEST_PASS_SYMBOL

Definition at line 34 of file evaluate.py.

Referenced by Python.Markopy.Evaluation.Evaluator.success().


The documentation for this class was generated from the following file: