Class: Splitta::Model
- Inherits:
-
Object
- Object
- Splitta::Model
- Includes:
- Singleton
- Defined in:
- lib/splitta/model.rb
Constant Summary collapse
- LABELS =
[0, 1]
Instance Attribute Summary collapse
-
#feats ⇒ Object
readonly
Returns the value of attribute feats.
-
#lower_words ⇒ Object
readonly
Returns the value of attribute lower_words.
-
#non_abbrs ⇒ Object
readonly
Returns the value of attribute non_abbrs.
-
#prior_probs ⇒ Object
readonly
Returns the value of attribute prior_probs.
Instance Method Summary collapse
- #classify(doc) ⇒ Object
-
#initialize ⇒ Model
constructor
A new instance of Model.
- #inspect ⇒ Object
Constructor Details
#initialize ⇒ Model
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
#feats ⇒ Object (readonly)
Returns the value of attribute feats.
15 16 17 |
# File 'lib/splitta/model.rb', line 15 def feats @feats end |
#lower_words ⇒ Object (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_abbrs ⇒ Object (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_probs ⇒ Object (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 |
#inspect ⇒ Object
33 34 35 |
# File 'lib/splitta/model.rb', line 33 def inspect "#<Splitta::Model:#{object_id}>" end |