opener-opinion-detector 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31c4caf46aa2fa93dd88d5138cbd495325783565
4
- data.tar.gz: 4e5d503fcc00e415d5bb0322a0adc0260d5b2cde
3
+ metadata.gz: 741deb8f509516cff44d47143287ea1d61573792
4
+ data.tar.gz: 7147f00cd7f11a48a709f2b1f62b388d25f78244
5
5
  SHA512:
6
- metadata.gz: d0ebc3136cec62b3178af44eacb6f49d7498a7806fa160fc802b4c496e5695728c1c3b19181e2972a48cf8f66fe5d49957fc1b96a8f9c38524ca22dfa54ffdf9
7
- data.tar.gz: 7edbf31a74dae022a6ca3e16eb6adb848bb00d5376fa9bf66d22ed8d144d6a19674ebbc00960e6d6144ca9cff7b0fde21b9393efbb80254e19fb84a209dcd02c
6
+ metadata.gz: ebe3bf2848a991733fa37ce2f63afe9146ca71edcaa2c24b3ae038de58ba62f84c3adca2e5d63d5860c59760085a332ced2b2f2c49855206580b93e0282efd26
7
+ data.tar.gz: c48954a106dd3dc149f9c549e07665f04cec27e167549d39e6b883b8f29dc6df5f0b5cb6ebb714ab1f7960172efb0066f81f8ecc02799520c79b04ee0bb21829
@@ -2,6 +2,7 @@ require 'open3'
2
2
 
3
3
  require 'nokogiri'
4
4
  require 'slop'
5
+ require 'opener/core'
5
6
  require 'opener/opinion_detectors/base'
6
7
 
7
8
  require_relative 'opinion_detector/version'
@@ -38,7 +39,7 @@ module Opener
38
39
  language = language_from_kaf(input)
39
40
 
40
41
  unless valid_language?(language)
41
- raise ArgumentError, "The specified language (#{language}) is invalid"
42
+ raise Core::UnsupportedLanguageError, language
42
43
  end
43
44
 
44
45
  kernel = language_constant(language).new(kernel_options)
@@ -46,7 +47,20 @@ module Opener
46
47
  return kernel.run(input)
47
48
  end
48
49
 
49
- protected
50
+ ##
51
+ # Extracts the language from a KAF document.
52
+ #
53
+ # @param [String] input
54
+ # @return [String]
55
+ #
56
+ def language_from_kaf(input)
57
+ document = Nokogiri::XML(input)
58
+ language = document.xpath('KAF/@xml:lang')[0]
59
+
60
+ return language ? language.to_s : nil
61
+ end
62
+
63
+ private
50
64
 
51
65
  ##
52
66
  # Returns the options to use for the kernel.
@@ -67,18 +81,6 @@ module Opener
67
81
  ENV['OPINION_DETECTOR_MODELS_PATH']
68
82
  end
69
83
 
70
- ##
71
- # Extracts the language from a KAF document.
72
- #
73
- # @param [String] input
74
- # @return [String]
75
- #
76
- def language_from_kaf(input)
77
- reader = Nokogiri::XML::Reader(input)
78
-
79
- return reader.read.lang
80
- end
81
-
82
84
  ##
83
85
  # @param [String] language
84
86
  # @return [Class]
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class OpinionDetector
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26
26
  gem.add_dependency 'opener-opinion-detector-base'
27
27
  gem.add_dependency 'opener-daemons', '~> 2.2'
28
28
  gem.add_dependency 'opener-webservice', '~> 2.1'
29
- gem.add_dependency 'opener-core', '~> 2.2'
29
+ gem.add_dependency 'opener-core', '~> 2.3'
30
30
 
31
31
  gem.add_dependency 'nokogiri'
32
32
  gem.add_dependency 'slop', '~> 3.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-opinion-detector
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - development@olery.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-25 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opener-opinion-detector-base
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.2'
61
+ version: '2.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.2'
68
+ version: '2.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement