@@ -58,7 +58,14 @@ def _get_plugin_counter(self, secret_type: str) -> 'StatisticsCounter':
58
58
return cast (StatisticsCounter , self .data [secret_type ]['stats' ])
59
59
60
60
def __str__ (self ) -> str :
61
- raise NotImplementedError
61
+ output = ''
62
+
63
+ for secret_type , framework in self .data .items ():
64
+ output += f'Plugin: { get_mapping_from_secret_type_to_class ()[secret_type ].__name__ } \n '
65
+ for value in framework .values ():
66
+ output += f'Statistics: { value } \n \n '
67
+
68
+ return output
62
69
63
70
def json (self ) -> Dict [str , Any ]:
64
71
output = {}
@@ -77,19 +84,36 @@ def __init__(self) -> None:
77
84
self .incorrect : int = 0
78
85
self .unknown : int = 0
79
86
80
- def __repr__ (self ) -> str :
87
+ def __str__ (self ) -> str :
81
88
return (
82
- f'{ self .__class__ .__name__ } (correct={ self .correct } , '
83
- 'incorrect={self.incorrect}, unknown={self.unknown},)'
89
+ f'True Positives: { self .correct } , False Positives: { self .incorrect } , '
90
+ f'Unknown: { self .unknown } , Precision: { self .calculate_precision ()} , '
91
+ f'Recall: { self .calculate_recall ()} '
84
92
)
85
93
86
94
def json (self ) -> Dict [str , Any ]:
95
+ return {
96
+ 'raw' : {
97
+ 'true-positives' : self .correct ,
98
+ 'false-positives' : self .incorrect ,
99
+ 'unknown' : self .unknown ,
100
+ },
101
+ 'score' : {
102
+ 'precision' : self .calculate_precision (),
103
+ 'recall' : self .calculate_recall (),
104
+ },
105
+ }
106
+
107
+ def calculate_precision (self ) -> float :
87
108
precision = (
88
109
round (float (self .correct ) / (self .correct + self .incorrect ), 4 )
89
110
if (self .correct and self .incorrect )
90
111
else 0.0
91
112
)
92
113
114
+ return precision
115
+
116
+ def calculate_recall (self ) -> float :
93
117
# NOTE(2020-11-08|domanchi): This isn't the formal definition of `recall`, however,
94
118
# this is the definition that we're going to attribute to it.
95
119
#
@@ -124,14 +148,4 @@ def json(self) -> Dict[str, Any]:
124
148
else 0.0
125
149
)
126
150
127
- return {
128
- 'raw' : {
129
- 'true-positives' : self .correct ,
130
- 'false-positives' : self .incorrect ,
131
- 'unknown' : self .unknown ,
132
- },
133
- 'score' : {
134
- 'precision' : precision ,
135
- 'recall' : recall ,
136
- },
137
- }
151
+ return recall
0 commit comments