indico 0.6.2 → 0.6.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
  SHA1:
3
- metadata.gz: d0d0293f757ec590af9dd4f4bc6d9159955af93d
4
- data.tar.gz: ff4f9b147a7084141f3cb69b3c00a15cd3a7da31
3
+ metadata.gz: cba55adc387286a8032d815e3934791cb6b1098b
4
+ data.tar.gz: f3b525cd00b9bab9d2221fb34067951137d805f2
5
5
  SHA512:
6
- metadata.gz: 774af344dacfcb8305c66153d4df7120b67afc6943959700d2d2066709725fc43bed20ae7750da6c1933fc7f857c81762f98acbf8c4463199df42a52f0baa904
7
- data.tar.gz: 028a5538564fc114955c780fc7d0112afe6a94af73687b05289d8912b074a5fe9c1746941a6d8d7c8fc4b724cc1ea4d9ac9188bb0a762adb5038ce4069d6b9cc
6
+ metadata.gz: 0e1e8df25001947843a37437a1278ec657c431196070f6e6f8ed715e083751711426e898d940066b190c336d4f09d976f0378a463aae309b6f5741f553cedf7d
7
+ data.tar.gz: 5db7693f4a85cd044586dbf43569063dc0050275742b58ebe58f21ea46f7e2e9eddebd25511e19812e495c3e57094abd04abbc6806cf21c59af450ca030fc301
@@ -14,7 +14,10 @@ TEXT_APIS = [
14
14
  "text_tags",
15
15
  "twitter_engagement",
16
16
  "keywords",
17
- "named_entities"
17
+ "named_entities",
18
+ "people",
19
+ "places",
20
+ "organizations"
18
21
  ]
19
22
  IMAGE_APIS = [
20
23
  "fer",
@@ -24,6 +27,10 @@ IMAGE_APIS = [
24
27
  "content_filtering"
25
28
  ]
26
29
 
30
+ MULTIAPI_NOT_SUPPORTED = [
31
+ "relevance",
32
+ "personas"
33
+ ]
27
34
  API_TYPES = {}
28
35
  TEXT_APIS.each do |api|
29
36
  API_TYPES[:api] = 'text'
@@ -1,3 +1,3 @@
1
1
  module Indico
2
- VERSION = '0.6.2'
2
+ VERSION = '0.6.3'
3
3
  end
data/lib/indico.rb CHANGED
@@ -68,6 +68,26 @@ module Indico
68
68
  api_handler(test_text, 'namedentities', config)
69
69
  end
70
70
 
71
+ def self.relevance(text, queries, config = nil)
72
+ if config.nil?
73
+ config = Hash.new()
74
+ end
75
+ config[:queries] = queries
76
+ return api_handler(text, 'relevance', config)
77
+ end
78
+
79
+ def self.people(text, config = nil)
80
+ api_handler(text, "people", config)
81
+ end
82
+
83
+ def self.organizations(text, config = nil)
84
+ api_handler(text, "organizations", config)
85
+ end
86
+
87
+ def self.places(text, config = nil)
88
+ api_handler(text, "places", config)
89
+ end
90
+
71
91
  def self.fer(image, config = nil)
72
92
  size = (config != nil and config["detect"] == true) ? false : 48
73
93
  api_handler(preprocess(image, size, false), 'fer', config)
@@ -42,6 +42,41 @@ describe Indico do
42
42
  end
43
43
  end
44
44
 
45
+ it 'should return the relevance between a set of documents and a set of query strings' do
46
+ text = ['If patience is a necessary quality for a Jedi, fans who have gathered in front of a Hollywood theater in anticipation of Thursday\'s midnight screening of "The Force Awakens" are surely experts in the ways of the Force.']
47
+ query = ['star wars', 'jedi']
48
+ result = Indico.relevance(text, query)
49
+ expect result[0][0] >= 0.5
50
+ expect result[0][0] >= 0.5
51
+ end
52
+
53
+ it 'should return people found in the text provided' do
54
+ text = ["Chef Michael Solomonov's gorgeous cookbook \"Zahav\" is taking up too much space on my dining room table, but his family stories, recipes and photography keep me from shelving it."]
55
+ text += text
56
+ result = Indico.people(text)
57
+ result[0] = result[0].sort_by { |k| -k["confidence"] }
58
+ expect result[0][0]["text"].include? "Michael Solomonov"
59
+ expect result.length == 2
60
+ end
61
+
62
+ it 'should return organizations found in the text provided' do
63
+ text = ["Chinese internet giant Alibaba is to buy Hong Kong-based newspaper the South China Morning Post (SCMP)."]
64
+ text += text
65
+ result = Indico.organizations(text)
66
+ result[0] = result[0].sort_by { |k| -k["confidence"] }
67
+ expect result[0][0]["text"].include? "Alibaba"
68
+ expect result.length == 2
69
+ end
70
+
71
+ it 'should return places found in the text provided' do
72
+ text = ["Alibaba to buy Hong Kong's South China Morning Post"]
73
+ text += text
74
+ result = Indico.places(text)
75
+ result[0] = result[0].sort_by { |k| -k["confidence"] }
76
+ expect result[0][0]["text"].include? "China"
77
+ expect result.length == 2
78
+ end
79
+
45
80
  it 'should access a private cloud' do
46
81
  expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
47
82
  data = ['Guns don\'t kill people.', ' People kill people.']
data/spec/indico_spec.rb CHANGED
@@ -135,6 +135,7 @@ describe Indico do
135
135
 
136
136
  expect Set.new(response.keys).subset?(Set.new(text.gsub(/\s+/m, ' ').strip.split(" ")))
137
137
  end
138
+
138
139
  it 'should tag text with correct keywords for specified language' do
139
140
  text = "La semaine suivante, il remporte sa premiere victoire, dans la descente de Val Gardena en Italie, près de cinq ans après la dernière victoire en Coupe du monde d'un Français dans cette discipline, avec le succès de Nicolas Burtin à Kvitfjell."
140
141
  config = { "language" => "French" }
@@ -143,6 +144,31 @@ describe Indico do
143
144
  expect Set.new(response.keys).subset?(Set.new(text.gsub(/\s+/m, ' ').strip.split(" ")))
144
145
  end
145
146
 
147
+ it 'should return the relevance between a set of documents and a set of query strings' do
148
+ text = 'If patience is a necessary quality for a Jedi, fans who have gathered in front of a Hollywood theater in anticipation of Thursday\'s midnight screening of "The Force Awakens" are surely experts in the ways of the Force.'
149
+ query = 'star wars'
150
+ result = Indico.relevance(text, query)
151
+ expect result[0] >= 0.5
152
+ end
153
+
154
+ it 'should return people found in the text provided' do
155
+ text = "Chef Michael Solomonov's gorgeous cookbook \"Zahav\" is taking up too much space on my dining room table, but his family stories, recipes and photography keep me from shelving it."
156
+ result = Indico.people(text).sort_by { |k| -k["confidence"] }
157
+ expect result[0]["text"].include? "Michael Solomonov"
158
+ end
159
+
160
+ it 'should return organizations found in the text provided' do
161
+ text = "Chinese internet giant Alibaba is to buy Hong Kong-based newspaper the South China Morning Post (SCMP)."
162
+ result = Indico.organizations(text).sort_by { |k| -k["confidence"] }
163
+ expect result[0]["text"].include? "Alibaba"
164
+ end
165
+
166
+ it 'should return places found in the text provided' do
167
+ text = "Alibaba to buy Hong Kong's South China Morning Post"
168
+ result = Indico.places(text).sort_by { |k| -k["confidence"] }
169
+ expect result[0]["text"].include? "China"
170
+ end
171
+
146
172
  it 'should return all named entities with category breakdowns' do
147
173
  expected_keys = Set.new(%w(unknown organization location person))
148
174
  response = Indico.named_entities('I want to move to New York City!')
@@ -233,16 +259,16 @@ describe Indico do
233
259
  end
234
260
 
235
261
  it "should respond with all text apis called" do
236
- expected_keys = Set.new(TEXT_APIS)
237
- response = Indico.analyze_text("Worst movie ever.", TEXT_APIS)
262
+ expected_keys = Set.new(TEXT_APIS) - Set.new(MULTIAPI_NOT_SUPPORTED)
263
+ response = Indico.analyze_text("Worst movie ever.")
238
264
 
239
265
  expect(response.class).to eql(Hash)
240
266
  expect(Set.new(response.keys)).to eql(expected_keys)
241
267
  end
242
268
 
243
269
  it "should respond with all text apis called by default" do
244
- expected_keys = Set.new(TEXT_APIS)
245
- response = Indico.analyze_text("Worst movie ever.", TEXT_APIS)
270
+ expected_keys = Set.new(TEXT_APIS) - Set.new(MULTIAPI_NOT_SUPPORTED)
271
+ response = Indico.analyze_text("Worst movie ever.")
246
272
 
247
273
  expect(response.class).to eql(Hash)
248
274
  expect(Set.new(response.keys)).to eql(expected_keys)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indico
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Slater Victoroff
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-07 00:00:00.000000000 Z
14
+ date: 2015-12-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: inifile