Skip to content

Commit

Permalink
local inference case issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aaravnavani committed Aug 30, 2024
1 parent ebbb529 commit 827cf03
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions validator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def filter_output_in_sentence(self, sentence: str, competitors: List[str]) -> st
filtered_text = sentence

for competitor in competitors:
filtered_text = filtered_text.replace(competitor, "[COMPETITOR]")
pattern = re.compile(re.escape(competitor), re.IGNORECASE)
filtered_text = pattern.sub("[COMPETITOR]", filtered_text)

return filtered_text

Expand All @@ -259,12 +260,10 @@ def compute_error_spans(self, sentences: List[str], competitors_per_sentence: Li


for competitor in competitors:
start_idx = 0
while sentence.find(competitor, start_idx) > -1:
start_idx = sentence.find(competitor, start_idx)
end_idx = start_idx + len(competitor)
pattern = re.compile(re.escape(competitor), re.IGNORECASE)
for match in pattern.finditer(sentence):
start_idx, end_idx = match.span()
error_spans.append(ErrorSpan(start=start_idx, end=end_idx, reason=f"Competitor was found: {competitor}"))
start_idx = end_idx

return error_spans

Expand Down

0 comments on commit 827cf03

Please sign in to comment.