opener-ned 3.0.0 → 3.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: a7555399cec5942f6c40e3153c895167a12b326a
4
- data.tar.gz: 8a35994ccb1d85171281b4114af842db52bf6099
3
+ metadata.gz: e0014a7b406f5acdc1a27604a7ba36d4f5a33534
4
+ data.tar.gz: 8c460b6b95deacea616d12be9dea6288db025b6e
5
5
  SHA512:
6
- metadata.gz: 42dd20c33ebc66b472ae3d343df1f0837c380e939bcf2dcd19d8b72b5fbf26c95d37edea792a9c348adbb6c4ddabedcae850ab39656545ec7b8e65cfea3751e5
7
- data.tar.gz: 651ee179eab6c0a6996f63623a8e0f57fa1cebf861dae08e45dc26c390dd338d980c79c6ab9cd9cd7699f567fec913fdbe5c1459190fb9017759f5d95a5dfbe9
6
+ metadata.gz: 348a303a62d45c87e08317585bdf55f8e3f27de0fd6a5f353894fc6c943e618fbadee44635d850d25e831d637a4648ad51306a948c75011d22690e1ffa78ee48
7
+ data.tar.gz: 5505776c3984193286e463bbbf57b69f83316528dae2fbb5caf92ff0d0ef80404bcdd308a60479e606ef779108d22660607538f89dfd1647d7bfc7ce5a965f2f
Binary file
@@ -3,6 +3,7 @@ require 'stringio'
3
3
 
4
4
  require 'slop'
5
5
  require 'nokogiri'
6
+ require 'opener/core'
6
7
 
7
8
  require File.expand_path('../../../core/target/ehu-ned-1.0.jar', __FILE__)
8
9
 
@@ -26,9 +27,9 @@ module Opener
26
27
  #
27
28
  LANGUAGE_ENDPOINTS = {
28
29
  "en" => "http://spotlight.sztaki.hu:2222",
29
- "nl" => "http://nl.dbpedia.org/spotlight",
30
+ "nl" => "http://spotlight.sztaki.hu:2232",
30
31
  "fr" => "http://spotlight.sztaki.hu:2225",
31
- "de" => "http://de.dbpedia.org/spotlight",
32
+ "de" => "http://spotlight.sztaki.hu:2226",
32
33
  "es" => "http://spotlight.sztaki.hu:2231",
33
34
  "it" => "http://spotlight.sztaki.hu:2230",
34
35
  "ru" => "http://spotlight.sztaki.hu:2227",
@@ -76,21 +77,36 @@ module Opener
76
77
  raise ArgumentError, 'No input specified'
77
78
  end
78
79
 
79
- language = language_from_kaf(input)
80
+ language = language_from_kaf(input)
81
+
82
+ unless LANGUAGE_ENDPOINTS[language]
83
+ raise Core::UnsupportedLanguageError, language
84
+ end
85
+
86
+ endpoint = uri_for_language(language)
80
87
  input_io = StringIO.new(input)
81
88
  reader = Java::java.io.InputStreamReader.new(input_io.to_inputstream)
82
89
  document = Java::ixa.kaflib.KAFDocument.create_from_stream(reader)
83
90
  annotator = new_annotator
84
- endpoint = options.fetch(:endpoint, uri_for_language(language))
85
91
 
86
- annotator.disambiguateNEsToKAF(
87
- document,
88
- endpoint.to_s
89
- )
92
+ annotator.disambiguateNEsToKAF(document, endpoint)
90
93
 
91
94
  return document.to_string
92
95
  end
93
96
 
97
+ ##
98
+ # Returns the language from the KAF document.
99
+ #
100
+ # @param [String] input The input KAF document.
101
+ # @return [String]
102
+ #
103
+ def language_from_kaf(input)
104
+ document = Nokogiri::XML(input)
105
+ language = document.xpath('KAF/@xml:lang')[0]
106
+
107
+ return language ? language.to_s : nil
108
+ end
109
+
94
110
  private
95
111
 
96
112
  ##
@@ -112,18 +128,6 @@ module Opener
112
128
  return annotator
113
129
  end
114
130
 
115
- ##
116
- # Returns the language from the KAF document.
117
- #
118
- # @param [String] input The input KAF document.
119
- # @return [String]
120
- #
121
- def language_from_kaf(input)
122
- document = Nokogiri::XML(input)
123
-
124
- return document.at('KAF').attr('xml:lang')
125
- end
126
-
127
131
  ##
128
132
  # Returns the endpoint URL for the given language.
129
133
  #
@@ -25,7 +25,7 @@ module Opener
25
25
  #
26
26
  def configure_slop
27
27
  return Slop.new(:strict => false, :indent => 2, :help => true) do
28
- banner 'Usage: ner [OPTIONS]'
28
+ banner 'Usage: ned [OPTIONS]'
29
29
 
30
30
  separator <<-EOF.chomp
31
31
 
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class Ned
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
  end # Ned
5
5
  end # Opener
@@ -25,11 +25,13 @@ Gem::Specification.new do |gem|
25
25
 
26
26
  gem.add_dependency 'opener-daemons', '~> 2.2'
27
27
  gem.add_dependency 'opener-webservice', '~> 2.1'
28
- gem.add_dependency 'opener-core', '~> 2.2'
28
+ gem.add_dependency 'opener-core', '~> 2.3'
29
29
 
30
30
  gem.add_dependency 'nokogiri'
31
31
  gem.add_dependency 'slop', '~> 3.5'
32
32
 
33
33
  gem.add_development_dependency 'rake'
34
34
  gem.add_development_dependency 'cliver'
35
+ gem.add_development_dependency 'cucumber'
36
+ gem.add_development_dependency 'rspec'
35
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-ned
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.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-daemons
@@ -44,12 +44,12 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '2.2'
47
+ version: '2.3'
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ~>
51
51
  - !ruby/object:Gem::Version
52
- version: '2.2'
52
+ version: '2.3'
53
53
  prerelease: false
54
54
  type: :runtime
55
55
  - !ruby/object:Gem::Dependency
@@ -108,6 +108,34 @@ dependencies:
108
108
  version: '0'
109
109
  prerelease: false
110
110
  type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: cucumber
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ prerelease: false
124
+ type: :development
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ prerelease: false
138
+ type: :development
111
139
  description: NED client using DBpedia
112
140
  email:
113
141
  executables: