opener-kaf2json 1.0.3-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c584701bd31ebf33e4fc649ae77de5883e354f5f
4
+ data.tar.gz: a9e83dcfa6226f4f2f94889a9e26050ba9776f5a
5
+ SHA512:
6
+ metadata.gz: 52542aadba335cb37120a7208d98b7c0b5826da493ef692103f3a453a9aac075ec0bc919f6327e4def95e83b88a0aa86de2450588f2a99e9468ea8d3921afab3
7
+ data.tar.gz: 12c7d3987962c1b991f8967602bcd5b1e931f8a9de79556dcbb2693486561ef648bd7b2cd11034f5e9a07a2fccb4f17bea3fd8b7c07701f7627209c30f456fe7
data/README.md ADDED
@@ -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
data/bin/kaf2json ADDED
@@ -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
data/config.ru ADDED
@@ -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,127 @@
1
+ <?xml version="1.0"?>
2
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
+
4
+ <xsl:output method="text" encoding="utf-8" omit-xml-declaration="yes"/>
5
+
6
+ <xsl:template match="/">{
7
+ "text" : "<xsl:apply-templates select="KAF/text/wf" />",
8
+ "language" : "<xsl:value-of select="KAF/@xml:lang" />",
9
+ "terms" : {<xsl:apply-templates select="KAF/terms/term" />},
10
+ "sentiments": [<xsl:apply-templates select="KAF/terms/term/sentiment" />],
11
+ "entities" : {<xsl:apply-templates select="KAF/entities/entity" />},
12
+ "opinions" : {<xsl:apply-templates select="KAF/opinions/opinion" />}
13
+ }
14
+ </xsl:template>
15
+
16
+ <xsl:template match="wf">
17
+ <xsl:value-of select="."/><xsl:text> </xsl:text>
18
+ </xsl:template>
19
+
20
+ <!-- Levels -->
21
+ <xsl:template match="term">
22
+ <xsl:variable name="termId" select="@tid"/>
23
+ "<xsl:value-of select="$termId"/>":
24
+ {
25
+ "type" :"<xsl:value-of select="@type" />",
26
+ "lemma" :"<xsl:value-of select="@lemma" />",
27
+ "text" :"<xsl:call-template name="termInside2" />",
28
+ "pos" :"<xsl:value-of select="@pos" />",
29
+ "morphofeat" :"<xsl:value-of select="@morphofeat" />"<xsl:if test="//entity//target/@id=$termId">,
30
+ "entity" :"<xsl:value-of select="//entity[.//target/@id=$termId]/@eid"/>"</xsl:if><xsl:if test="sentiment">,
31
+ "polarity" :"<xsl:value-of select="sentiment/@polarity"/>"</xsl:if>
32
+ }<xsl:if test="position()!=last()"><xsl:text>,</xsl:text></xsl:if>
33
+ </xsl:template>
34
+
35
+ <xsl:template match="sentiment">
36
+ {
37
+ "lexicon" :"<xsl:value-of select="@resource" />",
38
+ "polarity":"<xsl:value-of select="@polarity" />",
39
+ "termId" :"<xsl:value-of select="parent::term/@tid"/>",
40
+ "text" :"<xsl:call-template name="termInside" />"
41
+ }<xsl:if test="position()!=last()"><xsl:text>,</xsl:text></xsl:if>
42
+ </xsl:template>
43
+
44
+ <xsl:template match="entity">
45
+ "<xsl:value-of select="@eid"/>":
46
+ {
47
+ "type" :"<xsl:value-of select="@type" />",
48
+ "text" :"<xsl:call-template name="entityInside" />",
49
+ "reference":"<xsl:value-of select="externalReferences/externalRef/@reference" />",
50
+ "terms" :[<xsl:call-template name="entityTerms"/>]
51
+ }<xsl:if test="position()!=last()"><xsl:text>,</xsl:text></xsl:if>
52
+ </xsl:template>
53
+
54
+ <xsl:template match="opinion">
55
+ "<xsl:value-of select="@oid"/>":
56
+ {
57
+ "holder" :"",
58
+ "target" :"",
59
+ "polarity" :"<xsl:value-of select="opinion_expression/@polarity"/>",
60
+ "strength" :"<xsl:value-of select="opinion_expression/@strength"/>",
61
+ "text" :"<xsl:call-template name="opinionInside" />",
62
+ "terms" :[<xsl:call-template name="opinionTerms"/>]
63
+ }<xsl:if test="position()!=last()"><xsl:text>,</xsl:text></xsl:if>
64
+ </xsl:template>
65
+
66
+ <!-- Routines -->
67
+
68
+ <xsl:template name="termInside">
69
+ <xsl:for-each select="parent::term/span/target">
70
+ <xsl:call-template name="word">
71
+ <xsl:with-param name="id" select="@id"/>
72
+ </xsl:call-template>
73
+ <xsl:if test="position()!=last()"><xsl:text> </xsl:text></xsl:if>
74
+ </xsl:for-each>
75
+ </xsl:template>
76
+
77
+ <xsl:template name="termInside2">
78
+ <xsl:for-each select="span/target">
79
+ <xsl:call-template name="word">
80
+ <xsl:with-param name="id" select="@id"/>
81
+ </xsl:call-template>
82
+ <xsl:if test="position()!=last()"><xsl:text> </xsl:text></xsl:if>
83
+ </xsl:for-each>
84
+ </xsl:template>
85
+
86
+ <xsl:template name="entityInside">
87
+ <xsl:for-each select="references/span/target">
88
+ <xsl:call-template name="term">
89
+ <xsl:with-param name="id" select="@id"/>
90
+ </xsl:call-template>
91
+ <xsl:if test="position()!=last()"><xsl:text> </xsl:text></xsl:if>
92
+ </xsl:for-each>
93
+ </xsl:template>
94
+
95
+ <xsl:template name="entityTerms">
96
+ <xsl:for-each select="references/span/target">"<xsl:value-of select="@id"/>"<xsl:if test="position()!=last()"><xsl:text>,</xsl:text></xsl:if></xsl:for-each>
97
+ </xsl:template>
98
+
99
+ <xsl:template name="opinionTerms">
100
+ <xsl:for-each select="opinion_expression/span/target">"<xsl:value-of select="@id"/>"<xsl:if test="position()!=last()"><xsl:text>,</xsl:text></xsl:if></xsl:for-each>
101
+ </xsl:template>
102
+
103
+
104
+ <xsl:template name="opinionInside">
105
+ <xsl:for-each select="opinion_expression/span/target">
106
+ <xsl:call-template name="term">
107
+ <xsl:with-param name="id" select="@id"/>
108
+ </xsl:call-template>
109
+ <xsl:if test="position()!=last()"><xsl:text> </xsl:text></xsl:if>
110
+ </xsl:for-each>
111
+ </xsl:template>
112
+
113
+ <!-- Generic Routines -->
114
+ <xsl:template name="term">
115
+ <xsl:param name="id"/>
116
+ <xsl:for-each select="//term[@tid=$id]/span/target">
117
+ <xsl:call-template name="word">
118
+ <xsl:with-param name="id" select="@id"/>
119
+ </xsl:call-template>
120
+ </xsl:for-each>
121
+ </xsl:template>
122
+
123
+ <xsl:template name="word">
124
+ <xsl:param name="id"/>
125
+ <xsl:value-of select="//wf[@wid=$id]"/>
126
+ </xsl:template>
127
+ </xsl:stylesheet>
@@ -0,0 +1,74 @@
1
+ require_relative 'kaf_to_json/version'
2
+ require_relative 'kaf_to_json/server'
3
+
4
+ require 'saxon-xslt'
5
+
6
+
7
+
8
+ module Opener
9
+ ##
10
+ # Primary POS tagger class that delegates work the various POS tagging
11
+ # kernels.
12
+ #
13
+ # @!attribute [r] options
14
+ # @return [Hash]
15
+ #
16
+ class KafToJson
17
+ attr_reader :options
18
+
19
+ ##
20
+ # Hash containing the default options to use.
21
+ #
22
+ # @return [Hash]
23
+ #
24
+ DEFAULT_OPTIONS = {
25
+ :args => []
26
+ }.freeze
27
+
28
+ ##
29
+ # @param [Hash] options
30
+ #
31
+ # @option options [Array] :args Arbitrary arguments to pass to the
32
+ # underlying kernel.
33
+ #
34
+ def initialize(options = {})
35
+ @options = DEFAULT_OPTIONS.merge(options)
36
+ end
37
+
38
+ ##
39
+ # Processes the input and returns an Array containing the output of STDOUT,
40
+ # STDERR and an object containing process information.
41
+ #
42
+ # @param [String] input The input to process.
43
+ # @return [Array]
44
+ #
45
+ def run(input)
46
+ doc = Saxon::XML(input)
47
+ xslt = Saxon::XSLT(File.read(xsl))
48
+ xslt.transform(doc).to_string
49
+ end
50
+
51
+ alias tag run
52
+
53
+ def output_type
54
+ return :json
55
+ end
56
+
57
+ private
58
+
59
+ ##
60
+ # @return [String]
61
+ #
62
+ def config_dir
63
+ return File.expand_path('../../../config', __FILE__)
64
+ end
65
+
66
+ ##
67
+ # @return [String]
68
+ #
69
+ def xsl
70
+ return File.join(config_dir, 'kaf2json.xsl')
71
+ end
72
+ end # KafToJson
73
+ end # Opener
74
+
@@ -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.3"
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,35 @@
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
+ gem.platform = 'java'
13
+
14
+ gem.files = Dir.glob([
15
+ 'config/*',
16
+ 'lib/**/*',
17
+ 'config.ru',
18
+ '*.gemspec',
19
+ 'README.md'
20
+ ]).select { |file| File.file?(file) }
21
+
22
+ gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
23
+
24
+ gem.add_dependency 'builder'
25
+ gem.add_dependency 'sinatra', '~>1.4.2'
26
+ #gem.add_dependency 'nokogiri'
27
+ gem.add_dependency 'saxon-xslt'
28
+ gem.add_dependency 'puma'
29
+ gem.add_dependency 'opener-webservice'
30
+
31
+ gem.add_development_dependency 'rspec'
32
+ gem.add_development_dependency 'cucumber'
33
+ gem.add_development_dependency 'pry'
34
+ gem.add_development_dependency 'rake'
35
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opener-kaf2json
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: java
6
+ authors:
7
+ - development@olery.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
+ dependencies:
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
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.2
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 1.4.2
39
+ prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: saxon-xslt
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'
53
+ prerelease: false
54
+ type: :runtime
55
+ - !ruby/object:Gem::Dependency
56
+ name: puma
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ prerelease: false
68
+ type: :runtime
69
+ - !ruby/object:Gem::Dependency
70
+ name: opener-webservice
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ prerelease: false
82
+ type: :runtime
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ prerelease: false
96
+ type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: cucumber
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ prerelease: false
110
+ type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
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: rake
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
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
+ - config/kaf2json.xsl
152
+ - lib/opener/kaf_to_json.rb
153
+ - lib/opener/kaf_to_json/public/markdown.css
154
+ - lib/opener/kaf_to_json/server.rb
155
+ - lib/opener/kaf_to_json/version.rb
156
+ - lib/opener/kaf_to_json/views/index.erb
157
+ - lib/opener/kaf_to_json/views/result.erb
158
+ - opener-kaf2json.gemspec
159
+ homepage: http://opener-project.github.com/
160
+ licenses: []
161
+ metadata: {}
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - '>='
169
+ - !ruby/object:Gem::Version
170
+ version: 1.9.2
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 2.2.2
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: Converts KAF input into JSON
182
+ test_files: []