don't require space before & after
Browse files- logmetric.py +4 -4
logmetric.py
CHANGED
@@ -72,10 +72,10 @@ class LogMetric(evaluate.Metric):
|
|
72 |
timestamp_regex = r'^\s*\[?\s*(\d{4}[-/.]\d{2}[-/.]\d{2}(?:[ T]\d{2}[:]\d{2}(?:[:]\d{2}(?:[.,]\d+)?)?(?:Z|[+-]\d{2}[:]\d{2})?)?)\s*\]?\s*'
|
73 |
timestamp_pattern = re.compile(timestamp_regex, re.MULTILINE)
|
74 |
|
75 |
-
int_regex = r'(
|
76 |
int_pattern = re.compile(int_regex)
|
77 |
|
78 |
-
float_regex = r'(
|
79 |
float_pattern = re.compile(float_regex)
|
80 |
|
81 |
sacrebleu_metric = evaluate.load("evaluate-metric/sacrebleu")
|
@@ -161,8 +161,8 @@ class LogMetric(evaluate.Metric):
|
|
161 |
return self.smapeScore(pred_lines_amt, ref_lines_amt)
|
162 |
|
163 |
def replaceNumbers(self, text:str):
|
164 |
-
text = self.int_pattern.sub(r'
|
165 |
-
text = self.float_pattern.sub(r'
|
166 |
return text
|
167 |
|
168 |
# Get differenct scores regarding the content of a log-message
|
|
|
72 |
timestamp_regex = r'^\s*\[?\s*(\d{4}[-/.]\d{2}[-/.]\d{2}(?:[ T]\d{2}[:]\d{2}(?:[:]\d{2}(?:[.,]\d+)?)?(?:Z|[+-]\d{2}[:]\d{2})?)?)\s*\]?\s*'
|
73 |
timestamp_pattern = re.compile(timestamp_regex, re.MULTILINE)
|
74 |
|
75 |
+
int_regex = r'(-?\d+)'
|
76 |
int_pattern = re.compile(int_regex)
|
77 |
|
78 |
+
float_regex = r'(-?\d+\.\d+)'
|
79 |
float_pattern = re.compile(float_regex)
|
80 |
|
81 |
sacrebleu_metric = evaluate.load("evaluate-metric/sacrebleu")
|
|
|
161 |
return self.smapeScore(pred_lines_amt, ref_lines_amt)
|
162 |
|
163 |
def replaceNumbers(self, text:str):
|
164 |
+
text = self.int_pattern.sub(r'<|INT|>', text)
|
165 |
+
text = self.float_pattern.sub(r'<|FLOAT|>', text)
|
166 |
return text
|
167 |
|
168 |
# Get differenct scores regarding the content of a log-message
|