Skip to content
Snippets Groups Projects
Commit 26cd953b authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Improved merging weight

parent 19a30cc5
No related branches found
No related tags found
No related merge requests found
......@@ -75,7 +75,7 @@ namespace :tag do
$N_LOS = 50
# searched tag
$TAG = Tag.find_by_name("DNA")
$TAG = Tag.find_by_name("Sagitário")
puts "\nStarted Calculating relevant results for tag #{$TAG.name}\n"
......@@ -106,10 +106,11 @@ namespace :tag do
puts ""
end
# Relevancy Weight
$RW = 0.7
proportion = $TAG.taggings.size.to_f/$N_LOS
# Search Weight
$SW = 1 - $RW
$SW = proportion > 0.5 ? 0.5 : proportion
# Relevancy Weight
$RW = 1 - $SW
merged_los = merge(search_los, relevant_los[0])
......@@ -134,18 +135,18 @@ namespace :tag do
merged_los = []
max = search_los.first.search_hit['_score']
# min = search_los[search_los.size-1].search_hit['_score']
min = 0
min = search_los[search_los.size-1].search_hit['_score']
# min = 0
search_los.each do |slo|
slo.search_hit['_score'] = $SW*(slo.search_hit['_score']-min)/(max-min)
slo.search_hit['_score'] = $SW*(slo.search_hit['_score']*(1+$PAD)-min)/(max-min)
end
max = relevant_los.first[1]
# min = relevant_los.last[1]
min = relevant_los.last[1]
relevant_los.each do |rlo|
rlo[1] = $RW*(rlo[1]-min)/(max-min)
rlo[1] = $RW*(rlo[1]*(1+$PAD)-min)/(max-min)
end
search_los.each do |slo|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment