Class: VnTagger::Document
- Inherits:
-
Object
- Object
- VnTagger::Document
- Defined in:
- lib/vn_tagger/document.rb
Instance Attribute Summary collapse
-
#xml_document ⇒ Object
readonly
Returns the value of attribute xml_document.
Instance Method Summary collapse
- #filter_by_tag(tag = 'Proper noun') ⇒ Object
-
#initialize(xml_document) ⇒ Document
constructor
A new instance of Document.
- #proper_noun_words ⇒ Object
- #uncached_words ⇒ Object
- #words ⇒ Object
Constructor Details
#initialize(xml_document) ⇒ Document
Returns a new instance of Document.
7 8 9 |
# File 'lib/vn_tagger/document.rb', line 7 def initialize(xml_document) @xml_document = xml_document end |
Instance Attribute Details
#xml_document ⇒ Object (readonly)
Returns the value of attribute xml_document.
5 6 7 |
# File 'lib/vn_tagger/document.rb', line 5 def xml_document @xml_document end |
Instance Method Details
#filter_by_tag(tag = 'Proper noun') ⇒ Object
21 22 23 |
# File 'lib/vn_tagger/document.rb', line 21 def filter_by_tag(tag = 'Proper noun') words.select { |word| word.is_tag?(tag) } end |
#proper_noun_words ⇒ Object
25 26 27 |
# File 'lib/vn_tagger/document.rb', line 25 def proper_noun_words filter_by_tag('Proper noun').map(&:text) end |
#uncached_words ⇒ Object
15 16 17 18 19 |
# File 'lib/vn_tagger/document.rb', line 15 def uncached_words xml_document.xpath('//w').map do |element| Word.new(element.attr('pos'), element.text) end end |
#words ⇒ Object
11 12 13 |
# File 'lib/vn_tagger/document.rb', line 11 def words @words ||= uncached_words end |