Class: Datasets::AFINN
Defined Under Namespace
Classes: Record
Instance Attribute Summary
Attributes inherited from Dataset
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize ⇒ AFINN
constructor
A new instance of AFINN.
Methods inherited from Dataset
Constructor Details
#initialize ⇒ AFINN
Returns a new instance of AFINN.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/datasets/afinn.rb', line 9 def initialize super() .id = "afinn" .name = "AFINN" .url = "http://www2.imm.dtu.dk/pubdb/pubs/6010-full.html" .licenses = ["ODbL-1.0"] .description = lambda do extract_file("AFINN/AFINN-README.txt") do |input| readme = input.read readme.force_encoding("UTF-8") readme. gsub(/^AFINN-96:.*?\n\n/m, ""). gsub(/^In Python.*$/m, ""). strip end end end |
Instance Method Details
#each ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/datasets/afinn.rb', line 27 def each return to_enum(__method__) unless block_given? extract_file("AFINN/AFINN-111.txt") do |input| csv = CSV.new(input, col_sep: "\t", converters: :numeric) csv.each do |row| yield(Record.new(*row)) end end end |