opener-kaf2json 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDRhYjIyZWU2OTQ4ZTQwM2IzMmM2Y2NlY2E4YzMxYTA0ZjI1YjFmZQ==
5
+ data.tar.gz: !binary |-
6
+ ZThjNWMzNjVlYWJiNDU0N2M4NTRiYjZiNTJjNjYwNWYwZWFjOTNiZg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ M2RiZTU0OWI0YWNiYzM5YzExZjUxNjBiMDMxNzUwNzcwNzEyMTMxZjIxZDRj
10
+ ZDBiMTBiNTNlOWRlYjkwNjM1NjlmOTAzZjJlM2M5NmMxN2Q0ODIxNmM1YzMz
11
+ OWNkN2RkYWQyNzI1ZDA5MWJmMDQ0Yjc1NDRlM2UyOGI1MmNiOTE=
12
+ data.tar.gz: !binary |-
13
+ Y2JkOGUxNDc1Mjk5ZTc1NjUxODYxYTViZWZlODM4Njc2ZmRhMDVkZDJiMWY5
14
+ NzY0Mjk0NTM2MTFmYzU5NzQyMjkxYTBkZTA5MTNiNTc2MzRjMDA1ZWVmYmEy
15
+ YTAwOWVjMDQ4MjZjZGMyMGY0ZjA4NTBhNzVlMjlhZTMxN2ZiMmE=
@@ -0,0 +1,133 @@
1
+ kaf2json
2
+ ------------
3
+
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.
5
+ This is part of the feedback we got from the OpeNER hackathon held in Amsterdam during first days of July.
6
+ 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.
7
+ 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.
8
+
9
+ ### Confused by some terminology?
10
+
11
+ This software is part of a larger collection of natural language processing
12
+ tools known as "the OpeNER project". You can find more information about the
13
+ project at (the OpeNER portal)[http://opener-project.github.io]. There you can
14
+ also find references to terms like KAF (an XML standard to represent linguistic
15
+ annotations in texts), component, cores, scenario's and pipelines.
16
+
17
+ Quick Use Example
18
+ -----------------
19
+
20
+ Installing the kaf2json can be done by executing:
21
+
22
+ gem install opener-kaf2json
23
+
24
+ Please bare in mind that all components in OpeNER take KAF as an input and
25
+ output KAF by default.
26
+
27
+ ### Command line interface
28
+
29
+ You should now be able to call the kaf2json as a regular shell
30
+ command: by its name. Once installed the gem normally sits in your path so you can call it directly from anywhere.
31
+
32
+ This aplication reads a text from standard input in order to convert it to JSON.
33
+
34
+ cat some_kind_of_kaf_file.kaf | kaf2json
35
+
36
+
37
+ This will output (JSON Format):
38
+
39
+ ```
40
+ {
41
+ "text" : "Beatrix Wilhelmina Armgard van Oranje -Nassau (Baarn , 31 januari 1938 ) is sinds 30 april 1980 koningin van het Koninkrijk der Nederlandén ",
42
+ "language" : "nl",
43
+ "terms" : {},
44
+ "sentiments": [],
45
+ "entities" : {},
46
+ "opinions" : {}
47
+ }
48
+ ```
49
+
50
+ ### Webservices
51
+
52
+ You can launch a webservice by executing:
53
+
54
+ kaf2json-server
55
+
56
+ This will launch a mini webserver with the webservice. It defaults to port 9292,
57
+ so you can access it at <http://localhost:9292>.
58
+
59
+ To launch it on a different port provide the `-p [port-number]` option like
60
+ this:
61
+
62
+ kaf2json-server -p 1234
63
+
64
+ It then launches at <http://localhost:1234>
65
+
66
+ Documentation on the Webservice is provided by surfing to the urls provided
67
+ above. For more information on how to launch a webservice run the command with
68
+ the ```-h``` option.
69
+
70
+
71
+ ### Daemon
72
+
73
+ Last but not least the kaf2json comes shipped with a daemon that
74
+ can read jobs (and write) jobs to and from Amazon SQS queues. For more
75
+ information type:
76
+
77
+ kaf2json-daemon -h
78
+
79
+
80
+ Description of dependencies
81
+ ---------------------------
82
+
83
+ This component runs best if you run it in an environment suited for OpeNER
84
+ components. You can find an installation guide and helper tools in the (OpeNER
85
+ installer)[https://github.com/opener-project/opener-installer] and (an
86
+ installation guide on the Opener
87
+ Website)[http://opener-project.github.io/getting-started/how-to/local-installation.html]
88
+
89
+ At least you need the following system setup:
90
+
91
+ ### Depenencies for normal use:
92
+
93
+ * JRuby 1.7.9 or newer
94
+
95
+ Domain Adaption
96
+ ---------------
97
+
98
+ TODO
99
+
100
+ Language Extension
101
+ ------------------
102
+
103
+ TODO
104
+
105
+ The Core
106
+ --------
107
+
108
+ The component is a fat wrapper around the actual language technology core. You
109
+ can find the core technolies in the following repositories:
110
+
111
+ * (link to) Related Core readmes
112
+
113
+ Where to go from here
114
+ ---------------------
115
+
116
+ * Check (the project websitere)[http://opener-project.github.io]
117
+ * (Checkout the webservice)[http://opener.olery.com/kaf2json]
118
+
119
+ Report problem/Get help
120
+ -----------------------
121
+
122
+ If you encounter problems, please email support@opener-project.eu or leave an
123
+ issue in the (issue tracker)[https://github.com/opener-project/kaf2json/issues].
124
+
125
+
126
+ Contributing
127
+ ------------
128
+
129
+ 1. Fork it ( http://github.com/opener-project/kaf2json/fork )
130
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
131
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
132
+ 4. Push to the branch (`git push origin my-new-feature`)
133
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/opener/kaf_to_json'
3
+
4
+ cli = Opener::KafToJson.new(:args => ARGV)
5
+
6
+ puts cli.run(STDIN.tty? ? nil : STDIN.read)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'puma/cli'
4
+
5
+ rack_config = File.expand_path('../../config.ru', __FILE__)
6
+
7
+ cli = Puma::CLI.new([rack_config] + ARGV)
8
+ cli.run
@@ -0,0 +1,4 @@
1
+ require File.expand_path('../lib/opener/kaf_to_json', __FILE__)
2
+ require File.expand_path('../lib/opener/kaf_to_json/server', __FILE__)
3
+
4
+ run Opener::KafToJson::Server
@@ -0,0 +1,77 @@
1
+ require_relative 'kaf_to_json/version'
2
+ require_relative 'kaf_to_json/server'
3
+
4
+ require 'json'
5
+ require 'nokogiri'
6
+ require 'open3'
7
+ require 'optparse'
8
+
9
+
10
+
11
+ module Opener
12
+ ##
13
+ # Primary POS tagger class that delegates work the various POS tagging
14
+ # kernels.
15
+ #
16
+ # @!attribute [r] options
17
+ # @return [Hash]
18
+ #
19
+ class KafToJson
20
+ attr_reader :options
21
+
22
+ ##
23
+ # Hash containing the default options to use.
24
+ #
25
+ # @return [Hash]
26
+ #
27
+ DEFAULT_OPTIONS = {
28
+ :args => []
29
+ }.freeze
30
+
31
+ ##
32
+ # @param [Hash] options
33
+ #
34
+ # @option options [Array] :args Arbitrary arguments to pass to the
35
+ # underlying kernel.
36
+ #
37
+ def initialize(options = {})
38
+ @options = DEFAULT_OPTIONS.merge(options)
39
+ end
40
+
41
+ ##
42
+ # Processes the input and returns an Array containing the output of STDOUT,
43
+ # STDERR and an object containing process information.
44
+ #
45
+ # @param [String] input The input to process.
46
+ # @return [Array]
47
+ #
48
+ def run(input)
49
+ doc = Nokogiri::XML(input)
50
+ xslt = Nokogiri::XSLT(File.read(xsl))
51
+ xslt.apply_to(doc)
52
+ end
53
+
54
+ alias tag run
55
+
56
+ def output_type
57
+ return :json
58
+ end
59
+
60
+ private
61
+
62
+ ##
63
+ # @return [String]
64
+ #
65
+ def config_dir
66
+ return File.expand_path('../../../config', __FILE__)
67
+ end
68
+
69
+ ##
70
+ # @return [String]
71
+ #
72
+ def xsl
73
+ return File.join(config_dir, 'kaf2json.xsl')
74
+ end
75
+ end # KafToJson
76
+ end # Opener
77
+
@@ -0,0 +1,283 @@
1
+ input[type="text"], textarea
2
+ {
3
+ width: 500px;
4
+ }
5
+
6
+ body {
7
+ font-family: Helvetica, arial, sans-serif;
8
+ font-size: 14px;
9
+ line-height: 1.6;
10
+ padding-top: 10px;
11
+ padding-bottom: 10px;
12
+ background-color: white;
13
+ padding: 30px; }
14
+
15
+ body > *:first-child {
16
+ margin-top: 0 !important; }
17
+ body > *:last-child {
18
+ margin-bottom: 0 !important; }
19
+
20
+ a {
21
+ color: #4183C4; }
22
+ a.absent {
23
+ color: #cc0000; }
24
+ a.anchor {
25
+ display: block;
26
+ padding-left: 30px;
27
+ margin-left: -30px;
28
+ cursor: pointer;
29
+ position: absolute;
30
+ top: 0;
31
+ left: 0;
32
+ bottom: 0; }
33
+
34
+ h1, h2, h3, h4, h5, h6 {
35
+ margin: 20px 0 10px;
36
+ padding: 0;
37
+ font-weight: bold;
38
+ -webkit-font-smoothing: antialiased;
39
+ cursor: text;
40
+ position: relative; }
41
+
42
+ h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
43
+ background: url("../../images/modules/styleguide/para.png") no-repeat 10px center;
44
+ text-decoration: none; }
45
+
46
+ h1 tt, h1 code {
47
+ font-size: inherit; }
48
+
49
+ h2 tt, h2 code {
50
+ font-size: inherit; }
51
+
52
+ h3 tt, h3 code {
53
+ font-size: inherit; }
54
+
55
+ h4 tt, h4 code {
56
+ font-size: inherit; }
57
+
58
+ h5 tt, h5 code {
59
+ font-size: inherit; }
60
+
61
+ h6 tt, h6 code {
62
+ font-size: inherit; }
63
+
64
+ h1 {
65
+ font-size: 28px;
66
+ color: black; }
67
+
68
+ h2 {
69
+ font-size: 24px;
70
+ border-bottom: 1px solid #cccccc;
71
+ color: black; }
72
+
73
+ h3 {
74
+ font-size: 18px; }
75
+
76
+ h4 {
77
+ font-size: 16px; }
78
+
79
+ h5 {
80
+ font-size: 14px; }
81
+
82
+ h6 {
83
+ color: #777777;
84
+ font-size: 14px; }
85
+
86
+ p, blockquote, ul, ol, dl, li, table, pre {
87
+ margin: 15px 0; }
88
+
89
+ hr {
90
+ background: transparent url("../../images/modules/pulls/dirty-shade.png") repeat-x 0 0;
91
+ border: 0 none;
92
+ color: #cccccc;
93
+ height: 4px;
94
+ padding: 0; }
95
+
96
+ body > h2:first-child {
97
+ margin-top: 0;
98
+ padding-top: 0; }
99
+ body > h1:first-child {
100
+ margin-top: 0;
101
+ padding-top: 0; }
102
+ body > h1:first-child + h2 {
103
+ margin-top: 0;
104
+ padding-top: 0; }
105
+ body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
106
+ margin-top: 0;
107
+ padding-top: 0; }
108
+
109
+ a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
110
+ margin-top: 0;
111
+ padding-top: 0; }
112
+
113
+ h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
114
+ margin-top: 0; }
115
+
116
+ li p.first {
117
+ display: inline-block; }
118
+
119
+ ul, ol {
120
+ padding-left: 30px; }
121
+
122
+ ul :first-child, ol :first-child {
123
+ margin-top: 0; }
124
+
125
+ ul :last-child, ol :last-child {
126
+ margin-bottom: 0; }
127
+
128
+ dl {
129
+ padding: 0; }
130
+ dl dt {
131
+ font-size: 14px;
132
+ font-weight: bold;
133
+ font-style: italic;
134
+ padding: 0;
135
+ margin: 15px 0 5px; }
136
+ dl dt:first-child {
137
+ padding: 0; }
138
+ dl dt > :first-child {
139
+ margin-top: 0; }
140
+ dl dt > :last-child {
141
+ margin-bottom: 0; }
142
+ dl dd {
143
+ margin: 0 0 15px;
144
+ padding: 0 15px; }
145
+ dl dd > :first-child {
146
+ margin-top: 0; }
147
+ dl dd > :last-child {
148
+ margin-bottom: 0; }
149
+
150
+ blockquote {
151
+ border-left: 4px solid #dddddd;
152
+ padding: 0 15px;
153
+ color: #777777; }
154
+ blockquote > :first-child {
155
+ margin-top: 0; }
156
+ blockquote > :last-child {
157
+ margin-bottom: 0; }
158
+
159
+ table {
160
+ padding: 0; }
161
+ table tr {
162
+ border-top: 1px solid #cccccc;
163
+ background-color: white;
164
+ margin: 0;
165
+ padding: 0; }
166
+ table tr:nth-child(2n) {
167
+ background-color: #f8f8f8; }
168
+ table tr th {
169
+ font-weight: bold;
170
+ border: 1px solid #cccccc;
171
+ text-align: left;
172
+ margin: 0;
173
+ padding: 6px 13px; }
174
+ table tr td {
175
+ border: 1px solid #cccccc;
176
+ text-align: left;
177
+ margin: 0;
178
+ padding: 6px 13px; }
179
+ table tr th :first-child, table tr td :first-child {
180
+ margin-top: 0; }
181
+ table tr th :last-child, table tr td :last-child {
182
+ margin-bottom: 0; }
183
+
184
+ img {
185
+ max-width: 100%; }
186
+
187
+ span.frame {
188
+ display: block;
189
+ overflow: hidden; }
190
+ span.frame > span {
191
+ border: 1px solid #dddddd;
192
+ display: block;
193
+ float: left;
194
+ overflow: hidden;
195
+ margin: 13px 0 0;
196
+ padding: 7px;
197
+ width: auto; }
198
+ span.frame span img {
199
+ display: block;
200
+ float: left; }
201
+ span.frame span span {
202
+ clear: both;
203
+ color: #333333;
204
+ display: block;
205
+ padding: 5px 0 0; }
206
+ span.align-center {
207
+ display: block;
208
+ overflow: hidden;
209
+ clear: both; }
210
+ span.align-center > span {
211
+ display: block;
212
+ overflow: hidden;
213
+ margin: 13px auto 0;
214
+ text-align: center; }
215
+ span.align-center span img {
216
+ margin: 0 auto;
217
+ text-align: center; }
218
+ span.align-right {
219
+ display: block;
220
+ overflow: hidden;
221
+ clear: both; }
222
+ span.align-right > span {
223
+ display: block;
224
+ overflow: hidden;
225
+ margin: 13px 0 0;
226
+ text-align: right; }
227
+ span.align-right span img {
228
+ margin: 0;
229
+ text-align: right; }
230
+ span.float-left {
231
+ display: block;
232
+ margin-right: 13px;
233
+ overflow: hidden;
234
+ float: left; }
235
+ span.float-left span {
236
+ margin: 13px 0 0; }
237
+ span.float-right {
238
+ display: block;
239
+ margin-left: 13px;
240
+ overflow: hidden;
241
+ float: right; }
242
+ span.float-right > span {
243
+ display: block;
244
+ overflow: hidden;
245
+ margin: 13px auto 0;
246
+ text-align: right; }
247
+
248
+ code, tt {
249
+ margin: 0 2px;
250
+ padding: 0 5px;
251
+ white-space: nowrap;
252
+ border: 1px solid #eaeaea;
253
+ background-color: #f8f8f8;
254
+ border-radius: 3px; }
255
+
256
+ pre code {
257
+ margin: 0;
258
+ padding: 0;
259
+ white-space: pre;
260
+ border: none;
261
+ background: transparent; }
262
+
263
+ .highlight pre {
264
+ background-color: #f8f8f8;
265
+ border: 1px solid #cccccc;
266
+ font-size: 13px;
267
+ line-height: 19px;
268
+ overflow: auto;
269
+ padding: 6px 10px;
270
+ border-radius: 3px; }
271
+
272
+ pre {
273
+ background-color: #f8f8f8;
274
+ border: 1px solid #cccccc;
275
+ font-size: 13px;
276
+ line-height: 19px;
277
+ overflow: auto;
278
+ padding: 6px 10px;
279
+ border-radius: 3px; }
280
+ pre code, pre tt {
281
+ background-color: transparent;
282
+ border: none; }
283
+
@@ -0,0 +1,15 @@
1
+ require 'sinatra/base'
2
+ require 'opener/webservice'
3
+
4
+ module Opener
5
+ class KafToJson
6
+ ##
7
+ # POS Tagger server powered by Sinatra.
8
+ #
9
+ class Server < Webservice
10
+ set :views, File.expand_path('../views', __FILE__)
11
+ text_processor KafToJson
12
+ accepted_params :input
13
+ end # Server
14
+ end # KafToJson
15
+ end # Opener
@@ -0,0 +1,5 @@
1
+ module Opener
2
+ class KafToJson
3
+ VERSION = "1.0.1"
4
+ end
5
+ end
@@ -0,0 +1,163 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <link type="text/css" rel="stylesheet" charset="UTF-8" href="markdown.css"/>
5
+ <title>KAF to JSON Webservice</title>
6
+ </head>
7
+ <body>
8
+ <h1>KAF to JSON Web Service</h1>
9
+
10
+ <h2>Example Usage</h2>
11
+
12
+ <p>
13
+ <pre>kaf2json-server start</pre>
14
+ <pre>curl -d &#39;input=&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;KAF version=&quot;v1.opener&quot; xml:lang=&quot;en&quot;&gt;&lt;kafHeader&gt;&lt;linguisticProcessors layer=&quot;text&quot;&gt;&lt;lp name=&quot;opennlp-en-tok&quot; timestamp=&quot;2013-06-11T13:41:37Z&quot; version=&quot;1.0&quot;/&gt;&lt;lp name=&quot;opennlp-en-sent&quot; timestamp=&quot;2013-06-11T13:41:37Z&quot; version=&quot;1.0&quot;/&gt;&lt;/linguisticProcessors&gt;&lt;/kafHeader&gt;&lt;text&gt;&lt;wf length=&quot;4&quot; offset=&quot;0&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w1&quot;&gt;this&lt;/wf&gt;&lt;wf length=&quot;2&quot; offset=&quot;5&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w2&quot;&gt;is&lt;/wf&gt;&lt;wf length=&quot;2&quot; offset=&quot;8&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w3&quot;&gt;an&lt;/wf&gt;&lt;wf length=&quot;7&quot; offset=&quot;11&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w4&quot;&gt;english&lt;/wf&gt;&lt;wf length=&quot;4&quot; offset=&quot;19&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w5&quot;&gt;text&lt;/wf&gt;&lt;/text&gt;&lt;/KAF&gt;&#39; http://localhost:9292 -XPOST</pre>
15
+
16
+ outputs:
17
+
18
+ <pre>
19
+ &lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39;?&gt;
20
+ &lt;KAF version=&quot;v1.opener&quot; xml:lang=&quot;en&quot;&gt;
21
+ &lt;kafHeader&gt;
22
+ &lt;linguisticProcessors layer=&quot;text&quot;&gt;
23
+ &lt;lp name=&quot;opennlp-en-tok&quot; timestamp=&quot;2013-06-11T13:41:37Z&quot; version=&quot;1.0&quot;/&gt;
24
+ &lt;lp name=&quot;opennlp-en-sent&quot; timestamp=&quot;2013-06-11T13:41:37Z&quot; version=&quot;1.0&quot;/&gt;
25
+ &lt;/linguisticProcessors&gt;
26
+ &lt;linguisticProcessor layer=&quot;term&quot;&gt;
27
+ &lt;lp timestamp=&quot;2013-06-12T15:18:03CEST&quot; version=&quot;1.0&quot; name=&quot;Open nlp pos tagger&quot;/&gt;
28
+ &lt;/linguisticProcessor&gt;
29
+ &lt;/kafHeader&gt;
30
+ &lt;text&gt;
31
+ &lt;wf length=&quot;4&quot; offset=&quot;0&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w1&quot;&gt;this&lt;/wf&gt;
32
+ &lt;wf length=&quot;2&quot; offset=&quot;5&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w2&quot;&gt;is&lt;/wf&gt;
33
+ &lt;wf length=&quot;2&quot; offset=&quot;8&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w3&quot;&gt;an&lt;/wf&gt;
34
+ &lt;wf length=&quot;7&quot; offset=&quot;11&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w4&quot;&gt;english&lt;/wf&gt;
35
+ &lt;wf length=&quot;4&quot; offset=&quot;19&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w5&quot;&gt;text&lt;/wf&gt;
36
+ &lt;/text&gt;
37
+ &lt;terms&gt;
38
+ &lt;term lemma=&quot;this&quot; morphofeat=&quot;FM&quot; pos=&quot;O&quot; tid=&quot;t_1&quot; type=&quot;open&quot;&gt;
39
+ &lt;span&gt;
40
+ &lt;target id=&quot;w1&quot;/&gt;
41
+ &lt;/span&gt;
42
+ &lt;/term&gt;
43
+ &lt;term lemma=&quot;is&quot; morphofeat=&quot;FM&quot; pos=&quot;O&quot; tid=&quot;t_2&quot; type=&quot;open&quot;&gt;
44
+ &lt;span&gt;
45
+ &lt;target id=&quot;w2&quot;/&gt;
46
+ &lt;/span&gt;
47
+ &lt;/term&gt;
48
+ &lt;term lemma=&quot;an&quot; morphofeat=&quot;APPR&quot; pos=&quot;P&quot; tid=&quot;t_3&quot; type=&quot;close&quot;&gt;
49
+ &lt;span&gt;
50
+ &lt;target id=&quot;w3&quot;/&gt;
51
+ &lt;/span&gt;
52
+ &lt;/term&gt;
53
+ &lt;term lemma=&quot;english&quot; morphofeat=&quot;FM&quot; pos=&quot;O&quot; tid=&quot;t_4&quot; type=&quot;open&quot;&gt;
54
+ &lt;span&gt;
55
+ &lt;target id=&quot;w4&quot;/&gt;
56
+ &lt;/span&gt;
57
+ &lt;/term&gt;
58
+ &lt;term lemma=&quot;text&quot; morphofeat=&quot;FM&quot; pos=&quot;O&quot; tid=&quot;t_5&quot; type=&quot;open&quot;&gt;
59
+ &lt;span&gt;
60
+ &lt;target id=&quot;w5&quot;/&gt;
61
+ &lt;/span&gt;
62
+ &lt;/term&gt;
63
+ &lt;/terms&gt;
64
+ &lt;/KAF&gt;</pre>
65
+ </p>
66
+
67
+ <h2>Try the webservice</h2>
68
+
69
+ <p>* required</p>
70
+ <p>** When entering a value no response will be displayed in the browser.</p>
71
+
72
+ <form action="<%=url("/")%>" method="POST">
73
+ <div>
74
+ <label for="input"/>Type your text here*</label>
75
+ <br/>
76
+
77
+ <textarea name="input" id="text" rows="10" cols="50"/></textarea>
78
+ </div>
79
+
80
+ <% 10.times do |t| %>
81
+ <div>
82
+ <label for="callbacks">Callback URL <%=t+1%>(**)</label>
83
+ <br />
84
+
85
+ <input id="callbacks" type="text" name="callbacks[]" />
86
+ </div>
87
+ <% end %>
88
+
89
+
90
+ <div>
91
+ <label for="error_callback">Error Callback</label>
92
+ <br />
93
+
94
+ <input id="error_callback" type="text" name="error_callback" />
95
+ </div>
96
+ <input type="submit" value="Submit" />
97
+ </form>
98
+
99
+ <h2>Actions</h2>
100
+
101
+ <p>
102
+ <dl>
103
+ <dt>POST /</dt>
104
+ <dd>Convert the input KAF text. See arguments listing for more options.</dd>
105
+ <dt>GET /</dt>
106
+ <dd>Show this page</dd>
107
+ </dl>
108
+ </p>
109
+
110
+ <h2>Arguments</h2>
111
+
112
+ <p> The webservice takes the following arguments: </p>
113
+ <p>* required</p>
114
+
115
+ <dl>
116
+ <dt>text*</dt>
117
+ <dd>The input text in KAF format. Sample KAF input:</dd>
118
+ <pre>
119
+ &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
120
+ &lt;KAF version=&quot;v1.opener&quot; xml:lang=&quot;en&quot;&gt;
121
+ &lt;kafHeader&gt;
122
+ &lt;linguisticProcessors layer=&quot;text&quot;&gt;
123
+ &lt;lp name=&quot;opennlp-en-tok&quot; timestamp=&quot;2013-06-11T13:41:37Z&quot; version=&quot;1.0&quot;/&gt;
124
+ &lt;lp name=&quot;opennlp-en-sent&quot; timestamp=&quot;2013-06-11T13:41:37Z&quot; version=&quot;1.0&quot;/&gt;
125
+ &lt;/linguisticProcessors&gt;
126
+ &lt;/kafHeader&gt;
127
+ &lt;text&gt;
128
+ &lt;wf length=&quot;4&quot; offset=&quot;0&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w1&quot;&gt;this&lt;/wf&gt;
129
+ &lt;wf length=&quot;2&quot; offset=&quot;5&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w2&quot;&gt;is&lt;/wf&gt;
130
+ &lt;wf length=&quot;2&quot; offset=&quot;8&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w3&quot;&gt;an&lt;/wf&gt;
131
+ &lt;wf length=&quot;7&quot; offset=&quot;11&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w4&quot;&gt;english&lt;/wf&gt;
132
+ &lt;wf length=&quot;4&quot; offset=&quot;19&quot; para=&quot;1&quot; sent=&quot;1&quot; wid=&quot;w5&quot;&gt;text&lt;/wf&gt;
133
+ &lt;/text&gt;
134
+ &lt;/KAF&gt;</pre>
135
+
136
+ <dt>callbacks</dt>
137
+ <dd>
138
+ You can provide a list of callback urls. If you provide callback urls
139
+ the POS tagger will run as a background job and a callback
140
+ with the results will be performed (POST) to the first url in the callback
141
+ list. The other urls in callback list will be provided in the "callbacks"
142
+ argument.<br/><br/>
143
+ Using callback you can chain together several OpeNER webservices in
144
+ one call. The first, will call the second, which will call the third, etc.
145
+ See for more information the <a href="http://opener-project.github.io">
146
+ webservice documentation online</a>.
147
+ </dd>
148
+ <dt>error_callback</dt>
149
+ <dd>URL to notify if errors occur in the background process. The error
150
+ callback will do a POST with the error message in the 'error' field.</dd>
151
+ </dt>
152
+
153
+
154
+
155
+ </dl>
156
+
157
+
158
+ <p>
159
+
160
+ </p>
161
+
162
+ </body>
163
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <link type="text/css" rel="stylesheet" charset="UTF-8" href="markdown.css"/>
5
+ <title>KAF to JSON Webservice</title>
6
+ </head>
7
+ <body>
8
+ <h1>Output URL</h1>
9
+ <p>
10
+ When ready, you can view the result
11
+ <a href=<%= output_url %>>here</a>
12
+ </p>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../lib/opener/kaf_to_json/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'opener-kaf2json'
5
+ gem.version = Opener::KafToJson::VERSION
6
+ gem.authors = ['development@olery.com']
7
+ gem.summary = 'Converts KAF input into JSON'
8
+ gem.description = gem.summary
9
+ gem.homepage = "http://opener-project.github.com/"
10
+ gem.has_rdoc = 'yard'
11
+ gem.required_ruby_version = '>= 1.9.2'
12
+
13
+ gem.files = Dir.glob([
14
+ 'lib/**/*',
15
+ 'config.ru',
16
+ '*.gemspec',
17
+ 'README.md'
18
+ ]).select { |file| File.file?(file) }
19
+
20
+ gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
21
+
22
+ gem.add_dependency 'builder'
23
+ gem.add_dependency 'sinatra', '~>1.4.2'
24
+ gem.add_dependency 'nokogiri'
25
+ gem.add_dependency 'puma'
26
+ gem.add_dependency 'opener-webservice'
27
+
28
+ gem.add_development_dependency 'rspec'
29
+ gem.add_development_dependency 'cucumber'
30
+ gem.add_development_dependency 'pry'
31
+ gem.add_development_dependency 'rake'
32
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opener-kaf2json
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - development@olery.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: builder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.4.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: puma
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: opener-webservice
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: cucumber
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Converts KAF input into JSON
140
+ email:
141
+ executables:
142
+ - kaf2json
143
+ - kaf2json-server
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - README.md
148
+ - bin/kaf2json
149
+ - bin/kaf2json-server
150
+ - config.ru
151
+ - lib/opener/kaf_to_json.rb
152
+ - lib/opener/kaf_to_json/public/markdown.css
153
+ - lib/opener/kaf_to_json/server.rb
154
+ - lib/opener/kaf_to_json/version.rb
155
+ - lib/opener/kaf_to_json/views/index.erb
156
+ - lib/opener/kaf_to_json/views/result.erb
157
+ - opener-kaf2json.gemspec
158
+ homepage: http://opener-project.github.com/
159
+ licenses: []
160
+ metadata: {}
161
+ post_install_message:
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
169
+ version: 1.9.2
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubyforge_project:
177
+ rubygems_version: 2.2.2
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Converts KAF input into JSON
181
+ test_files: []