Skip to content

Commit

Permalink
Refactor Leva's RunnerResult to improve parsed predictions extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
kieranklaassen committed Aug 23, 2024
1 parent 07571a3 commit 23a5393
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/models/leva/runner_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ class RunnerResult < ApplicationRecord

delegate :ground_truth, to: :dataset_record

# @return [Array<String>] The parsed prediction
# @return [Array<String>] The parsed draft responses
def parsed_predictions
@parsed_predictions ||= begin
if dataset_record.recordable.extract_regex_pattern
match_data = prediction.match(dataset_record.recordable.extract_regex_pattern)
match_data ? match_data.captures : prediction
else
prediction
end
end
@parsed_predictions ||= if extract_regex_pattern
prediction.scan(extract_regex_pattern).map { |_, content| content.strip }
else
[prediction]
end
end
end
end

0 comments on commit 23a5393

Please sign in to comment.