class JnbClassifier::Document

associate label to the frequency of words in the document

Attributes

attributes[R]
label[R]

Public Class Methods

new(label,doc) click to toggle source
# File lib/jnb_classifier.rb, line 64
def initialize(label,doc)
  @label = label                               # String
  @attributes = create_attributes(doc)         # Hsah
end

Public Instance Methods

create_attributes(doc) click to toggle source
# File lib/jnb_classifier.rb, line 69
def create_attributes(doc)
  attributes = Hash.new(0)
  nm = Natto::MeCab.new
  nm.parse(doc) do |n|
    attributes[n.surface] += 1 if n.feature.match(/名詞/)
  end
  attributes
end