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
Defined Under Namespace
Constant Summary collapse
- DEFAULT_OPTIONS =
Hash containing the default options to use.
{ :args => [] }.freeze
- VERSION =
'4.0.0'
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.
27 28 29 30 |
# File 'lib/opener/tree_tagger.rb', line 27 def initialize( = {}) @args = .delete(:args) || [] @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/opener/tree_tagger.rb', line 10 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/opener/tree_tagger.rb', line 10 def @options end |
Instance Method Details
#capture(input) ⇒ Object
40 41 42 |
# File 'lib/opener/tree_tagger.rb', line 40 def capture(input) Open3.capture3(*command.split(" "), :stdin_data=>input) end |
#command ⇒ Object
44 45 46 |
# File 'lib/opener/tree_tagger.rb', line 44 def command return "python -E #{kernel} #{args.join(' ')}" end |
#run(input) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/opener/tree_tagger.rb', line 32 def run(input) stdout, stderr, process = capture(input) raise stderr unless process.success? return stdout end |