opener-kaf2json 1.1.1-java → 2.0.0-java

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: 586646679121ccd4d2180500b7638a6a8f1e0d0d
4
- data.tar.gz: 024f2d20e458dfc884152014fc42ed1f3b4ff9be
3
+ metadata.gz: 6189b9563f53756f473c46ab38e63fb5e6f4eb7c
4
+ data.tar.gz: 0676e9747e6ae3f01e06bbf852d958e6cd09edfd
5
5
  SHA512:
6
- metadata.gz: 28a9e7055ad249a64e9596cce02263c2714d0008c5f38f5383cb11ea1f405f2076338a203ea8e86d39f75f92eca61bc8cae7acf5f56132e4cc8008dd075f698e
7
- data.tar.gz: 5d46f27fc2d8451d4a3e3171b91af971a7aa26744a5d187e4240f94c4bb34437cea0a43153865e87f1794fca48698ab5bce76874c51e0b3c2a8957c589314c24
6
+ metadata.gz: 828e9063625de95d67442e1279689130280700be184387bc6afe59746816cb4b79cfeaff7f542770184c15bbb901642e2d26066487707ad08cfee68f89bbbfa6
7
+ data.tar.gz: 42661053b7e7cecbd8039c0b98cdde65b2dc02dfa64b14ebf555ae87108a58fac08d3d874c4d5add7cc3834a2395fda0bb2f38fcbe68a69473eb770e1e086825
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,43 +1,52 @@
1
- kaf2json
2
- ------------
1
+ # KAF to JSON
3
2
 
4
- Even if KAF is the true OpeNER data representation format, it is not very friendly for humans. It is also difficult to parse and work with it, specially for new users that are not familiarized with KAF. This is part of the feedback we got from the OpeNER hackathon held in Amsterdam during first days of July. To ease the post-processing of the results by any potential user, we are designing an alternative JSON format to output translate KAF, and turn its complexity into a much more usable format. Although, the specification for this JSON is currently work in progress, we have already a version that covers the most relevant parts from the KAF representation.
3
+ Even if KAF is the true OpeNER data representation format, it is not very
4
+ friendly for humans. It is also difficult to parse and work with it, specially
5
+ for new users that are not familiarized with KAF. This is part of the feedback
6
+ we got from the OpeNER hackathon held in Amsterdam during first days of July. To
7
+ ease the post-processing of the results by any potential user, we are designing
8
+ an alternative JSON format to output translate KAF, and turn its complexity into
9
+ a much more usable format. Although, the specification for this JSON is
10
+ currently work in progress, we have already a version that covers the most
11
+ relevant parts from the KAF representation.
5
12
 
