Class: VnTagger::Tagger
- Inherits:
-
Object
- Object
- VnTagger::Tagger
- Defined in:
- lib/vn_tagger/tagger.rb
Constant Summary collapse
- ROOT_PATH =
File.('../../..', __FILE__)
- COMMAND =
'java -jar vn.hus.nlp.tagger-4.2.0.jar'- INPUT =
File.join(ROOT_PATH, 'input.txt')
- OUTPUT =
File.join(ROOT_PATH, 'output.xml')
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text) ⇒ Tagger
constructor
A new instance of Tagger.
- #result ⇒ Object
- #tag ⇒ Object
- #xml_result ⇒ Object
Constructor Details
#initialize(text) ⇒ Tagger
Returns a new instance of Tagger.
11 12 13 |
# File 'lib/vn_tagger/tagger.rb', line 11 def initialize(text) @text = normalize(text) end |
Class Method Details
.tag(text) ⇒ Object
35 36 37 38 39 |
# File 'lib/vn_tagger/tagger.rb', line 35 def self.tag(text) tagger = new(text) tagger.tag tagger.result end |
Instance Method Details
#result ⇒ Object
31 32 33 |
# File 'lib/vn_tagger/tagger.rb', line 31 def result @result ||= Document.new(xml_result) end |
#tag ⇒ Object
15 16 17 18 |
# File 'lib/vn_tagger/tagger.rb', line 15 def tag write_to_file @success = system("cd #{ROOT_PATH}; #{COMMAND} -i #{INPUT} -o #{OUTPUT}") end |
#xml_result ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vn_tagger/tagger.rb', line 20 def xml_result @xml_result ||= if @success file = File.open(OUTPUT) xml_document = Nokogiri::XML(file) file.close xml_document else Nokogiri::XML('') end end |