Class: Splitta::Model

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/splitta/model.rb

Constant Summary collapse

LABELS =
[0, 1]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModel

Returns a new instance of Model.


17
18
19
20
21
22
23
24
25
# File 'lib/splitta/model.rb', line 17

def initialize
  @feats = model_read(:feats)
  @lower_words = model_read(:lower_words)
  @non_abbrs = model_read(:non_abbrs)

  @prior_probs = LABELS.each_with_object({}) do |label, h|
    h[label] = feats[[label, '<prior>']]**4
  end
end

Instance Attribute Details

#featsObject (readonly)

Returns the value of attribute feats


15
16
17
# File 'lib/splitta/model.rb', line 15

def feats
  @feats
end

#lower_wordsObject (readonly)

Returns the value of attribute lower_words


15
16
17
# File 'lib/splitta/model.rb', line 15

def lower_words
  @lower_words
end

#non_abbrsObject (readonly)

Returns the value of attribute non_abbrs


15
16
17
# File 'lib/splitta/model.rb', line 15

def non_abbrs
  @non_abbrs
end

#prior_probsObject (readonly)

Returns the value of attribute prior_probs


15
16
17
# File 'lib/splitta/model.rb', line 15

def prior_probs
  @prior_probs
end

Instance Method Details

#classify(doc) ⇒ Object


27
28
29
30
31
# File 'lib/splitta/model.rb', line 27

def classify(doc)
  doc.frags.each do |frag|
    frag.pred = classify_one(frag)
  end
end

#inspectObject


33
34
35
# File 'lib/splitta/model.rb', line 33

def inspect
  "#<Splitta::Model:#{object_id}>"
end