Class: JnbClassifier::Document
- Inherits:
-
Object
- Object
- JnbClassifier::Document
- Defined in:
- lib/jnb_classifier.rb
Overview
associate label to the frequency of words in the document
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #create_attributes(doc) ⇒ Object
-
#initialize(label, doc) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(label, doc) ⇒ Document
Returns a new instance of Document.
64 65 66 67 |
# File 'lib/jnb_classifier.rb', line 64 def initialize(label,doc) @label = label # String @attributes = create_attributes(doc) # Hsah end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
62 63 64 |
# File 'lib/jnb_classifier.rb', line 62 def attributes @attributes end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
61 62 63 |
# File 'lib/jnb_classifier.rb', line 61 def label @label end |
Instance Method Details
#create_attributes(doc) ⇒ Object
69 70 71 72 73 74 75 76 |
# 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 |