jakal 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,12 @@ Feature: Calais-Specific features
17
17
  Then I should get a response
18
18
  And I should receive some tags
19
19
 
20
+ @connection_needed
21
+ Scenario: Get nested tags from calais
22
+ Given I have some simple text
23
+ When I request the nested entities from calais
24
+ Then I should get a decent response
25
+
20
26
  Scenario: Clean up blank items from a calais response
21
27
  Given I have a mock calais response
22
28
  When I remove the unwanted items
@@ -35,4 +41,3 @@ Feature: Calais-Specific features
35
41
  Scenario: Go through the calais response tags as a single array
36
42
  Given I have a mock calais response
37
43
  Then I should be able to see the whole lot of tags as one block
38
-
@@ -42,3 +42,11 @@ Then /^I should be able to see the whole lot of tags as one block$/ do
42
42
  tags.length.should > 0
43
43
  end
44
44
 
45
+ When /^I request the nested entities from calais$/ do
46
+ key = YAML::load_file('config/keys.yml')['calais']
47
+ @response = Jkl::get_calais_metadata key, @text
48
+ end
49
+
50
+ Then /^I should get a decent response$/ do
51
+ @response.eql?({"Person"=>["Barack Obama", "Hillary Clinton"], "Position"=>["Secretary of State"]}).should == true
52
+ end
@@ -29,10 +29,11 @@ module Jkl
29
29
  cleaned_result
30
30
  end
31
31
 
32
- def self.get_calais_metadata(response)
33
- #ce = CalaisExtractor.new( response )
34
- #ce.prettify
35
- #TODO work out how to implement this
32
+ def self.get_calais_metadata(key, text)
33
+ name_value_pairs = Jkl::tags(key, text).entities.map{|e| {e.type => [e.attributes["name"]]}}
34
+ nested_list = {}
35
+ name_value_pairs.each { |a| nested_list = nested_list.merge!(a){ |key,v1,v2| v1+v2 }}
36
+ nested_list
36
37
  end
37
38
 
38
39
  #jkl doesn't work with these aspects of the calais response, also removing blanks
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jakal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - sshingler