Class: StyleScanner::Tagger
- Inherits:
-
Object
- Object
- StyleScanner::Tagger
- Defined in:
- lib/style_scanner/tagger.rb
Instance Attribute Summary collapse
-
#input_text ⇒ Object
readonly
Returns the value of attribute input_text.
Class Method Summary collapse
-
.parts_of_speech_tagger ⇒ Object
load once since there is a high initialization cost.
Instance Method Summary collapse
-
#initialize(input_text) ⇒ Tagger
constructor
A new instance of Tagger.
- #tagged_words ⇒ Object
Constructor Details
#initialize(input_text) ⇒ Tagger
Returns a new instance of Tagger.
6 7 8 |
# File 'lib/style_scanner/tagger.rb', line 6 def initialize(input_text) @input_text = input_text end |
Instance Attribute Details
#input_text ⇒ Object (readonly)
Returns the value of attribute input_text.
4 5 6 |
# File 'lib/style_scanner/tagger.rb', line 4 def input_text @input_text end |
Class Method Details
.parts_of_speech_tagger ⇒ Object
load once since there is a high initialization cost
19 20 21 |
# File 'lib/style_scanner/tagger.rb', line 19 def parts_of_speech_tagger @eng_tagger ||= EngTagger.new end |
Instance Method Details
#tagged_words ⇒ Object
10 11 12 13 14 15 |
# File 'lib/style_scanner/tagger.rb', line 10 def tagged_words @tagged_words ||= Tagger.parts_of_speech_tagger. (input_text). scan(/\<(?<tag>\w+)>(?<text>[^(<\)]+)</). map {|tag, word| TaggedWord.new(tag,word)} end |