Class: Opener::PropertyTagger
- Inherits:
-
Object
- Object
- Opener::PropertyTagger
- Defined in:
- lib/opener/property_tagger.rb,
lib/opener/property_tagger/cli.rb,
lib/opener/property_tagger/server.rb,
lib/opener/property_tagger/version.rb,
lib/opener/property_tagger/processor.rb,
lib/opener/property_tagger/file_aspects_cache.rb,
lib/opener/property_tagger/remote_aspects_cache.rb
Overview
Ruby wrapper around the Python based polarity tagger.
Defined Under Namespace
Classes: CLI, FileAspectsCache, Processor, RemoteAspectsCache, Server
Constant Summary collapse
- VERSION =
'3.4.2'
Instance Attribute Summary collapse
- #args ⇒ Array readonly
- #options ⇒ Hash readonly
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PropertyTagger
constructor
A new instance of PropertyTagger.
-
#path ⇒ String
Get the resource path for the lexicon files, defaults to an ENV variable.
- #remote_url ⇒ Object
-
#run(input, params = {}) ⇒ String
Processes the input KAF document.
Constructor Details
#initialize(options = {}) ⇒ PropertyTagger
Returns a new instance of PropertyTagger.
40 41 42 43 |
# File 'lib/opener/property_tagger.rb', line 40 def initialize( = {}) @args = .delete(:args) || [] @options = end |
Instance Attribute Details
#args ⇒ Array (readonly)
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 77 78 79 80 81 82 |
# File 'lib/opener/property_tagger.rb', line 29 class PropertyTagger attr_reader :options, :args ## # @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. # def initialize( = {}) @args = .delete(:args) || [] @options = end ## # Get the resource path for the lexicon files, defaults to an ENV variable # # @return [String] # def path return @path if @path @path = [:resource_path] || ENV['RESOURCE_PATH'] || ENV['PROPERTY_TAGGER_LEXICONS_PATH'] return unless @path @path = File. @path end def remote_url @remote_url ||= ENV['PROPERTY_TAGGER_LEXICONS_URL'] end ## # Processes the input KAF document. # # @param [String] input # @return [String] # def run input, params = {} = ![:no_time] Processor.new(input, params: params, url: remote_url, path: path, timestamp: , pretty: [:pretty], ).process end end |
#options ⇒ Hash (readonly)
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 77 78 79 80 81 82 |
# File 'lib/opener/property_tagger.rb', line 29 class PropertyTagger attr_reader :options, :args ## # @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. # def initialize( = {}) @args = .delete(:args) || [] @options = end ## # Get the resource path for the lexicon files, defaults to an ENV variable # # @return [String] # def path return @path if @path @path = [:resource_path] || ENV['RESOURCE_PATH'] || ENV['PROPERTY_TAGGER_LEXICONS_PATH'] return unless @path @path = File. @path end def remote_url @remote_url ||= ENV['PROPERTY_TAGGER_LEXICONS_URL'] end ## # Processes the input KAF document. # # @param [String] input # @return [String] # def run input, params = {} = ![:no_time] Processor.new(input, params: params, url: remote_url, path: path, timestamp: , pretty: [:pretty], ).process end end |
Instance Method Details
#path ⇒ String
Get the resource path for the lexicon files, defaults to an ENV variable
50 51 52 53 54 55 56 57 58 |
# File 'lib/opener/property_tagger.rb', line 50 def path return @path if @path @path = [:resource_path] || ENV['RESOURCE_PATH'] || ENV['PROPERTY_TAGGER_LEXICONS_PATH'] return unless @path @path = File. @path end |
#remote_url ⇒ Object
60 61 62 |
# File 'lib/opener/property_tagger.rb', line 60 def remote_url @remote_url ||= ENV['PROPERTY_TAGGER_LEXICONS_URL'] end |
#run(input, params = {}) ⇒ String
Processes the input KAF document.
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/opener/property_tagger.rb', line 70 def run input, params = {} = ![:no_time] Processor.new(input, params: params, url: remote_url, path: path, timestamp: , pretty: [:pretty], ).process end |