svenwey commited on
Commit
ededaca
·
1 Parent(s): 1f7e97c

revert changes

Browse files
Files changed (1) hide show
  1. logmetric.py +9 -12
logmetric.py CHANGED
@@ -19,7 +19,6 @@ import re
19
  import dateutil.parser
20
  import numpy as np
21
  from difflib import SequenceMatcher
22
- import sacrebleu
23
 
24
  import time
25
 
@@ -71,8 +70,7 @@ class LogMetric(evaluate.Metric):
71
  # Constant regex to get timestrings
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
- sacrebleu = evaluate.load("evaluate-metric/sacrebleu")
75
-
76
 
77
  def _info(self):
78
  # TODO: Specifies the evaluate.EvaluationModuleInfo object
@@ -115,15 +113,13 @@ class LogMetric(evaluate.Metric):
115
 
116
  # Use minimum edit distance between two sentences
117
  def get_overall_similarity(self, sentence1, sentence2):
118
- return sacrebleu.compute(predictions=sentence1, references=sentence2)
119
-
120
- # s1split = sentence1.split()
121
- # s2split = sentence2.split()
122
 
123
- # jaccard_score = self.get_jaccard_similarity(set(s1split), set(s2split))
124
- # length_score = self.get_length_score(s1split, s2split)
125
 
126
- # return (jaccard_score * 0.7 + length_score * 0.3) * 100.0
127
 
128
  def getLogMetric(self, pred : str, ref : str):
129
  ref = ref.strip(' \t\n\r')
@@ -198,10 +194,11 @@ class LogMetric(evaluate.Metric):
198
  monotonicallyIncreasingScore = 0.0
199
 
200
  # apply jaccard-similarity to every pred-ref pair and then take mean score * 100
201
- local_score = self.get_overall_similarity(
 
202
  list(map(lambda t: t[1], pred_logentries))[:min_logentries],
203
  list(map(lambda t: t[1], ref_logentries))[:min_logentries]
204
- )
205
 
206
 
207
  # we aggregate the bleu scores where we weight the difference in logentries with a score of 0
 
19
  import dateutil.parser
20
  import numpy as np
21
  from difflib import SequenceMatcher
 
22
 
23
  import time
24
 
 
70
  # Constant regex to get timestrings
71
  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*'
72
  timestamp_pattern = re.compile(timestamp_regex, re.MULTILINE)
73
+
 
74
 
75
  def _info(self):
76
  # TODO: Specifies the evaluate.EvaluationModuleInfo object
 
113
 
114
  # Use minimum edit distance between two sentences
115
  def get_overall_similarity(self, sentence1, sentence2):
116
+ s1split = sentence1.split()
117
+ s2split = sentence2.split()
 
 
118
 
119
+ jaccard_score = self.get_jaccard_similarity(set(s1split), set(s2split))
120
+ length_score = self.get_length_score(s1split, s2split)
121
 
122
+ return (jaccard_score * 0.7 + length_score * 0.3) * 100.0
123
 
124
  def getLogMetric(self, pred : str, ref : str):
125
  ref = ref.strip(' \t\n\r')
 
194
  monotonicallyIncreasingScore = 0.0
195
 
196
  # apply jaccard-similarity to every pred-ref pair and then take mean score * 100
197
+ local_score = np.mean([self.get_overall_similarity(p, r) for p,r in
198
+ zip(
199
  list(map(lambda t: t[1], pred_logentries))[:min_logentries],
200
  list(map(lambda t: t[1], ref_logentries))[:min_logentries]
201
+ )])
202
 
203
 
204
  # we aggregate the bleu scores where we weight the difference in logentries with a score of 0