Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix RRE export format #929

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/assets/javascripts/components/export_case/_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ <h3 class="modal-title">Export Case: <span class="modal-case">{{ ctrl.theCase.ca
<hr/>
<div class="form-group">
<input type="radio" id="rre" name="exportSelection" value="rre" ng-model="ctrl.options.which">
<label for="rre">Rated Ranking Evaluator</label>
<label for="rre">Rated Ranking Evaluator / RankQuest</label>
<span class="help-block">
Need to gather relevance metrics for 1000's of queries? <a href="https://github.com/SeaseLtd/rated-ranking-evaluator" target="_blank">Rated Ranking Evaluator</a> is a great option! This exports
the judgement list in the RRE format.
Using <a href="https://github.com/SeaseLtd/rated-ranking-evaluator" target="_blank">Rated Ranking Evaluator</a> or <a href="https://rankquest.jillesvangurp.com/" target="_blank">RankQuest</a>? Use the RRE format to export the ratings from Quepid to import into those tools.
</span>
</div>
<div class="form-group">
Expand Down
15 changes: 2 additions & 13 deletions app/views/api/v1/export/ratings/_rre_query.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,8 @@ json.placeholders do
json.set!('$query', query.query_text)
end

grouped_ratings = {}

query.ratings.fully_rated.each do |r|
# rubocop:disable Style/IfUnlessModifier
unless grouped_ratings.key?(r.rating)
grouped_ratings[r.rating] = []
end
# rubocop:enable Style/IfUnlessModifier
grouped_ratings[r.rating] << r.doc_id
end

json.relevant_documents do
grouped_ratings.sort.to_h.each do |key, value|
json.set!(key, value)
query.ratings.fully_rated.each do |r|
json.set!(r.doc_id, { gain: r.rating.to_i } )
end
end
16 changes: 14 additions & 2 deletions test/controllers/api/v1/export/ratings_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RatingsControllerTest < ActionController::TestCase
end

describe 'Exporting a case in RRE json format' do
let(:the_case) { cases(:one) }
let(:the_case) { cases(:queries_case) }

test 'returns case info' do
get :show, params: { case_id: the_case.id, file_format: 'rre' }
Expand All @@ -55,7 +55,19 @@ class RatingsControllerTest < ActionController::TestCase
assert_equal body['queries'].size, the_case.queries.size
assert_equal body['queries'][0]['placeholders']['$query'], the_case.queries[0].query_text
assert_equal body['queries'][2]['placeholders']['$query'], the_case.queries[2].query_text
assert_nil body['queries'][2]['relevant_documents']
assert_not_nil body['queries'][2]['relevant_documents']

# somewhat verbose RRE format for describing ratings.
expected_relevant_docs = {
docb: {
gain: 1,
},
doca: {
gain: 3,
},
}

assert_equal expected_relevant_docs, body['queries'][2]['relevant_documents'].deep_symbolize_keys
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/teams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
valid:
name: valid team
owner: :doug
cases: shared_through_owned_team
cases: shared_through_owned_team, queries_case
members: doug

shared:
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/tries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,5 @@ for_case_queries_case:
case: :queries_case
query_params: 'q=#$query##'
try_number: 1
field_spec: id:id title:title
search_endpoint: :for_case_queries_case