Class: Opener::TreeTagger
- Inherits:
-
Object
- Object
- Opener::TreeTagger
- Defined in:
- lib/opener/tree_tagger.rb,
lib/opener/tree_tagger/cli.rb,
lib/opener/tree_tagger/server.rb,
lib/opener/tree_tagger/version.rb,
lib/opener/tree_tagger/error_layer.rb
Defined Under Namespace
Classes: CLI, ErrorLayer, Server
Constant Summary collapse
- DEFAULT_OPTIONS =
Hash containing the default options to use.
{ :args => [] }.freeze
- VERSION =
"3.0.3"
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #capture(input) ⇒ Object
- #command ⇒ Object
-
#initialize(options = {}) ⇒ TreeTagger
constructor
A new instance of TreeTagger.
- #run(input) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TreeTagger
Returns a new instance of TreeTagger.
28 29 30 31 |
# File 'lib/opener/tree_tagger.rb', line 28 def initialize( = {}) @args = .delete(:args) || [] = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
11 12 13 |
# File 'lib/opener/tree_tagger.rb', line 11 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/opener/tree_tagger.rb', line 11 def end |
Instance Method Details
#capture(input) ⇒ Object
43 44 45 |
# File 'lib/opener/tree_tagger.rb', line 43 def capture(input) Open3.capture3(*command.split(" "), :stdin_data=>input) end |
#command ⇒ Object
47 48 49 |
# File 'lib/opener/tree_tagger.rb', line 47 def command return "#{adjust_python_path} python -E -OO #{kernel} #{args.join(' ')}" end |
#run(input) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/opener/tree_tagger.rb', line 33 def run(input) begin stdout, stderr, process = capture(input) raise stderr unless process.success? return stdout rescue Exception => error return ErrorLayer.new(input, error., self.class).add end end |