Class: NlpToolz::PosTags
- Inherits:
-
Object
- Object
- NlpToolz::PosTags
- Defined in:
- lib/nlp_toolz/pos_tags.rb
Constant Summary collapse
- FileInputStream =
load java classes
Rjb::import('java.io.FileInputStream')
- POSModel =
Rjb::import('opennlp.tools.postag.POSModel')
- POSTaggerME =
Rjb::import('opennlp.tools.postag.POSTaggerME')
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#model ⇒ Object
Returns the value of attribute model.
-
#model_name ⇒ Object
Returns the value of attribute model_name.
-
#tokenized ⇒ Object
Returns the value of attribute tokenized.
Instance Method Summary collapse
- #get_pos_tags ⇒ Object
- #has_model? ⇒ Boolean
-
#initialize(input, lang = nil) ⇒ PosTags
constructor
A new instance of PosTags.
- #tags ⇒ Object
- #tokens ⇒ Object
Constructor Details
#initialize(input, lang = nil) ⇒ PosTags
Returns a new instance of PosTags.
20 21 22 23 24 25 |
# File 'lib/nlp_toolz/pos_tags.rb', line 20 def initialize(input, lang = nil) @input = input @lang = lang || NlpToolz::Language.get_language(input) @model_name = "#{@lang}-pos-maxent.bin" get_model end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
18 19 20 |
# File 'lib/nlp_toolz/pos_tags.rb', line 18 def input @input end |
#lang ⇒ Object
Returns the value of attribute lang.
18 19 20 |
# File 'lib/nlp_toolz/pos_tags.rb', line 18 def lang @lang end |
#model ⇒ Object
Returns the value of attribute model.
18 19 20 |
# File 'lib/nlp_toolz/pos_tags.rb', line 18 def model @model end |
#model_name ⇒ Object
Returns the value of attribute model_name.
18 19 20 |
# File 'lib/nlp_toolz/pos_tags.rb', line 18 def model_name @model_name end |
#tokenized ⇒ Object
Returns the value of attribute tokenized.
18 19 20 |
# File 'lib/nlp_toolz/pos_tags.rb', line 18 def tokenized @tokenized end |
Instance Method Details
#get_pos_tags ⇒ Object
27 28 29 30 31 |
# File 'lib/nlp_toolz/pos_tags.rb', line 27 def if self.has_model? @tokenized = tokenize_it @tagger.tag(@input.clean_up) end end |
#has_model? ⇒ Boolean
41 42 43 |
# File 'lib/nlp_toolz/pos_tags.rb', line 41 def has_model? @model end |
#tags ⇒ Object
37 38 39 |
# File 'lib/nlp_toolz/pos_tags.rb', line 37 def @tokenized[:tags] end |
#tokens ⇒ Object
33 34 35 |
# File 'lib/nlp_toolz/pos_tags.rb', line 33 def tokens @tokenized[:tokens] end |