opener-opinion-detector-basic 3.2.2 → 3.2.3

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
  SHA256:
3
- metadata.gz: d90cb88e3b8224dc8d308e0c14aee257451869d6ae4c79db007b0247aaae6c2b
4
- data.tar.gz: 0546c8e56ce77a995e259cb1567be5b7444044944f6ee017a7497780f6ee98c5
3
+ metadata.gz: 37bab9088bfcdff7ddd21a5452bd9226edb14a0d11fb35b2f7bd8a183cd5b1af
4
+ data.tar.gz: 3605f40a5b4c1f22d343a308d6b7e4e28184bd8f0e7de000ca334842ccc3b4f7
5
5
  SHA512:
6
- metadata.gz: 8db793d069cec098dcc50d3732820bbf83756e2dfaff54975ff6b2ef47af116efe140416e40c92ac5a6e011d161c6f398388282e59ea60b50ec6c596520437e9
7
- data.tar.gz: 70dde9675a2b3038d9883e24f378abe597a6823ec5aa2e88d0806be5b71d20cc174c68fd0ef3da3a141931559a9c81be54ab2d1f100e3f9573d568042d2c0890
6
+ metadata.gz: ccc07cced6aee88b530fa52bfa7185855a840cced15f7008574e9493e85e9249c2af14c6b0645b0e991edfe876e51d69ef26a10ff9ab56ded4ffe59a47873cf4
7
+ data.tar.gz: 025e2637189339a502fefa73f4e6c44d1317e3199ea474a790d1a4421a0b50293adac691da913800f70a023c1ae190ba2473397021b0d45f7952d6470f33da09
@@ -1,7 +1,7 @@
1
1
  gem 'slop', '~> 3.0'
2
2
 
3
3
  require 'slop'
4
- require 'oga'
4
+ require 'nokogiri'
5
5
 
6
6
  require 'rexml/document'
7
7
  require 'rexml/formatters/pretty'
@@ -17,7 +17,7 @@ module Opener
17
17
  # by default due to the performance overhead.
18
18
  #
19
19
  def initialize(file, options = {})
20
- @document = Oga.parse_xml(file)
20
+ @document = Nokogiri.XML file
21
21
 
22
22
  @timestamp = options[:timestamp]
23
23
  @opinion_strength = options[:opinion_strength]
@@ -44,30 +44,16 @@ module Opener
44
44
  pretty ? pretty_print(document) : document.to_xml
45
45
  end
46
46
 
47
- ##
48
- # Get the language of the input file.
49
- #
50
- # @return [String]
51
- #
52
47
  def language
53
- @language ||= document.at_xpath('KAF').get('xml:lang')
48
+ @language ||= document.at_xpath('KAF').attr('xml:lang')
54
49
  end
55
50
 
56
- ##
57
- # Get the terms from the input file
58
- # @return [Hash]
59
- #
60
51
  def terms
61
52
  @terms ||= document.xpath('KAF/terms/term').map do |term|
62
53
  Term.new(term, document, language)
63
54
  end
64
55
  end
65
56
 
66
- ##
67
- # Get the opinions.
68
- #
69
- # @return [Hash]
70
- #
71
57
  def opinions
72
58
  unless @opinions
73
59
  set_accumulated_strength
@@ -117,7 +103,7 @@ module Opener
117
103
  #
118
104
  def add_opinion(opinion, index)
119
105
  opinion_node = new_node("opinion", "KAF/opinions")
120
- opinion_node.set('oid', "o#{index.to_s}")
106
+ opinion_node['oid'] = "o#{index.to_s}"
121
107
 
122
108
  unless opinion.holders.empty?
123
109
  opinion_holder_node = new_node("opinion_holder", opinion_node)
@@ -131,8 +117,8 @@ module Opener
131
117
  end
132
118
 
133
119
  expression_node = new_node("opinion_expression", opinion_node)
134
- expression_node.set('polarity', opinion.polarity)
135
- expression_node.set('strength', opinion.strength.to_s)
120
+ expression_node['polarity'] = opinion.polarity
121
+ expression_node['strength'] = opinion.strength.to_s
136
122
 
137
123
  add_opinion_element(expression_node, opinion.ids)
138
124
  end
@@ -141,14 +127,15 @@ module Opener
141
127
  # Method for adding opinion holders, targets and expressions.
142
128
  #
143
129
  def add_opinion_element(node, ids)
144
- lemmas = terms.select{|t| ids.include?(t.id)}.map(&:lemma).join(" ")
145
- comment = Oga::XML::Comment.new(:text => "#{lemmas}")
146
- node.children << comment
130
+ lemmas = terms.select{|t| ids.include?(t.id)}.map(&:lemma).join(" ")
131
+ comment = Nokogiri::XML::Comment.new(document, "#{lemmas}")
132
+ node.add_child comment
133
+
147
134
  span_node = new_node("span", node)
148
135
 
149
136
  ids.each do |id|
150
- target_node = new_node("target", span_node)
151
- target_node.set('id', id.to_s)
137
+ target_node = new_node("target", span_node)
138
+ target_node['id'] = id.to_s
152
139
  end
153
140
  end
154
141
 
@@ -162,19 +149,19 @@ module Opener
162
149
  version = '2.0'
163
150
 
164
151
  node = new_node('linguisticProcessors', 'KAF/kafHeader')
165
- node.set('layer', 'opinions')
152
+ node['layer'] = 'opinions'
166
153
 
167
154
  lp_node = new_node('lp', node)
168
155
 
169
- lp_node.set('version', "#{last_edited}-#{version}")
170
- lp_node.set('name', description)
156
+ lp_node['version'] = "#{last_edited}-#{version}"
157
+ lp_node['name'] = description
171
158
 
172
159
  if timestamp
173
160
  format = '%Y-%m-%dT%H:%M:%S%Z'
174
161
 
175
- lp_node.set('timestamp', Time.now.strftime(format))
162
+ lp_node['timestamp'] = Time.now.strftime(format)
176
163
  else
177
- lp_node.set('timestamp', '*')
164
+ lp_node['timestamp'] = '*'
178
165
  end
179
166
  end
180
167
 
@@ -307,9 +294,9 @@ module Opener
307
294
  parent_node = parent
308
295
  end
309
296
 
310
- node = Oga::XML::Element.new(:name => tag)
297
+ node = Nokogiri::XML::Element.new(tag, document)
311
298
 
312
- parent_node.children << node
299
+ parent_node.add_child node
313
300
 
314
301
  node
315
302
  end
@@ -321,6 +308,6 @@ module Opener
321
308
  def is_kaf?
322
309
  !!document.at_xpath('KAF')
323
310
  end
324
- end # Processor
325
- end # OpinionDetectorBasic
326
- end # Opener
311
+ end
312
+ end
313
+ end
@@ -29,7 +29,7 @@ module Opener
29
29
  # @return [String]
30
30
  #
31
31
  def id
32
- @id ||= node.get('tid')
32
+ @id ||= node.attr('tid')
33
33
  end
34
34
 
35
35
  ##
@@ -38,7 +38,7 @@ module Opener
38
38
  # @return [String]
39
39
  #
40
40
  def lemma
41
- @lemma ||= node.get('lemma')
41
+ @lemma ||= node.attr('lemma')
42
42
  end
43
43
 
44
44
  ##
@@ -47,7 +47,7 @@ module Opener
47
47
  # @return [String]
48
48
  #
49
49
  def pos
50
- @pos ||= node.get('pos')
50
+ @pos ||= node.attr('pos')
51
51
  end
52
52
 
53
53
  ##
@@ -57,7 +57,7 @@ module Opener
57
57
  #
58
58
  def sentiment_modifier
59
59
  @sentiment_modifier ||=
60
- first_sentiment ? first_sentiment.get('sentiment_modifier') : nil
60
+ first_sentiment ? first_sentiment.attr('sentiment_modifier') : nil
61
61
  end
62
62
 
63
63
  ##
@@ -66,7 +66,7 @@ module Opener
66
66
  # @return [String|NilClass]
67
67
  #
68
68
  def polarity
69
- @polarity ||= first_sentiment ? first_sentiment.get('polarity') : nil
69
+ @polarity ||= first_sentiment ? first_sentiment.attr('polarity') : nil
70
70
  end
71
71
 
72
72
  ##
@@ -76,7 +76,7 @@ module Opener
76
76
  #
77
77
  def target_ids
78
78
  @target_ids ||= node.xpath('span/target')
79
- .map { |target| target.get('id') }
79
+ .map { |target| target.attr('id') }
80
80
  end
81
81
 
82
82
  ##
@@ -109,7 +109,7 @@ module Opener
109
109
  document
110
110
  .xpath("KAF/text/wf[@wid='#{target_ids.first}']")
111
111
  .first
112
- .get('sent')
112
+ .attr('sent')
113
113
  end
114
114
 
115
115
  ##
@@ -1,7 +1,7 @@
1
1
  module Opener
2
2
  class OpinionDetectorBasic
3
3
 
4
- VERSION = '3.2.2'
4
+ VERSION = '3.2.3'
5
5
 
6
6
  end
7
7
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
27
27
  gem.add_dependency 'opener-webservice', '~> 2.1'
28
28
  gem.add_dependency 'opener-core', '~> 2.2'
29
29
 
30
- gem.add_dependency 'oga', ['~> 1.0', '>= 1.3.1']
30
+ gem.add_dependency 'nokogiri'
31
31
 
32
32
  gem.add_development_dependency 'rspec', '~> 3.0'
33
33
  gem.add_development_dependency 'cucumber'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-opinion-detector-basic
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.3
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: 2020-11-04 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opener-daemons
@@ -53,25 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.2'
55
55
  - !ruby/object:Gem::Dependency
56
- name: oga
56
+ name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.0'
62
59
  - - ">="
63
60
  - !ruby/object:Gem::Version
64
- version: 1.3.1
61
+ version: '0'
65
62
  type: :runtime
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
- - - "~>"
70
- - !ruby/object:Gem::Version
71
- version: '1.0'
72
66
  - - ">="
73
67
  - !ruby/object:Gem::Version
74
- version: 1.3.1
68
+ version: '0'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: rspec
77
71
  requirement: !ruby/object:Gem::Requirement