Class: Opener::POSTaggers::FR

Inherits:
Object
  • Object
show all
Defined in:
lib/opener/pos_taggers/fr.rb,
lib/opener/pos_taggers/fr/version.rb

Overview

The POS tagger that supports French.

Constant Summary collapse

VERSION =
"1.0.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FR

Returns a new instance of FR.

Parameters:

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

Options Hash (options):

  • :args (Array)

    The commandline arguments to pass to the underlying Python script.



23
24
25
26
# File 'lib/opener/pos_taggers/fr.rb', line 23

def initialize(options = {})
  @args          = options.delete(:args) || []
  @options       = options
end

Instance Attribute Details

#argsArray (readonly)

Returns:

  • (Array)


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
# File 'lib/opener/pos_taggers/fr.rb', line 14

class FR
  attr_reader :args, :options

  ##
  # @param [Hash] options
  #
  # @option options [Array] :args The commandline arguments to pass to the
  #  underlying Python script.
  #
  def initialize(options = {})
    @args          = options.delete(:args) || []
    @options       = options
  end

  ##
  # Builds the command used to execute the kernel.
  #
  # @return [String]
  #
  def command
    "java -jar #{kernel} -l #{lang} #{args.join(' ')}"
  end

  ##
  # Runs the command and returns the output of STDOUT, STDERR and the
  # process information.
  #
  # @param [String] input The input to tag.
  # @return [Array]
  #
  def run(input)
    return Open3.capture3(command, :stdin_data => input)
  end

  protected

  ##
  # @return [String]
  #
  def core_dir
    File.expand_path("../../../core", File.dirname(__FILE__))
  end  

  ##
  # @return [String]
  #
  def kernel
    core_dir+'/target/Vicom-postagger_FR-0.9.jar'
  end 
  
  def lang
    'fr'
  end
  
end

#optionsHash (readonly)

Returns:

  • (Hash)


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
# File 'lib/opener/pos_taggers/fr.rb', line 14

class FR
  attr_reader :args, :options

  ##
  # @param [Hash] options
  #
  # @option options [Array] :args The commandline arguments to pass to the
  #  underlying Python script.
  #
  def initialize(options = {})
    @args          = options.delete(:args) || []
    @options       = options
  end

  ##
  # Builds the command used to execute the kernel.
  #
  # @return [String]
  #
  def command
    "java -jar #{kernel} -l #{lang} #{args.join(' ')}"
  end

  ##
  # Runs the command and returns the output of STDOUT, STDERR and the
  # process information.
  #
  # @param [String] input The input to tag.
  # @return [Array]
  #
  def run(input)
    return Open3.capture3(command, :stdin_data => input)
  end

  protected

  ##
  # @return [String]
  #
  def core_dir
    File.expand_path("../../../core", File.dirname(__FILE__))
  end  

  ##
  # @return [String]
  #
  def kernel
    core_dir+'/target/Vicom-postagger_FR-0.9.jar'
  end 
  
  def lang
    'fr'
  end
  
end

Instance Method Details

#commandString

Builds the command used to execute the kernel.

Returns:

  • (String)


33
34
35
# File 'lib/opener/pos_taggers/fr.rb', line 33

def command
  "java -jar #{kernel} -l #{lang} #{args.join(' ')}"
end

#run(input) ⇒ Array

Runs the command and returns the output of STDOUT, STDERR and the process information.

Parameters:

  • input (String)

    The input to tag.

Returns:

  • (Array)


44
45
46
# File 'lib/opener/pos_taggers/fr.rb', line 44

def run(input)
  return Open3.capture3(command, :stdin_data => input)
end