diff --git a/lib/twitter_ebooks/model.rb b/lib/twitter_ebooks/model.rb index 6d4af13..03f4fe5 100644 --- a/lib/twitter_ebooks/model.rb +++ b/lib/twitter_ebooks/model.rb @@ -63,9 +63,9 @@ module Ebooks next if l.include?('RT') || l.include?('MT') # Remove soft retweets if l.include?('@') - statements << NLP.normalize(l) - else mentions << NLP.normalize(l) + else + statements << NLP.normalize(l) end end diff --git a/spec/model_spec.rb b/spec/model_spec.rb index 8fdc82d..4837735 100644 --- a/spec/model_spec.rb +++ b/spec/model_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' require 'memory_profiler' +require 'tempfile' def Process.rss; `ps -o rss= -p #{Process.pid}`.chomp.to_i; end @@ -11,4 +12,30 @@ describe Ebooks::Model do expect(report.total_memsize).to be < 1000000000 end + + describe '.consume' do + it 'interprets lines with @ as mentions' do + file = Tempfile.new('mentions') + file.write('@m1spy hello!') + file.close + + model = Ebooks::Model.consume(file.path) + expect(model.sentences.count).to eq 0 + expect(model.mentions.count).to eq 1 + + file.unlink + end + + it 'interprets lines without @ as statements' do + file = Tempfile.new('statements') + file.write('hello!') + file.close + + model = Ebooks::Model.consume(file.path) + expect(model.mentions.count).to eq 0 + expect(model.sentences.count).to eq 1 + + file.unlink + end + end end