Class: Opener::KafNafParser
- Inherits:
-
Object
- Object
- Opener::KafNafParser
- Defined in:
- lib/opener/kaf_naf_parser.rb,
lib/opener/kaf_naf_parser/cli.rb,
lib/opener/kaf_naf_parser/server.rb,
lib/opener/kaf_naf_parser/version.rb
Overview
Ruby wrapper around the Python based KafNafParser.
Defined Under Namespace
Constant Summary collapse
- DEFAULT_OPTIONS =
Hash containing the default options to use.
{ :args => [], :conversion => "to-kaf" }.freeze
- VERSION =
'1.1.0'
Instance Attribute Summary collapse
- #options ⇒ Hash readonly
Instance Method Summary collapse
-
#command ⇒ String
Returns a String containing the command to use for executing the kernel.
- #conversion ⇒ Object
-
#initialize(options = {}) ⇒ KafNafParser
constructor
A new instance of KafNafParser.
-
#run(input) ⇒ Array
Processes the input and returns an Array containing the output of STDOUT, STDERR and an object containing process information.
Constructor Details
#initialize(options = {}) ⇒ KafNafParser
Returns a new instance of KafNafParser.
33 34 35 |
# File 'lib/opener/kaf_naf_parser.rb', line 33 def initialize( = {}) @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#options ⇒ Hash (readonly)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/opener/kaf_naf_parser.rb', line 14 class KafNafParser attr_reader :options ## # Hash containing the default options to use. # # @return [Hash] # DEFAULT_OPTIONS = { :args => [], :conversion => "to-kaf" }.freeze ## # @param [Hash] options # # @option options [Array] :args Collection of arbitrary arguments to pass # to the underlying kernel. # def initialize( = {}) @options = DEFAULT_OPTIONS.merge() end ## # Returns a String containing the command to use for executing the kernel. # # @return [String] # def command return "python -E #{kernel} #{[:args].join(' ')} #{conversion}" end def conversion "--#{[:conversion].gsub(/-/,'')}" end ## # Processes the input and returns an Array containing the output of STDOUT, # STDERR and an object containing process information. # # @param [String] input The text of which to detect the language. # @return [Array] # def run(input) return Open3.capture3(command, :stdin_data => input) end protected ## # @return [String] # def core_dir return File.('../../../core', __FILE__) end ## # @return [String] # def kernel return File.join(core_dir, 'kaf-naf-parser.py') end end |
Instance Method Details
#command ⇒ String
Returns a String containing the command to use for executing the kernel.
42 43 44 |
# File 'lib/opener/kaf_naf_parser.rb', line 42 def command return "python -E #{kernel} #{[:args].join(' ')} #{conversion}" end |
#conversion ⇒ Object
46 47 48 |
# File 'lib/opener/kaf_naf_parser.rb', line 46 def conversion "--#{[:conversion].gsub(/-/,'')}" end |
#run(input) ⇒ Array
Processes the input and returns an Array containing the output of STDOUT, STDERR and an object containing process information.
57 58 59 |
# File 'lib/opener/kaf_naf_parser.rb', line 57 def run(input) return Open3.capture3(command, :stdin_data => input) end |