Sha256: 994da7f64f5705c4f6b133bcad7a22281940509d534fb9b98a4da40f32fd1e02

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path("../../lib", File.dirname(__FILE__)))
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
require 'wukong/script'

require 'models'

Settings.use :commandline
Settings.resolve!

Wukong.flow(:mapper) do |input|
  source(:stdin) |
    from_tsv     | map{|arr| arr[3] } | from_json |
    map{|hsh| [ hsh['user_id'], hsh['strong_links'].sort_by{|id,wt| -wt }.map{|id,wt| id } ] } |
    reject{ |(id, links)| links.length < 5 } |
    project{|(id, links)| links[0..49].each{|link| emit([id, link]) unless link.to_i == 0 } } |
    to_tsv | stdout
end

Wukong::Script.new(Settings).run

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wukong-3.0.0.pre2 examples/twitter/pt4-strong_links.rb
wukong-3.0.0.pre examples/twitter/pt4-strong_links.rb