change keeper name to tagger
This commit is contained in:
@@ -7,9 +7,13 @@ class PostKeeperManager
|
||||
delay(queue: "default").check_and_update(post_id)
|
||||
end
|
||||
|
||||
# in general, unweighted changes attribution 5% of the time,
|
||||
# weighted changes attribution 12% of the time at w=1000,
|
||||
# up to 17% of the time at w=100.
|
||||
def self.evaluate(post_ids)
|
||||
total = 0
|
||||
matches = 0
|
||||
weighted_matches = 0
|
||||
keeper_dist = {}
|
||||
uploader_dist = {}
|
||||
Post.where(id: post_ids).find_each do |post|
|
||||
@@ -17,15 +21,20 @@ class PostKeeperManager
|
||||
total += 1
|
||||
if keeper != post.uploader_id
|
||||
matches += 1
|
||||
keeper_dist[keeper] ||= 0
|
||||
keeper_dist[keeper] += 1
|
||||
uploader_dist[post.uploader_id] ||= 0
|
||||
uploader_dist[post.uploader_id] += 1
|
||||
# keeper_dist[keeper] ||= 0
|
||||
# keeper_dist[keeper] += 1
|
||||
# uploader_dist[post.uploader_id] ||= 0
|
||||
# uploader_dist[post.uploader_id] += 1
|
||||
end
|
||||
if check_weighted(post) != post.uploader_id
|
||||
puts post.id
|
||||
weighted_matches += 1
|
||||
end
|
||||
end
|
||||
|
||||
puts "total: #{total}"
|
||||
puts "changes: #{matches}"
|
||||
puts "unweighted changes: #{matches}"
|
||||
puts "weighted changes: #{weighted_matches}"
|
||||
# puts "keepers:"
|
||||
# keeper_dist.each do |k, v|
|
||||
# puts " #{k}: #{v}"
|
||||
@@ -44,6 +53,72 @@ class PostKeeperManager
|
||||
end
|
||||
end
|
||||
|
||||
def self.print_weighted(post, w = 1000)
|
||||
changes = {}
|
||||
final_tags = Set.new(post.tag_array)
|
||||
|
||||
# build a mapping of who added a tag first
|
||||
PostArchive.where(post_id: post.id).order("updated_at").each do |pa|
|
||||
pa.added_tags.each do |at|
|
||||
if pa.updater_id
|
||||
if !changes.has_key?(at) && final_tags.include?(at)
|
||||
changes[at] = pa.updater_id
|
||||
end
|
||||
|
||||
if pa.source_changed? && pa.source == post.source
|
||||
changes[" source"] = pa.updater_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# add up how many changes each user has made
|
||||
ranking = changes.values.uniq.inject({}) do |h, user_id|
|
||||
h[user_id] = changes.select {|k, v| v == user_id}.map do |tag, user_id|
|
||||
count = Tag.find_by_name(tag).try(:post_count) || 0
|
||||
1.0 / (w + count)
|
||||
end.sum
|
||||
h
|
||||
end
|
||||
|
||||
ranking.sort_by {|k, v| v}.each do |user_id, score|
|
||||
user = User.find(user_id)
|
||||
sum = changes.select {|k, v| v == user_id}.size
|
||||
Rails.logger.debug "#{user.name}: %.4f (%d)" % [score, sum]
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_weighted(post, w = 1000)
|
||||
changes = {}
|
||||
final_tags = Set.new(post.tag_array)
|
||||
|
||||
# build a mapping of who added a tag first
|
||||
PostArchive.where(post_id: post.id).order("updated_at").each do |pa|
|
||||
pa.added_tags.each do |at|
|
||||
if pa.updater_id
|
||||
if !changes.has_key?(at) && final_tags.include?(at)
|
||||
changes[at] = pa.updater_id
|
||||
end
|
||||
|
||||
if pa.source_changed? && pa.source == post.source
|
||||
changes[" source"] = pa.updater_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# add up how many changes each user has made
|
||||
ranking = changes.values.uniq.inject({}) do |h, user_id|
|
||||
h[user_id] = changes.select {|k, v| v == user_id}.map do |tag, user_id|
|
||||
count = Tag.find_by_name(tag).try(:post_count) || 0
|
||||
1.0 / (w + count)
|
||||
end.sum
|
||||
h
|
||||
end
|
||||
|
||||
ranking.max_by {|k, v| v}.first
|
||||
end
|
||||
|
||||
def self.check(post)
|
||||
changes = {}
|
||||
final_tags = Set.new(post.tag_array)
|
||||
@@ -84,20 +159,10 @@ class PostKeeperManager
|
||||
|
||||
# add up how many changes each user has made
|
||||
ranking = changes.values.uniq.inject({}) do |h, user_id|
|
||||
# h[user_id] = changes.select {|k, v| v == user_id}.map do |tag, user_id|
|
||||
# count = Tag.find_by_name(tag).try(:post_count) || 0
|
||||
# 1.0 / (1000 + count)
|
||||
# end.sum
|
||||
h[user_id] = changes.select {|k, v| v == user_id}.size
|
||||
h
|
||||
end
|
||||
|
||||
# ranking.sort_by {|k, v| v}.each do |user_id, score|
|
||||
# user = User.find(user_id)
|
||||
# sum = changes.select {|k, v| v == user_id}.size
|
||||
# Rails.logger.debug "#{user.name}: %.4f (%d)" % [score, sum]
|
||||
# end
|
||||
|
||||
ranking.max_by {|k, v| v}.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ul itemscope itemtype="http://schema.org/ImageObject">
|
||||
<li>ID: <%= post.id %></li>
|
||||
<li>Keeper: <%= link_to_user(post.keeper) %></li>
|
||||
<li>Tagger: <%= link_to_user(post.keeper) %></li>
|
||||
<li>
|
||||
Date: <%= link_to time_ago_in_words_tagged(post.created_at), posts_path(:tags => "date:#{post.created_at.to_date}"), :rel => "nofollow" %>
|
||||
<meta itemprop="uploadDate" content="<%= post.created_at.iso8601 %>">
|
||||
|
||||
Reference in New Issue
Block a user