Fix parser swapping mentions and sentences
This commit is contained in:
parent
6f27d32bf1
commit
927efe7f07
2 changed files with 29 additions and 2 deletions
|
@ -63,9 +63,9 @@ module Ebooks
|
||||||
next if l.include?('RT') || l.include?('MT') # Remove soft retweets
|
next if l.include?('RT') || l.include?('MT') # Remove soft retweets
|
||||||
|
|
||||||
if l.include?('@')
|
if l.include?('@')
|
||||||
statements << NLP.normalize(l)
|
|
||||||
else
|
|
||||||
mentions << NLP.normalize(l)
|
mentions << NLP.normalize(l)
|
||||||
|
else
|
||||||
|
statements << NLP.normalize(l)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require 'memory_profiler'
|
require 'memory_profiler'
|
||||||
|
require 'tempfile'
|
||||||
|
|
||||||
def Process.rss; `ps -o rss= -p #{Process.pid}`.chomp.to_i; end
|
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
|
expect(report.total_memsize).to be < 1000000000
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue