remove the part which computes the sacrebleu-metric
Browse files- logscoremetric.py +2 -21
logscoremetric.py
CHANGED
@@ -69,7 +69,6 @@ class LogScoreMetric(evaluate.Metric):
|
|
69 |
# Constant regex to get timestrings
|
70 |
timestamp_regex = r'(^\d{4}[-/.]\d{2}[-/.]\d{2}(?:[ T]\d{2}[:]\d{2}(?:[:]\d{2}(?:[.,]\d+)?)?(?:Z|[+-]\d{2}[:]\d{2})?)?)'
|
71 |
timestamp_pattern = re.compile(timestamp_regex, re.MULTILINE)
|
72 |
-
sacrebleu = evaluate.load("sacrebleu")
|
73 |
|
74 |
def _info(self):
|
75 |
# TODO: Specifies the evaluate.EvaluationModuleInfo object
|
@@ -144,30 +143,12 @@ class LogScoreMetric(evaluate.Metric):
|
|
144 |
"""Returns the scores"""
|
145 |
|
146 |
t_before_logmetric = time.perf_counter()
|
147 |
-
|
148 |
timestamp_score = np.mean([self.getLogMetric(p,r) for p,r in zip(predictions,references)])
|
|
|
149 |
|
150 |
-
t_after_logmetric = t_before_timestamp_rm = time.perf_counter()
|
151 |
-
|
152 |
-
predictions_without_timestamps = [self.timestamp_pattern.sub('', p) for p in predictions]
|
153 |
-
references_without_timestamps = [self.timestamp_pattern.sub('', r) for r in references]
|
154 |
-
|
155 |
-
t_after_timestamp_rm = t_before_sacrebleu = time.perf_counter()
|
156 |
-
|
157 |
-
# Sacrebleu score on logs without timestamps
|
158 |
-
sb_results = self.sacrebleu.compute(predictions=predictions_without_timestamps, references=references_without_timestamps)
|
159 |
-
|
160 |
-
t_after_sacrebleu = time.perf_counter()
|
161 |
logmetric_duration = f" {t_after_logmetric - t_before_logmetric:0.10f}"
|
162 |
-
timestamp_rm_duration = f" {t_after_timestamp_rm - t_before_timestamp_rm:0.10f}"
|
163 |
-
sacrebleu_duration = f" {t_after_sacrebleu - t_before_sacrebleu:0.10f}"
|
164 |
-
overall_duration = f" {t_after_sacrebleu - t_before_logmetric:0.10f}"
|
165 |
|
166 |
return {
|
167 |
"timestamp_score": timestamp_score,
|
168 |
-
"
|
169 |
-
"logmetric_duration":logmetric_duration,
|
170 |
-
"timestamp_rm_duration":timestamp_rm_duration,
|
171 |
-
"sacrebleu_duration":sacrebleu_duration,
|
172 |
-
"overall_duration":overall_duration
|
173 |
}
|
|
|
69 |
# Constant regex to get timestrings
|
70 |
timestamp_regex = r'(^\d{4}[-/.]\d{2}[-/.]\d{2}(?:[ T]\d{2}[:]\d{2}(?:[:]\d{2}(?:[.,]\d+)?)?(?:Z|[+-]\d{2}[:]\d{2})?)?)'
|
71 |
timestamp_pattern = re.compile(timestamp_regex, re.MULTILINE)
|
|
|
72 |
|
73 |
def _info(self):
|
74 |
# TODO: Specifies the evaluate.EvaluationModuleInfo object
|
|
|
143 |
"""Returns the scores"""
|
144 |
|
145 |
t_before_logmetric = time.perf_counter()
|
|
|
146 |
timestamp_score = np.mean([self.getLogMetric(p,r) for p,r in zip(predictions,references)])
|
147 |
+
t_after_logmetric = time.perf_counter()
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
logmetric_duration = f" {t_after_logmetric - t_before_logmetric:0.10f}"
|
|
|
|
|
|
|
150 |
|
151 |
return {
|
152 |
"timestamp_score": timestamp_score,
|
153 |
+
"logmetric_duration": logmetric_duration,
|
|
|
|
|
|
|
|
|
154 |
}
|