opener-ned 2.4.1 → 3.0.0

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: b6c0f8c10e46991a6c5d92768a4336a7112fdb52
4
- data.tar.gz: 75f1f11a4d2f4e31e1bc479cf0e1a5b35535126c
3
+ metadata.gz: a7555399cec5942f6c40e3153c895167a12b326a
4
+ data.tar.gz: 8a35994ccb1d85171281b4114af842db52bf6099
5
5
  SHA512:
6
- metadata.gz: 1c1a3843a2b23bef511adc25d4eebd5ac2072d62678d9a4ce59e7297c791dad092cc31d630b35589059d5f88d4d3b050a217d9e8c92d4b0c4b9e60447f3becb2
7
- data.tar.gz: ca9bad5047147879798d6b237007d97918dc82a62eb2d5e6a1958ed2a8bf1b114cbbcb02f84d7ce51ffc0dc661d71aae01895bf9960023912a38f8c35b365913
6
+ metadata.gz: 42dd20c33ebc66b472ae3d343df1f0837c380e939bcf2dcd19d8b72b5fbf26c95d37edea792a9c348adbb6c4ddabedcae850ab39656545ec7b8e65cfea3751e5
7
+ data.tar.gz: 651ee179eab6c0a6996f63623a8e0f57fa1cebf861dae08e45dc26c390dd338d980c79c6ab9cd9cd7699f567fec913fdbe5c1459190fb9017759f5d95a5dfbe9
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2014 OpeNER Project Consortium
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md CHANGED
@@ -1,26 +1,30 @@
1
- Introduction
2
- ------------
1
+ # NED
3
2
 
4
- This repository contains a Named Entity Disambiguation tool that queries a DBpedia spotlight server. The client takes KAF as input (containing `<entities>` nodes).
3
+ This repository contains a Named Entity Disambiguation tool that queries a
4
+ DBpedia spotlight server. The client takes KAF as input (containing `<entities>`
5
+ nodes).
5
6
 
6
- ### Confused by some terminology?
7
+ ## Confused by some terminology?
7
8
 
8
- This software is part of a larger collection of natural language processing tools known as "the OpeNER project". You can find more information about the project at [the OpeNER portal](http://opener-project.github.io). There you can also find references to terms like KAF (an XML standard to represent linguistic annotations in texts), component, cores, scenario's and pipelines.
9
+ This software is part of a larger collection of natural language processing
10
+ tools known as "the OpeNER project". You can find more information about the
11
+ project at [the OpeNER portal](http://opener-project.github.io). There you can
12
+ also find references to terms like KAF (an XML standard to represent linguistic
13
+ annotations in texts), component, cores, scenario's and pipelines.
9
14
 
10
-
11
- Quick Use Example
12
- -----------------
15
+ ## Quick Use Example
13
16
 
14
17
  Installing the ned can be done by executing:
15
18
 
16
19
  gem install opener-ned
17
20
 
18
- Please bare in mind that all components in OpeNER take KAF as an input and output KAF by default.
19
-
21
+ Please keep in mind that all components in OpeNER take KAF as an input and
22
+ output KAF by default.
20
23
 
21
24
  ### Command line interface
22
25
 
23
- The NED client connects to the [DBPedia spotlight demo servers](http://dbpedia-spotlight.github.io/demo/).
26
+ The NED client connects to the [DBPedia spotlight demo
27
+ servers](http://dbpedia-spotlight.github.io/demo/).
24
28
 
25
29
  A simple example:
26
30
 
@@ -28,21 +32,19 @@ A simple example:
28
32
 
29
33
  An example output (excerpt) could look like this:
30
34
 
31
- ```xml
32
- <entity eid="e3" type="organization">
33
- <references>
34
- <!--North Yorkshire Police-->
35
- <span>
36
- <target id="t17" />
37
- <target id="t18" />
38
- <target id="t19" />
39
- </span>
40
- </references>
41
- <externalReferences>
42
- <externalRef resource="spotlight_v1" reference="http://dbpedia.org/resource/North_Yorkshire_Police" />
43
- </externalReferences>
44
- </entity>
45
- ```
35
+ <entity eid="e3" type="organization">
36
+ <references>
37
+ <!--North Yorkshire Police-->
38
+ <span>
39
+ <target id="t17" />
40
+ <target id="t18" />
41
+ <target id="t19" />
42
+ </span>
43
+ </references>
44
+ <externalReferences>
45
+ <externalRef resource="spotlight_v1" reference="http://dbpedia.org/resource/North_Yorkshire_Police" />
46
+ </externalReferences>
47
+ </entity>
46
48
 
47
49
  ### Webservices
48
50
 
@@ -50,28 +52,32 @@ You can launch a language identification webservice by executing:
50
52
 
51
53
  ned-server
52
54
 
53
- This will launch a mini webserver with the webservice. It defaults to port 9292, so you can access it at <http://localhost:9292>.
55
+ This will launch a mini webserver with the webservice. It defaults to port 9292,
56
+ so you can access it at <http://localhost:9292>.
54
57
 
55
- To launch it on a different port provide the `-p [port-number]` option like this:
58
+ To launch it on a different port provide the `-p [port-number]` option like
59
+ this:
56
60
 
57
61
  ned-server -p 1234
58
62
 
59
63
  It then launches at <http://localhost:1234>
60
64
 
61
- Documentation on the Webservice is provided by surfing to the urls provided above. For more information on how to launch a webservice run the command with the ```-h``` option.
62
-
65
+ Documentation on the Webservice is provided by surfing to the urls provided
66
+ above. For more information on how to launch a webservice run the command with
67
+ the `--help` option.
63
68
 
64
69
  ### Daemon
65
70
 
66
- Last but not least the NED comes shipped with a daemon that can read jobs (and write) jobs to and from Amazon SQS queues. For moreinformation type:
71
+ Last but not least the NED comes shipped with a daemon that can read jobs (and
72
+ write) jobs to and from Amazon SQS queues. For moreinformation type:
67
73
 
68
74
  ned-daemon -h
69
75
 
76
+ ## Description of dependencies
70
77
 
71
- Description of dependencies
72
- ---------------------------
73
-
74
- This component runs best if you run it in an environment suited for OpeNER components. You can find an installation guide and helper tools in the [OpeNER installer](ttps://github.com/opener-project/opener-installer) and an
78
+ This component runs best if you run it in an environment suited for OpeNER
79
+ components. You can find an installation guide and helper tools in the
80
+ [OpeNER installer](ttps://github.com/opener-project/opener-installer) and an
75
81
  [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
76
82
 
77
83
  At least you need the following system setup:
@@ -87,32 +93,28 @@ At least you need the following system setup:
87
93
 
88
94
  ### Structure
89
95
 
90
- This repository comes in two parts: a collection of Java source files and Ruby source files. The Java code can be found in the `core/` directory, everything else will be Ruby source code.
96
+ This repository comes in two parts: a collection of Java source files and Ruby
97
+ source files. The Java code can be found in the `core/` directory, everything
98
+ else will be Ruby source code.
91
99
 
92
- Language Extension
93
- ------------------
100
+ ## Language Extension
94
101
 
95
- TODO
102
+ TODO
96
103
 
97
- Where to go from here
98
- ---------------------
104
+ ## Where to go from here
99
105
 
100
106
  * [Check the project website](http://opener-project.github.io)
101
107
  * [Checkout the webservice](http://opener.olery.com/ned)
102
108
 
103
- Report problem/Get help
104
- -----------------------
105
-
106
- If you encounter problems, please email <support@opener-project.eu> or leave an issue in the
107
- [issue tracker](https://github.com/opener-project/ned/issue).
109
+ ## Report problem/Get help
108
110
 
111
+ If you encounter problems, please email <support@opener-project.eu> or leave an
112
+ issue in the [issue tracker](https://github.com/opener-project/ned/issue).
109
113
 
110
- Contributing
111
- ------------
114
+ ## Contributing
112
115
 
113
116
  1. Fork it <http://github.com/opener-project/ned/fork>
114
117
  2. Create your feature branch (`git checkout -b my-new-feature`)
115
118
  3. Commit your changes (`git commit -am 'Add some feature'`)
116
119
  4. Push to the branch (`git push origin my-new-feature`)
117
120
  5. Create new Pull Request
118
-
data/bin/ned CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  require_relative '../lib/opener/ned'
4
4
 
5
- cli = Opener::Ned::CLI.new(:args => ARGV)
5
+ cli = Opener::Ned::CLI.new
6
6
 
7
- cli.run(STDIN.tty? ? nil : STDIN.read)
7
+ cli.run
data/bin/ned-daemon CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'opener/daemons'
4
4
 
5
- exec_path = File.expand_path('../../exec/ned.rb', __FILE__)
5
+ controller = Opener::Daemons::Controller.new(
6
+ :name => 'opener-ned',
7
+ :exec_path => File.expand_path('../../exec/ned.rb', __FILE__)
8
+ )
6
9
 
7
- Opener::Daemons::Controller.new(
8
- :name => 'ned',
9
- :exec_path => exec_path
10
- )
10
+ controller.run
data/bin/ned-server CHANGED
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'puma/cli'
3
+ require 'opener/webservice'
4
4
 
5
- rack_config = File.expand_path('../../config.ru', __FILE__)
5
+ parser = Opener::Webservice::OptionParser.new(
6
+ 'opener-ned',
7
+ File.expand_path('../../config.ru', __FILE__)
8
+ )
6
9
 
7
- cli = Puma::CLI.new([rack_config] + ARGV)
8
- cli.run
10
+ parser.run
Binary file
data/exec/ned.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'opener/daemons'
4
+
4
5
  require_relative '../lib/opener/ned'
5
6
 
6
- options = Opener::Daemons::OptParser.parse!(ARGV)
7
- daemon = Opener::Daemons::Daemon.new(Opener::Ned, options)
7
+ daemon = Opener::Daemons::Daemon.new(Opener::Ned)
8
8
 
9
- daemon.start
9
+ daemon.start
@@ -1,79 +1,68 @@
1
1
  module Opener
2
2
  class Ned
3
3
  ##
4
- # CLI wrapper around {Opener::Ned} using OptionParser.
4
+ # CLI wrapper around {Opener::Ned} using Slop.
5
5
  #
6
- # @!attribute [r] options
7
- # @return [Hash]
8
- # @!attribute [r] option_parser
9
- # @return [OptionParser]
6
+ # @!attribute [r] parser
7
+ # @return [Slop]
10
8
  #
11
9
  class CLI
12
- attr_reader :options, :option_parser
10
+ attr_reader :parser
11
+
12
+ def initialize
13
+ @parser = configure_slop
14
+ end
13
15
 
14
16
  ##
15
- # @param [Hash] options
17
+ # @param [Array] argv
16
18
  #
17
- def initialize(options = {})
18
- @options = DEFAULT_OPTIONS.merge(options)
19
-
20
- @option_parser = OptionParser.new do |opts|
21
- opts.program_name = 'ned'
22
- opts.summary_indent = ' '
23
-
24
- opts.separator "\nOptions:\n\n"
25
-
26
- opts.on('-h', '--help', 'Shows this help message') do
27
- show_help
28
- end
29
-
30
- opts.on('-v', '--version', 'Shows the current version') do
31
- show_version
32
- end
19
+ def run(argv = ARGV)
20
+ parser.parse(argv)
21
+ end
33
22
 
34
- opts.on('-l', '--logging', 'Enables logging output') do
35
- @options[:logging] = true
36
- end
23
+ ##
24
+ # @return [Slop]
25
+ #
26
+ def configure_slop
27
+ return Slop.new(:strict => false, :indent => 2, :help => true) do
28
+ banner 'Usage: ner [OPTIONS]'
37
29
 
38
- opts.on('--no-time', 'Disables timestamps') do
39
- @options[:enable_time] = false
40
- end
30
+ separator <<-EOF.chomp
41
31
 
42
- opts.separator <<-EOF
32
+ About:
43
33
 
44
- Examples:
34
+ Named Entity Disambiguation for various languages using DBPedia.
35
+ This command reads input from STDIN.
45
36
 
46
- cat input_file.kaf | #{opts.program_name}
37
+ Example:
47
38
 
39
+ cat some_file.kaf | ned
48
40
  EOF
49
- end
50
- end
51
41
 
52
- ##
53
- # @param [String] input
54
- #
55
- def run(input)
56
- option_parser.parse!(options[:args])
42
+ separator "\nOptions:\n"
57
43
 
58
- ned = Ned.new(options)
44
+ on :v, :version, 'Shows the current version' do
45
+ abort "ned v#{VERSION} on #{RUBY_DESCRIPTION}"
46
+ end
59
47
 
60
- puts ned.run(input)
61
- end
48
+ on :l, :logging, 'Enables debug logging output',
49
+ :default => false
62
50
 
63
- private
51
+ on :'disable-time', 'Disables adding of dynamic timestamps',
52
+ :default => false
64
53
 
65
- ##
66
- # Shows the help message and exits the program.
67
- #
68
- def show_help
69
- abort option_parser.to_s
70
- end
54
+ run do |opts, args|
55
+ ned = Ned.new(
56
+ :args => args,
57
+ :logging => opts[:logging],
58
+ :enable_time => !opts[:'disable-time']
59
+ )
71
60
 
72
- ##
73
- # Shows the version and exits the program.
74
- #
75
- def show_version
76
- abort "#{option_parser.program_name} v#{VERSION} on #{RUBY_DESCRIPTION}"
61
+ input = STDIN.tty? ? nil : STDIN.read
62
+
63
+ puts ned.run(input)
64
+ end
65
+ end
77
66
  end
78
67
  end # CLI
79
68
  end # Ned
@@ -1,13 +1,12 @@
1
- require 'sinatra/base'
2
1
  require 'opener/webservice'
3
- require 'httpclient'
4
2
 
5
3
  module Opener
6
4
  class Ned
7
- class Server < Webservice
5
+ class Server < Webservice::Server
8
6
  set :views, File.expand_path('../views', __FILE__)
9
- text_processor Ned
10
- accepted_params :input, :host, :port
7
+
8
+ self.text_processor = Ned
9
+ self.accepted_params = [:input, :host, :port]
11
10
  end # Server
12
11
  end # Ned
13
12
  end # Opener
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class Ned
3
- VERSION = '2.4.1'
3
+ VERSION = '3.0.0'
4
4
  end # Ned
5
5
  end # Opener
data/lib/opener/ned.rb CHANGED
@@ -1,17 +1,14 @@
1
- require 'optparse'
2
1
  require 'java'
3
2
  require 'stringio'
3
+
4
+ require 'slop'
4
5
  require 'nokogiri'
5
- require 'opener/core'
6
6
 
7
7
  require File.expand_path('../../../core/target/ehu-ned-1.0.jar', __FILE__)
8
8
 
9
9
  require_relative 'ned/version'
10
10
  require_relative 'ned/cli'
11
11
 
12
- import 'java.io.InputStreamReader'
13
- import 'ixa.kaflib.KAFDocument'
14
-
15
12
  module Opener
16
13
  ##
17
14
  # Ruby wrapper around the Java based NED tool that's powered by DBpedia.
@@ -81,8 +78,8 @@ module Opener
81
78
 
82
79
  language = language_from_kaf(input)
83
80
  input_io = StringIO.new(input)
84
- reader = InputStreamReader.new(input_io.to_inputstream)
85
- document = KAFDocument.create_from_stream(reader)
81
+ reader = Java::java.io.InputStreamReader.new(input_io.to_inputstream)
82
+ document = Java::ixa.kaflib.KAFDocument.create_from_stream(reader)
86
83
  annotator = new_annotator
87
84
  endpoint = options.fetch(:endpoint, uri_for_language(language))
88
85
 
@@ -92,9 +89,6 @@ module Opener
92
89
  )
93
90
 
94
91
  return document.to_string
95
-
96
- rescue Exception => error
97
- return Opener::Core::ErrorLayer.new(input, error.message, self.class).add
98
92
  end
99
93
 
100
94
  private
data/opener-ned.gemspec CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.summary = 'NED client using DBpedia'
8
8
  gem.description = gem.summary
9
9
  gem.has_rdoc = 'yard'
10
+ gem.license = 'Apache 2.0'
10
11
 
11
12
  gem.required_ruby_version = '>= 1.9.2'
12
13
 
@@ -16,18 +17,18 @@ Gem::Specification.new do |gem|
16
17
  '*.gemspec',
17
18
  'config.ru',
18
19
  'README.md',
20
+ 'LICENSE.txt',
19
21
  'exec/**/*'
20
22
  ]).select { |file| File.file?(file) }
21
23
 
22
24
  gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
23
25
 
24
- gem.add_dependency 'sinatra', '~> 1.4'
25
- gem.add_dependency 'httpclient'
26
- gem.add_dependency 'opener-webservice'
26
+ gem.add_dependency 'opener-daemons', '~> 2.2'
27
+ gem.add_dependency 'opener-webservice', '~> 2.1'
28
+ gem.add_dependency 'opener-core', '~> 2.2'
29
+
27
30
  gem.add_dependency 'nokogiri'
28
- gem.add_dependency 'puma'
29
- gem.add_dependency 'opener-daemons'
30
- gem.add_dependency 'opener-core', '~> 1.0'
31
+ gem.add_dependency 'slop', '~> 3.5'
31
32
 
32
33
  gem.add_development_dependency 'rake'
33
34
  gem.add_development_dependency 'cliver'
metadata CHANGED
@@ -1,87 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-ned
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 3.0.0
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-06-25 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sinatra
14
+ name: opener-daemons
15
15
  version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.4'
19
+ version: '2.2'
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: '1.4'
25
- prerelease: false
26
- type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: httpclient
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- requirement: !ruby/object:Gem::Requirement
35
- requirements:
36
- - - '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
24
+ version: '2.2'
39
25
  prerelease: false
40
26
  type: :runtime
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: opener-webservice
43
29
  version_requirements: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- prerelease: false
54
- type: :runtime
55
- - !ruby/object:Gem::Dependency
56
- name: nokogiri
57
- version_requirements: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
31
+ - - ~>
60
32
  - !ruby/object:Gem::Version
61
- version: '0'
33
+ version: '2.1'
62
34
  requirement: !ruby/object:Gem::Requirement
63
35
  requirements:
64
- - - '>='
36
+ - - ~>
65
37
  - !ruby/object:Gem::Version
66
- version: '0'
38
+ version: '2.1'
67
39
  prerelease: false
68
40
  type: :runtime
69
41
  - !ruby/object:Gem::Dependency
70
- name: puma
42
+ name: opener-core
71
43
  version_requirements: !ruby/object:Gem::Requirement
72
44
  requirements:
73
- - - '>='
45
+ - - ~>
74
46
  - !ruby/object:Gem::Version
75
- version: '0'
47
+ version: '2.2'
76
48
  requirement: !ruby/object:Gem::Requirement
77
49
  requirements:
78
- - - '>='
50
+ - - ~>
79
51
  - !ruby/object:Gem::Version
80
- version: '0'
52
+ version: '2.2'
81
53
  prerelease: false
82
54
  type: :runtime
83
55
  - !ruby/object:Gem::Dependency
84
- name: opener-daemons
56
+ name: nokogiri
85
57
  version_requirements: !ruby/object:Gem::Requirement
86
58
  requirements:
87
59
  - - '>='
@@ -95,17 +67,17 @@ dependencies:
95
67
  prerelease: false
96
68
  type: :runtime
97
69
  - !ruby/object:Gem::Dependency
98
- name: opener-core
70
+ name: slop
99
71
  version_requirements: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - ~>
102
74
  - !ruby/object:Gem::Version
103
- version: '1.0'
75
+ version: '3.5'
104
76
  requirement: !ruby/object:Gem::Requirement
105
77
  requirements:
106
78
  - - ~>
107
79
  - !ruby/object:Gem::Version
108
- version: '1.0'
80
+ version: '3.5'
109
81
  prerelease: false
110
82
  type: :runtime
111
83
  - !ruby/object:Gem::Dependency
@@ -155,12 +127,14 @@ files:
155
127
  - opener-ned.gemspec
156
128
  - config.ru
157
129
  - README.md
130
+ - LICENSE.txt
158
131
  - exec/ned.rb
159
132
  - bin/ned-daemon
160
133
  - bin/ned-server
161
134
  - bin/ned
162
135
  homepage:
163
- licenses: []
136
+ licenses:
137
+ - Apache 2.0
164
138
  metadata: {}
165
139
  post_install_message:
166
140
  rdoc_options: []