Class: Opener::Coreference

Inherits:
Object
  • Object
show all
Defined in:
lib/opener/coreference.rb,
lib/opener/coreference/cli.rb,
lib/opener/coreference/server.rb,
lib/opener/coreference/version.rb

Defined Under Namespace

Classes: CLI, Server

Constant Summary collapse

DEFAULT_OPTIONS =

Hash containing the default options to use.

Returns:

  • (Hash)
{
  :args     => [],
}.freeze
VERSION =
"1.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Coreference

Returns a new instance of Coreference.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :args (Array)

    Collection of arbitrary arguments to pass to the underlying kernels.

  • :language (String)

    The language to use.



28
29
30
# File 'lib/opener/coreference.rb', line 28

def initialize(options = {})
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/opener/coreference.rb', line 10

def options
  @options
end

Instance Method Details

#run(input) ⇒ Array

Processes the input and returns an array containing the output of STDOUT, STDERR and an object containing process information.

Parameters:

  • input (String)

Returns:

  • (Array)


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/opener/coreference.rb', line 39

def run(input)
  language = language_from_kaf(input)
  args = options[:args].dup

  if language_constant_defined?(language)
    kernel = language.new(:args => args)
  else
    kernel = Coreferences::Base.new(:args => args, :language => language)
  end

  return kernel.run(input)
end