6
- ### Confused by some terminology?
13
+ ## Confused by some terminology?
7
14
 
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.
15
+ This software is part of a larger collection of natural language processing
16
+ tools known as "the OpeNER project". You can find more information about the
17
+ project at [the OpeNER portal](http://opener-project.github.io). There you can
18
+ also find references to terms like KAF (an XML standard to represent linguistic
19
+ annotations in texts), component, cores, scenario's and pipelines.
9
20
 
10
-
11
- Quick Use Example
12
- -----------------
21
+ ## Quick Use Example
13
22
 
14
23
  Installing the kaf2json can be done by executing:
15
24
 
16
25
  gem install opener-kaf2json
17
26
 
18
- Please bare in mind that all components in OpeNER take KAF as an input and output KAF by default.
27
+ Please keep in mind that all components in OpeNER take KAF as an input and
28
+ output KAF by default.
19
29
 
20
30
  ### Command line interface
21
31
 
22
- You should now be able to call the kaf2json as a regular shell command: by its name. Once installed the gem normally sits in your path so you can call it directly from anywhere.
32
+ You should now be able to call the kaf2json as a regular shell command: by its
33
+ name. Once installed the gem normally sits in your path so you can call it
34
+ directly from anywhere.
23
35
 
24
36
  This aplication reads a text from standard input in order to convert it to JSON.
25
37
 
26
38
  cat some_kind_of_kaf_file.kaf | kaf2json
27
39
 
40
+ The output will look like the following JSON:
28
41
 
29
- This will output (JSON Format):
30
-
31
- ```
32
- {
33
- "text" : "Beatrix Wilhelmina Armgard van Oranje -Nassau (Baarn , 31 januari 1938 ) is sinds 30 april 1980 koningin van het Koninkrijk der Nederlandén ",
34
- "language" : "nl",
35
- "terms" : {},
36
- "sentiments": [],
37
- "entities" : {},
38
- "opinions" : {}
39
- }
40
- ```
42
+ {
43
+ "text" : "Beatrix Wilhelmina Armgard van Oranje -Nassau (Baarn , 31 januari 1938 ) is sinds 30 april 1980 koningin van het Koninkrijk der Nederlandén ",
44
+ "language" : "nl",
45
+ "terms" : {},
46
+ "sentiments": [],
47
+ "entities" : {},
48
+ "opinions" : {}
49
+ }
41
50
 
42
51
  ### Webservices
43
52
 
@@ -45,28 +54,32 @@ You can launch a webservice by executing:
45
54
 
46
55
  kaf2json-server
47
56
 
48
- This will launch a mini webserver with the webservice. It defaults to port 9292, so you can access it at <http://localhost:9292>.
57
+ This will launch a mini webserver with the webservice. It defaults to port 9292,
58
+ so you can access it at <http://localhost:9292>.
49
59
 
50
- To launch it on a different port provide the `-p [port-number]` option like this:
60
+ To launch it on a different port provide the `-p [port-number]` option like
61
+ this:
51
62
 
52
63
  kaf2json-server -p 1234
53
64
 
54
65
  It then launches at <http://localhost:1234>
55
66
 
56
- 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.
57
-
67
+ Documentation on the Webservice is provided by surfing to the urls provided
68
+ above. For more information on how to launch a webservice run the command with
69
+ the `--help` option.
58
70
 
59
71
  ### Daemon
60
72
 
61
- Last but not least the kaf2json comes shipped with a daemon that can read jobs (and write) jobs to and from Amazon SQS queues. For more information type:
73
+ Last but not least the kaf2json comes shipped with a daemon that can read jobs
74
+ (and write) jobs to and from Amazon SQS queues. For more information type:
62
75
 
63
76
  kaf2json-daemon -h
64
77
 
78
+ ## Description of dependencies
65
79
 
66
- Description of dependencies
67
- ---------------------------
68
-
69
- 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
80
+ This component runs best if you run it in an environment suited for OpeNER
81
+ components. You can find an installation guide and helper tools in the
82
+ [OpeNER installer](https://github.com/opener-project/opener-installer) and an
70
83
  [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
71
84
 
72
85
  At least you need the following system setup:
@@ -75,28 +88,17 @@ At least you need the following system setup:
75
88
 
76
89
  * JRuby 1.7.9 or newer
77
90
 
78
- The Core
79
- --------
80
-
81
- The component is a fat wrapper around the actual language technology core. You can find the core technolies in the following repositories:
82
-
83
- * (link to) Related Core readmes
84
-
85
- Where to go from here
86
- ---------------------
91
+ ## Where to go from here
87
92
 
88
93
  * [Check the project website](http://opener-project.github.io)
89
94
  * [Checkout the webservice](http://opener.olery.com/kaf2json)
90
95
 
91
- Report problem/Get help
92
- -----------------------
96
+ ## Report problem/Get help
93
97
 
94
98
  If you encounter problems, please email support@opener-project.eu or leave an
95
99
  [issue tracker](https://github.com/opener-project/kaf2json/issues).
96
100
 
97
-
98
- Contributing
99
- ------------
101
+ ## Contributing
100
102
 
101
103
  1. Fork it <http://github.com/opener-project/kaf2json/fork>
102
104
  2. Create your feature branch (`git checkout -b my-new-feature`)
data/bin/kaf2json CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  require_relative '../lib/opener/kaf_to_json'
3
4
 
4
- cli = Opener::KafToJson.new(:args => ARGV)
5
+ cli = Opener::KafToJson::CLI.new
5
6
 
6
- puts cli.run(STDIN.tty? ? nil : STDIN.read)
7
+ cli.run
data/bin/kaf2json-daemon CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'opener/daemons'
4
4
 
5
- exec_path = File.expand_path('../../exec/kaf-to-json.rb', __FILE__)
5
+ controller = Opener::Daemons::Controller.new(
6
+ :name => 'opener-kaf-to-json',
7
+ :exec_path => File.expand_path('../../exec/kaf-to-json.rb', __FILE__)
8
+ )
6
9
 
7
- Opener::Daemons::Controller.new(
8
- :name => 'kaf-to-json',
9
- :exec_path => exec_path
10
- )
10
+ controller.run
data/bin/kaf2json-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-kaf-to-json',
7
+ File.expand_path('../../config.ru', __FILE__)
8
+ )
6
9
 
7
- cli = Puma::CLI.new([rack_config] + ARGV)
8
- cli.run
10
+ parser.run
data/exec/kaf-to-json.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/kaf_to_json'
5
6
 
6
- options = Opener::Daemons::OptParser.parse!(ARGV)
7
- daemon = Opener::Daemons::Daemon.new(Opener::KafToJson, options)
7
+ daemon = Opener::Daemons::Daemon.new(Opener::KafToJson)
8
8
 
9
- daemon.start
9
+ daemon.start
@@ -0,0 +1,58 @@
1
+ module Opener
2
+ class KafToJson
3
+ ##
4
+ # CLI wrapper around {Opener::KafToJson} using Slop.
5
+ #
6
+ # @!attribute [r] parser
7
+ # @return [Slop]
8
+ #
9
+ class CLI
10
+ attr_reader :parser
11
+
12
+ def initialize
13
+ @parser = configure_slop
14
+ end
15
+
16
+ ##
17
+ # @param [Array] argv
18
+ #
19
+ def run(argv = ARGV)
20
+ parser.parse(argv)
21
+ end
22
+
23
+ ##
24
+ # @return [Slop]
25
+ #
26
+ def configure_slop
27
+ return Slop.new(:strict => false, :indent => 2, :help => true) do
28
+ banner 'Usage: kaf2json [OPTIONS]'
29
+
30
+ separator <<-EOF.chomp
31
+
32
+ About:
33
+
34
+ Component that converts a given KAF document into a JSON object.
35
+ This command reads input from STDIN.
36
+
37
+ Example:
38
+
39
+ cat some_file.kaf | kaf2json
40
+ EOF
41
+
42
+ separator "\nOptions:\n"
43
+
44
+ on :v, :version, 'Shows the current version' do
45
+ abort "kaf2json v#{VERSION} on #{RUBY_DESCRIPTION}"
46
+ end
47
+
48
+ run do |opts, args|
49
+ converter = KafToJson.new
50
+ input = STDIN.tty? ? nil : STDIN.read
51
+
52
+ puts converter.run(input)
53
+ end
54
+ end
55
+ end
56
+ end # CLI
57
+ end # KafToJson
58
+ end # Opener
@@ -1,4 +1,3 @@
1
- require 'sinatra/base'
2
1
  require 'opener/webservice'
3
2
 
4
3
  module Opener
@@ -6,10 +5,11 @@ module Opener
6
5
  ##
7
6
  # POS Tagger server powered by Sinatra.
8
7
  #
9
- class Server < Webservice
8
+ class Server < Webservice::Server
10
9
  set :views, File.expand_path('../views', __FILE__)
11
- text_processor KafToJson
12
- accepted_params :input
10
+
11
+ self.text_processor = KafToJson
12
+ self.accepted_params = [:input]
13
13
  end # Server
14
14
  end # KafToJson
15
15
  end # Opener
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class KafToJson
3
- VERSION = "1.1.1"
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -1,65 +1,48 @@
1
+ require 'slop'
1
2
  require 'saxon-xslt'
2
- require 'opener/core'
3
3
 
4
4
  require_relative 'kaf_to_json/version'
5
5
  require_relative 'kaf_to_json/server'
6
+ require_relative 'kaf_to_json/cli'
6
7
 
7
8
  module Opener
8
9
  ##
9
- # Primary POS tagger class that delegates work the various POS tagging
10
- # kernels.
11
- #
12
- # @!attribute [r] options
13
- # @return [Hash]
10
+ # Component for converting KAF documents to JSON objects.
14
11
  #
15
12
  class KafToJson
16
- attr_reader :options
17
-
18
13
  ##
19
- # Hash containing the default options to use.
14
+ # This method takes a single argument that is ignored to ensure
15
+ # compatibility with all the other OpeNER components.
20
16
  #
21
- # @return [Hash]
22
- #
23
- DEFAULT_OPTIONS = {
24
- :args => []
25
- }.freeze
17
+ def initialize(*); end
26
18
 
27
19
  ##
28
- # @param [Hash] options
20
+ # Processes the input KAF document and returns a String containing the JSON
21
+ # output.
29
22
  #
30
- # @option options [Array] :args Arbitrary arguments to pass to the
31
- # underlying kernel.
23
+ # @param [String] input The input to process.
24
+ # @return [String]
32
25
  #
33
- def initialize(options = {})
34
- @options = DEFAULT_OPTIONS.merge(options)
26
+ def run(input)
27
+ doc = Saxon::XML(input)
28
+ xslt = Saxon::XSLT(File.read(xsl))
29
+
30
+ return xslt.transform(doc).to_s
35
31
  end
36
32
 
33
+ alias tag run
34
+
37
35
  ##
38
- # Processes the input and returns an Array containing the output of STDOUT,
39
- # STDERR and an object containing process information.
36
+ # The output type to use in the webservices.
40
37
  #
41
- # @param [String] input The input to process.
42
- # @return [Array]
38
+ # @return [Symbol]
43
39
  #
44
- def run(input)
45
- begin
46
- doc = Saxon::XML(input)
47
- xslt = Saxon::XSLT(File.read(xsl))
48
- return xslt.transform(doc).to_string
49
-
50
- rescue Exception => error
51
- return Opener::Core::ErrorLayer.new(input, error.message, self.class).add
52
- end
53
- end
54
-
55
- alias tag run
56
-
57
40
  def output_type
58
41
  return :json
59
42
  end
60
-
43
+
61
44
  private
62
-
45
+
63
46
  ##
64
47
  # @return [String]
65
48
  #
@@ -75,4 +58,3 @@ module Opener
75
58
  end
76
59
  end # KafToJson
77
60
  end # Opener
78
-
@@ -11,25 +11,28 @@ Gem::Specification.new do |gem|
11
11
  gem.required_ruby_version = '>= 1.9.2'
12
12
  gem.platform = 'java'
13
13
 
14
+ gem.license = 'Apache 2.0'
15
+
14
16
  gem.files = Dir.glob([
15
17
  'config/*',
16
18
  'lib/**/*',
17
19
  'config.ru',
18
20
  '*.gemspec',
19
21
  'README.md',
22
+ 'LICENSE.txt',
20
23
  'exec/**/*'
21
24
  ]).select { |file| File.file?(file) }
22
25
 
23
26
  gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
24
27
 
28
+ gem.add_dependency 'opener-daemons', '~> 2.2'
29
+ gem.add_dependency 'opener-webservice', '~> 2.1'
30
+ gem.add_dependency 'opener-core', '~> 2.2'
31
+
25
32
  gem.add_dependency 'builder'
26
- gem.add_dependency 'sinatra', '~>1.4.2'
27
33
  gem.add_dependency 'nokogiri'
28
34
  gem.add_dependency 'saxon-xslt'
29
- gem.add_dependency 'puma'
30
- gem.add_dependency 'opener-daemons'
31
- gem.add_dependency 'opener-webservice'
32
- gem.add_dependency 'opener-core', '~> 1.0'
35
+ gem.add_dependency 'slop', '~> 3.5'
33
36
 
34
37
  gem.add_development_dependency 'rspec'
35
38
  gem.add_development_dependency 'cucumber'
metadata CHANGED
@@ -1,73 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-kaf2json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.0
5
5
  platform: java
6
6
  authors:
7
7
  - development@olery.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 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: builder
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- requirement: !ruby/object:Gem::Requirement
21
- requirements:
22
- - - '>='
23
- - !ruby/object:Gem::Version
24
- version: '0'
25
- prerelease: false
26
- type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: sinatra
14
+ name: opener-daemons
29
15
  version_requirements: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ~>
32
18
  - !ruby/object:Gem::Version
33
- version: 1.4.2
19
+ version: '2.2'
34
20
  requirement: !ruby/object:Gem::Requirement
35
21
  requirements:
36
22
  - - ~>
37
23
  - !ruby/object:Gem::Version
38
- version: 1.4.2
24
+ version: '2.2'
39
25
  prerelease: false
40
26
  type: :runtime
41
27
  - !ruby/object:Gem::Dependency
42
- name: nokogiri
28
+ name: opener-webservice
43
29
  version_requirements: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - '>='
31
+ - - ~>
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: '2.1'
48
34
  requirement: !ruby/object:Gem::Requirement
49
35
  requirements:
50
- - - '>='
36
+ - - ~>
51
37
  - !ruby/object:Gem::Version
52
- version: '0'
38
+ version: '2.1'
53
39
  prerelease: false
54
40
  type: :runtime
55
41
  - !ruby/object:Gem::Dependency
56
- name: saxon-xslt
42
+ name: opener-core
57
43
  version_requirements: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - '>='
45
+ - - ~>
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
47
+ version: '2.2'
62
48
  requirement: !ruby/object:Gem::Requirement
63
49
  requirements:
64
- - - '>='
50
+ - - ~>
65
51
  - !ruby/object:Gem::Version
66
- version: '0'
52
+ version: '2.2'
67
53
  prerelease: false
68
54
  type: :runtime
69
55
  - !ruby/object:Gem::Dependency
70
- name: puma
56
+ name: builder
71
57
  version_requirements: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - '>='
@@ -81,7 +67,7 @@ dependencies:
81
67
  prerelease: false
82
68
  type: :runtime
83
69
  - !ruby/object:Gem::Dependency
84
- name: opener-daemons
70
+ name: nokogiri
85
71
  version_requirements: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - '>='
@@ -95,7 +81,7 @@ dependencies:
95
81
  prerelease: false
96
82
  type: :runtime
97
83
  - !ruby/object:Gem::Dependency
98
- name: opener-webservice
84
+ name: saxon-xslt
99
85
  version_requirements: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - '>='
@@ -109,17 +95,17 @@ dependencies:
109
95
  prerelease: false
110
96
  type: :runtime
111
97
  - !ruby/object:Gem::Dependency
112
- name: opener-core
98
+ name: slop
113
99
  version_requirements: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
117
- version: '1.0'
103
+ version: '3.5'
118
104
  requirement: !ruby/object:Gem::Requirement
119
105
  requirements:
120
106
  - - ~>
121
107
  - !ruby/object:Gem::Version
122
- version: '1.0'
108
+ version: '3.5'
123
109
  prerelease: false
124
110
  type: :runtime
125
111
  - !ruby/object:Gem::Dependency
@@ -181,27 +167,30 @@ dependencies:
181
167
  description: Converts KAF input into JSON
182
168
  email:
183
169
  executables:
184
- - kaf2json
185
170
  - kaf2json-daemon
186
171
  - kaf2json-server
172
+ - kaf2json
187
173
  extensions: []
188
174
  extra_rdoc_files: []
189
175
  files:
190
- - README.md
191
- - bin/kaf2json
192
- - bin/kaf2json-daemon
193
- - bin/kaf2json-server
194
- - config.ru
195
176
  - config/kaf2json.xsl
196
- - exec/kaf-to-json.rb
197
177
  - lib/opener/kaf_to_json.rb
198
- - lib/opener/kaf_to_json/public/markdown.css
199
- - lib/opener/kaf_to_json/server.rb
200
178
  - lib/opener/kaf_to_json/version.rb
179
+ - lib/opener/kaf_to_json/server.rb
180
+ - lib/opener/kaf_to_json/cli.rb
181
+ - lib/opener/kaf_to_json/public/markdown.css
201
182
  - lib/opener/kaf_to_json/views/index.erb
183
+ - config.ru
202
184
  - opener-kaf2json.gemspec
185
+ - README.md
186
+ - LICENSE.txt
187
+ - exec/kaf-to-json.rb
188
+ - bin/kaf2json-daemon
189
+ - bin/kaf2json-server
190
+ - bin/kaf2json
203
191
  homepage: http://opener-project.github.com/
204
- licenses: []
192
+ licenses:
193
+ - Apache 2.0
205
194
  metadata: {}
206
195
  post_install_message:
207
196
  rdoc_options: []
@@ -219,8 +208,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
208
  version: '0'
220
209
  requirements: []
221
210
  rubyforge_project:
222
- rubygems_version: 2.2.2
211
+ rubygems_version: 2.1.9
223
212
  signing_key:
224
213
  specification_version: 4
225
214
  summary: Converts KAF input into JSON
226
215
  test_files: []
216
+ has_rdoc: yard