class Opener::PropertyTagger

Ruby wrapper around the Python based polarity tagger.

@!attribute [r] options

@return [Hash]

@!attribute [r] args

@return [Array]

Constants

VERSION

Attributes

args[R]
options[R]

Public Class Methods

new(options = {}) click to toggle source

@param [Hash] options

@option options [Array] :args Collection of arbitrary arguments to pass

to the underlying kernel.

@option options [TrueClass] :no_time Disables adding of timestamps.

# File lib/opener/property_tagger.rb, line 40
def initialize(options = {})
  @args    = options.delete(:args) || []
  @options = options
end

Public Instance Methods

path() click to toggle source

Get the resource path for the lexicon files, defaults to an ENV variable

@return [String]

# File lib/opener/property_tagger.rb, line 50
def path
  return @path if @path

  @path = options[:resource_path] || ENV['RESOURCE_PATH'] ||
    ENV['PROPERTY_TAGGER_LEXICONS_PATH']
  return unless @path

  @path = File.expand_path @path
end
remote_url() click to toggle source
# File lib/opener/property_tagger.rb, line 60
def remote_url
  @remote_url ||= ENV['PROPERTY_TAGGER_LEXICONS_URL']
end
run(input, params = {}) click to toggle source

Processes the input KAF document.

@param [String] input @return [String]

# File lib/opener/property_tagger.rb, line 70
def run input, params = {}
  timestamp = !options[:no_time]

  Processor.new(input,
    params:    params,
    url:       remote_url,
    path:      path,
    timestamp: timestamp,
    pretty:    options[:pretty],
  ).process
end