diff --git a/lib/tasks/tag_clustering.rake b/lib/tasks/tag_clustering.rake index 402a7261d3981f2685c17a81ed85eb30858de0fb..8a7e942f40dfa8051652f96eebecb19faf7a5387 100644 --- a/lib/tasks/tag_clustering.rake +++ b/lib/tasks/tag_clustering.rake @@ -197,10 +197,10 @@ namespace :tag do puts "\nStarted Ranking LOs...\n" # ranks each LO - # freq = cluster_frequency(close_tags) + # freq_cluster = cluster_frequency(close_tags) LearningObject.all.each do |lo| los_ranked[lo.id] = relevance_frequency_rank(lo, close_tags) - # los_ranked[lo.id] = relevance_frequency_rank_global(lo, close_tags, freq) + # los_ranked[lo.id] = relevance_frequency_rank_global(lo, close_tags, freq_cluster) # los_ranked[lo.id] = relevance_raw_rank(lo, close_tags) end @@ -245,7 +245,7 @@ namespace :tag do def relevance_frequency_rank_global(lo, close_tags, freq_cluster) # for each tag in LO that is in the cluster, accumulate it's rank - rank_sum = 0 + rank_sum = 1 lo.tags.each do |t| close_tags.each do |tag| if tag[:id] == t.id @@ -255,11 +255,11 @@ namespace :tag do end wdf = 0 - wdf = (Math.log2(freq+1)/(Math.log2(lo.tags.size)+1)) if lo.tags.size != 0 + wdf = (Math.log2(rank_sum)/(Math.log2(lo.tags.size)+1)) if lo.tags.size != 0 itf = Math.log2(Tag.all.size/freq_cluster)+1 - return wdf*itf*rank_sum + return wdf*itf end # returns the rank sum of the tags in the LO