notebook/app/models/documents/document_analysis.rb
2019-07-12 12:05:46 -05:00

18 lines
527 B
Ruby

class DocumentAnalysis < ApplicationRecord
belongs_to :document
has_many :document_entities, dependent: :destroy
has_many :document_concepts, dependent: :destroy
has_many :document_categories, dependent: :destroy
serialize :words_per_sentence, Array
serialize :n_syllable_words, Hash
# usage: analysis.pos_percentage(:adjective) => 23.4
def pos_percentage(pos_symbol)
(send(pos_symbol.to_s + '_count').to_f / word_count * 100).round(2)
end
def complete?
self.completed_at.present?
end
end