Test that models save and load correctly
This commit is contained in:
parent
7e62000e37
commit
0cb7abcb52
2 changed files with 19 additions and 3 deletions
|
@ -113,7 +113,7 @@ module Ebooks
|
|||
@mentions = mass_tikify(mention_text)
|
||||
|
||||
log "Ranking keywords"
|
||||
@keywords = NLP.keywords(text)
|
||||
@keywords = NLP.keywords(text).top(200).map(&:to_s)
|
||||
|
||||
self
|
||||
end
|
||||
|
|
|
@ -22,12 +22,28 @@ describe Ebooks::Model do
|
|||
end
|
||||
end
|
||||
|
||||
it "does not use a ridiculous amount of memory" do
|
||||
it "consumes, saves and loads models correctly" do
|
||||
model = nil
|
||||
|
||||
report = MemoryUsage.report do
|
||||
model = Ebooks::Model.consume(path("data/0xabad1dea.json"))
|
||||
end
|
||||
expect(report.total_memsize).to be < 200000000
|
||||
|
||||
expect(report.total_memsize).to be < 1000000000
|
||||
file = Tempfile.new("0xabad1dea")
|
||||
model.save(file.path)
|
||||
|
||||
report2 = MemoryUsage.report do
|
||||
model = Ebooks::Model.load(file.path)
|
||||
end
|
||||
expect(report2.total_memsize).to be < 3000000
|
||||
|
||||
expect(model.tokens[0]).to be_a String
|
||||
expect(model.sentences[0][0]).to be_a Fixnum
|
||||
expect(model.mentions[0][0]).to be_a Fixnum
|
||||
expect(model.keywords[0]).to be_a String
|
||||
|
||||
puts "0xabad1dea.model uses #{report2.total_memsize} bytes in memory"
|
||||
end
|
||||
|
||||
describe '.consume' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue