opener-ner 2.1.0 → 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: 822d5662b2e3e6fc8bdb4d9764374cf88494065c
4
- data.tar.gz: 850c3aa84b1e851f366ae0db587aecd694bc54b8
3
+ metadata.gz: 0e3d2681b8fd8feaa6a65dbcb5082eac3e517656
4
+ data.tar.gz: 03cedcd7d8f77c63fe4a9d70c24fb5e87187936e
5
5
  SHA512:
6
- metadata.gz: f1f33be981aff1cf9b431121f0493f55ba2d18e32ac742c1b47325dc465128f1484b4fd3d06d9bb7ffa8bf218f213fb04a5aadf172fc1b941fc82e130dbceca2
7
- data.tar.gz: 34961f4cda78f5d995b67eb33d3b0cce8da166993be279276cdba2b94080a0ca024f15889543f2f5aab10cb390f52c999bdc5d4a14f54eea69c55c27361b23ce
6
+ metadata.gz: 1e2e99e598633b21e17d6a0dd8a08707556406aa6599d24df80b9d1c4723ae909a9b67657c0be3fb46ddf8fe127fb6eada9c75f73fa974f07e5f61a30988a838
7
+ data.tar.gz: 7ff4845b61b7028fb38886a57ebbba60e7a5cf9cf3be16e5fdeabd3e76c52715052670c0b0d9c6ea3955828eaf5ddc34e2bc78af8c7a7f3b4f0618cfeaf6f1f2
data/README.md CHANGED
@@ -1,44 +1,50 @@
1
1
  # NER
2
2
 
3
- This repository contains the source code for the primary NER component of the OpeNER project. This component provides a CLI interface for the various kernels as well as providing a Sinatra based web service.
3
+ This repository contains the source code for the primary NER component of the
4
+ OpeNER project. This component provides a CLI interface for the various kernels
5
+ as well as providing a Sinatra based web service.
4
6
 
5
7
  ### Confused by some terminology?
6
8
 
7
- 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.
8
14
 
9
-
10
- Quick Use Example
11
- -----------------
15
+ ## Quick Use Example
12
16
 
13
17
  Installing the ner can be done by executing:
14
18
 
15
19
  gem install opener-ner
16
20
 
17
- Please bare in mind that all components in OpeNER take KAF as an input and output KAF by default.
21
+ Please keep in mind that all components in OpeNER take KAF as an input and
22
+ output KAF by default.
18
23
 
19
24
  ### Command line interface
20
25
 
21
- You should now be able to call the NER as a regular shell command: by its name. Once installed the gem normalyl sits in your path so you can call it directly from anywhere.
26
+ You should now be able to call the NER as a regular shell command: by its name.
27
+ Once installed the gem normalyl sits in your path so you can call it directly
28
+ from anywhere.
22
29
 
23
- This aplication reads a text from standard input in order to identify the language.
30
+ This aplication reads a text from standard input in order to identify the
31
+ language.
24
32
 
25
33
  cat some_kind_of_kaf_file.kaf | ner
26
34
 
35
+ This will output a kaf file containing the named entities. An excerpt can be
36
+ seen here
27
37
 
28
- This will output a kaf file containing the named entities. An excerpt can be seen here
29
-
30
- ```
31
- <entity eid="e3" type="organization">
32
- <references>
33
- <!--North Yorkshire Police-->
34
- <span>
35
- <target id="t17" />
36
- <target id="t18" />
37
- <target id="t19" />
38
- </span>
39
- </references>
40
- </entity>
41
- ```
38
+ <entity eid="e3" type="organization">
39
+ <references>
40
+ <!--North Yorkshire Police-->
41
+ <span>
42
+ <target id="t17" />
43
+ <target id="t18" />
44
+ <target id="t19" />
45
+ </span>
46
+ </references>
47
+ </entity>
42
48
 
43
49
  ### Webservices
44
50
 
@@ -46,28 +52,32 @@ You can launch a language identification webservice by executing:
46
52
 
47
53
  ner-server
48
54
 
49
- 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>.
50
57
 
51
- 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:
52
60
 
53
61
  ner-server -p 1234
54
62
 
55
63
  It then launches at <http://localhost:1234>
56
64
 
57
- 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.
58
-
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.
59
68
 
60
69
  ### Daemon
61
70
 
62
- Last but not least the NER comes shipped with a daemon that can read jobs (and write) jobs to and from Amazon SQS queues. For more information type:
71
+ Last but not least the NER comes shipped with a daemon that can read jobs (and
72
+ write) jobs to and from Amazon SQS queues. For more information type:
63
73
 
64
74
  ner-daemon -h
65
75
 
76
+ ## Description of dependencies
66
77
 
67
- Description of dependencies
68
- ---------------------------
69
-
70
- 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](https://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](https://github.com/opener-project/opener-installer) and an
71
81
  [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
72
82
 
73
83
  At least you need the following system setup:
@@ -81,43 +91,35 @@ At least you need the following system setup:
81
91
 
82
92
  * Maven (for building the Gem)
83
93
 
84
- Domain Adaption
85
- ---------------
94
+ ## Domain Adaption
86
95
 
87
- TODO
96
+ TODO
88
97
 
89
- Language Extension
90
- ------------------
98
+ ## Language Extension
91
99
 
92
- TODO
100
+ TODO
93
101
 
94
- The Core
95
- --------
102
+ ## The Core
96
103
 
97
- The component is a fat wrapper around the actual language technology core. You can find the core technolies in the following repositories:
104
+ The component is a wrapper around the actual language technology core. You can
105
+ find the core technolies in the following repositories:
98
106
 
99
107
  * [ner-base](https://github.com/opener-project/ner-base)
100
108
 
101
-
102
- Where to go from here
103
- ---------------------
109
+ ## Where to go from here
104
110
 
105
111
  * [Check the project website](http://opener-project.github.io)
106
112
  * [Checkout the webservice](http://opener.olery.com/ner)
107
113
 
108
- Report problem/Get help
109
- -----------------------
110
-
111
- If you encounter problems, please email <support@opener-project.eu> or leave an issue in the
112
- [issue tracker](https://github.com/opener-project/ner/issues).
114
+ ## Report problem/Get help
113
115
 
116
+ If you encounter problems, please email <support@opener-project.eu> or leave an
117
+ issue in the [issue tracker](https://github.com/opener-project/ner/issues).
114
118
 
115
- Contributing
116
- ------------
119
+ ## Contributing
117
120
 
118
121
  1. Fork it <http://github.com/opener-project/ner/fork>
119
122
  2. Create your feature branch (`git checkout -b my-new-feature`)
120
123
  3. Commit your changes (`git commit -am 'Add some feature'`)
121
124
  4. Push to the branch (`git push origin my-new-feature`)
122
125
  5. Create new Pull Request
123
-
data/bin/ner CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  require_relative '../lib/opener/ner'
4
4
 
5
- cli = Opener::Ner::CLI.new(:args => ARGV)
5
+ cli = Opener::Ner::CLI.new
6
6
 
7
- puts cli.run(STDIN.tty? ? nil : STDIN.read)
7
+ cli.run
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'opener/daemons'
4
4
 
5
- exec_path = File.expand_path('../../exec/ner.rb', __FILE__)
5
+ controller = Opener::Daemons::Controller.new(
6
+ :name => 'opener-ner',
7
+ :exec_path => File.expand_path('../../exec/ner.rb', __FILE__)
8
+ )
6
9
 
7
- Opener::Daemons::Controller.new(
8
- :name => 'ner',
9
- :exec_path => exec_path
10
- )
10
+ controller.run
@@ -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-ner',
7
+ File.expand_path('../../config.ru', __FILE__)
8
+ )
6
9
 
7
- cli = Puma::CLI.new([rack_config] + ARGV)
8
- cli.run
10
+ parser.run
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'opener/daemons'
4
+
4
5
  require_relative '../lib/opener/ner'
5
6
 
6
- options = Opener::Daemons::OptParser.parse!(ARGV)
7
- daemon = Opener::Daemons::Daemon.new(Opener::Ner, options)
7
+ daemon = Opener::Daemons::Daemon.new(Opener::Ner)
8
8
 
9
- daemon.start
9
+ daemon.start
@@ -1,7 +1,6 @@
1
- require 'optparse'
2
1
  require 'opener/ners/base'
3
2
  require 'nokogiri'
4
- require 'opener/core'
3
+ require 'slop'
5
4
 
6
5
  require_relative 'ner/version'
7
6
  require_relative 'ner/cli'
@@ -39,6 +38,7 @@ module Opener
39
38
  #
40
39
  # @option options [Array] :args Collection of arbitrary arguments to pass
41
40
  # to the underlying kernels.
41
+ #
42
42
  # @option options [String] :language The language to use.
43
43
  #
44
44
  def initialize(options = {})
@@ -53,20 +53,16 @@ module Opener
53
53
  # @return [Array]
54
54
  #
55
55
  def run(input)
56
- begin
57
- language = language_from_kaf(input) || DEFAULT_LANGUAGE
58
- args = options[:args].dup
59
-
60
- if language_constant_defined?(language)
61
- kernel = language_constant(language).new(options)
62
- else
63
- kernel = Ners::Base.new(options)
64
- end
56
+ language = language_from_kaf(input) || DEFAULT_LANGUAGE
57
+ args = options[:args].dup
65
58
 
66
- return kernel.run(input)
67
- rescue Exception => error
68
- return Opener::Core::ErrorLayer.new(input, error.message, self.class).add
59
+ if language_constant_defined?(language)
60
+ kernel = language_constant(language).new(options)
61
+ else
62
+ kernel = Ners::Base.new(options)
69
63
  end
64
+
65
+ return kernel.run(input)
70
66
  end
71
67
 
72
68
  protected
@@ -1,88 +1,64 @@
1
1
  module Opener
2
2
  class Ner
3
3
  ##
4
- # CLI wrapper around {Opener::Ner} using OptionParser.
4
+ # CLI wrapper around {Opener::Ner} 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 = 'ner'
22
- opts.summary_indent = ' '
23
-
24
- opts.on('-h', '--help', 'Shows this help message') do
25
- show_help
26
- end
27
-
28
- opts.on('-v', '--version', 'Shows the current version') do
29
- show_version
30
- end
31
-
32
- opts.on(
33
- '-l',
34
- '--language [VALUE]',
35
- 'Uses this specific language'
36
- ) do |value|
37
- @options[:language] = value
38
- end
19
+ def run(argv = ARGV)
20
+ parser.parse(argv)
21
+ end
39
22
 
40
- opts.separator <<-EOF
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]'
41
29
 
42
- Examples:
30
+ separator <<-EOF.chomp
43
31
 
44
- cat example.kaf | #{opts.program_name} -l en
32
+ About:
45
33
 
46
- Languages:
34
+ Named Entity Recognition for various languages such as English and Dutch.
35
+ This command reads input from STDIN.
47
36
 
48
- Ner will try to detect the language of the KAF file if no language is given.
37
+ Example:
49
38
 
50
- * Dutch (nl)
51
- * English (en)
52
- * French (fr)
53
- * German (de)
54
- * Italian (it)
55
- * Spanish (es)
39
+ cat some_file.kaf | ner
56
40
  EOF
57
- end
58
- end
59
41
 
60
- ##
61
- # @param [String] input
62
- #
63
- def run(input)
64
- option_parser.parse!(options[:args])
42
+ separator "\nOptions:\n"
65
43
 
66
- ner = Ner.new(options)
44
+ on :v, :version, 'Shows the current version' do
45
+ abort "ner v#{VERSION} on #{RUBY_DESCRIPTION}"
46
+ end
67
47
 
68
- return ner.run(input)
69
- end
48
+ on :l=, :language=, 'Sets a specific language to use', :as => String
70
49
 
71
- private
50
+ run do |opts, args|
51
+ parser = Ner.new(
52
+ :args => args,
53
+ :language => opts[:language]
54
+ )
72
55
 
73
- ##
74
- # Shows the help message and exits the program.
75
- #
76
- def show_help
77
- abort option_parser.to_s
78
- end
56
+ input = STDIN.tty? ? nil : STDIN.read
79
57
 
80
- ##
81
- # Shows the version and exits the program.
82
- #
83
- def show_version
84
- abort "#{option_parser.program_name} v#{VERSION} on #{RUBY_DESCRIPTION}"
58
+ puts parser.run(input)
59
+ end
60
+ end
85
61
  end
86
62
  end # CLI
87
- end # Ner
63
+ end # ConstituentParser
88
64
  end # Opener
@@ -1,16 +1,15 @@
1
- require 'sinatra/base'
2
1
  require 'opener/webservice'
3
- require 'httpclient'
4
2
 
5
3
  module Opener
6
4
  class Ner
7
5
  ##
8
6
  # NER server powered by Sinatra.
9
7
  #
10
- class Server < Webservice
8
+ class Server < Webservice::Server
11
9
  set :views, File.expand_path('../views', __FILE__)
12
- text_processor Ner
13
- accepted_params :input
10
+
11
+ self.text_processor = Ner
12
+ self.accepted_params = [:input]
14
13
  end # Server
15
14
  end # Ner
16
15
  end # Opener
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class Ner
3
- VERSION = '2.1.0'
3
+ VERSION = '3.0.0'
4
4
  end # NER
5
5
  end # Opener
@@ -22,14 +22,12 @@ Gem::Specification.new do |gem|
22
22
 
23
23
  gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
24
24
 
25
- gem.add_dependency 'sinatra', '~> 1.4'
26
- gem.add_dependency 'httpclient'
27
- gem.add_dependency 'nokogiri'
28
- gem.add_dependency 'puma'
29
- gem.add_dependency 'opener-daemons'
30
25
  gem.add_dependency 'opener-ner-base', ['~> 3.0']
31
- gem.add_dependency 'opener-webservice'
32
- gem.add_dependency 'opener-core', '~> 1.0'
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
+
30
+ gem.add_dependency 'nokogiri'
33
31
 
34
32
  gem.add_development_dependency 'rake'
35
33
  end
metadata CHANGED
@@ -1,101 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-ner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
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-30 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-ner-base
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: '3.0'
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'
39
- prerelease: false
40
- type: :runtime
41
- - !ruby/object:Gem::Dependency
42
- name: nokogiri
43
- version_requirements: !ruby/object:Gem::Requirement
44
- 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'
24
+ version: '3.0'
53
25
  prerelease: false
54
26
  type: :runtime
55
27
  - !ruby/object:Gem::Dependency
56
- name: puma
28
+ name: opener-daemons
57
29
  version_requirements: !ruby/object:Gem::Requirement
58
30
  requirements:
59
- - - '>='
31
+ - - ~>
60
32
  - !ruby/object:Gem::Version
61
- version: '0'
33
+ version: '2.2'
62
34
  requirement: !ruby/object:Gem::Requirement
63
35
  requirements:
64
- - - '>='
36
+ - - ~>
65
37
  - !ruby/object:Gem::Version
66
- version: '0'
38
+ version: '2.2'
67
39
  prerelease: false
68
40
  type: :runtime
69
41
  - !ruby/object:Gem::Dependency
70
- name: opener-daemons
42
+ name: opener-webservice
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.1'
76
48
  requirement: !ruby/object:Gem::Requirement
77
49
  requirements:
78
- - - '>='
50
+ - - ~>
79
51
  - !ruby/object:Gem::Version
80
- version: '0'
52
+ version: '2.1'
81
53
  prerelease: false
82
54
  type: :runtime
83
55
  - !ruby/object:Gem::Dependency
84
- name: opener-ner-base
56
+ name: opener-core
85
57
  version_requirements: !ruby/object:Gem::Requirement
86
58
  requirements:
87
59
  - - ~>
88
60
  - !ruby/object:Gem::Version
89
- version: '3.0'
61
+ version: '2.2'
90
62
  requirement: !ruby/object:Gem::Requirement
91
63
  requirements:
92
64
  - - ~>
93
65
  - !ruby/object:Gem::Version
94
- version: '3.0'
66
+ version: '2.2'
95
67
  prerelease: false
96
68
  type: :runtime
97
69
  - !ruby/object:Gem::Dependency
98
- name: opener-webservice
70
+ name: nokogiri
99
71
  version_requirements: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - '>='
@@ -108,20 +80,6 @@ dependencies:
108
80
  version: '0'
109
81
  prerelease: false
110
82
  type: :runtime
111
- - !ruby/object:Gem::Dependency
112
- name: opener-core
113
- version_requirements: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- version: '1.0'
118
- requirement: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - ~>
121
- - !ruby/object:Gem::Version
122
- version: '1.0'
123
- prerelease: false
124
- type: :runtime
125
83
  - !ruby/object:Gem::Dependency
126
84
  name: rake
127
85
  version_requirements: !ruby/object:Gem::Requirement