opener-kaf2json 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDRhYjIyZWU2OTQ4ZTQwM2IzMmM2Y2NlY2E4YzMxYTA0ZjI1YjFmZQ==
5
- data.tar.gz: !binary |-
6
- ZThjNWMzNjVlYWJiNDU0N2M4NTRiYjZiNTJjNjYwNWYwZWFjOTNiZg==
2
+ SHA1:
3
+ metadata.gz: 66212d6809a4fd542e5f769acd327d6332f2f74e
4
+ data.tar.gz: 371f6c137c28d6d7fbc444d29c2ed0de9fb913b3
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- M2RiZTU0OWI0YWNiYzM5YzExZjUxNjBiMDMxNzUwNzcwNzEyMTMxZjIxZDRj
10
- ZDBiMTBiNTNlOWRlYjkwNjM1NjlmOTAzZjJlM2M5NmMxN2Q0ODIxNmM1YzMz
11
- OWNkN2RkYWQyNzI1ZDA5MWJmMDQ0Yjc1NDRlM2UyOGI1MmNiOTE=
12
- data.tar.gz: !binary |-
13
- Y2JkOGUxNDc1Mjk5ZTc1NjUxODYxYTViZWZlODM4Njc2ZmRhMDVkZDJiMWY5
14
- NzY0Mjk0NTM2MTFmYzU5NzQyMjkxYTBkZTA5MTNiNTc2MzRjMDA1ZWVmYmEy
15
- YTAwOWVjMDQ4MjZjZGMyMGY0ZjA4NTBhNzVlMjlhZTMxN2ZiMmE=
6
+ metadata.gz: 5d367ca659c719bc87c7728a32806a5294e1036c824d2b97703881d8af0eb85fe3ea3f7cfc6e1ea49c87d60d1665ae2214075787241dcc438a371e2a9e4026f5
7
+ data.tar.gz: 9f6c413b75ebe4b53ffef6681959136f5710652d9ae138732b17cda63e375b6ee8f8454b8fc9210179e449e126375ed90adf4f6e47e556970180d3f773cfc01b
@@ -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>
@@ -3,8 +3,6 @@ require_relative 'kaf_to_json/server'
3
3
 
4
4
  require 'json'
5
5
  require 'nokogiri'
6
- require 'open3'
7
- require 'optparse'
8
6
 
9
7
 
10
8
 
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class KafToJson
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.required_ruby_version = '>= 1.9.2'
12
12
 
13
13
  gem.files = Dir.glob([
14
+ 'config/*',
14
15
  'lib/**/*',
15
16
  'config.ru',
16
17
  '*.gemspec',
metadata CHANGED
@@ -1,143 +1,143 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-kaf2json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - development@olery.com
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
15
- requirement: !ruby/object:Gem::Requirement
15
+ version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
20
+ requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
- - - ! '>='
22
+ - - '>='
25
23
  - !ruby/object:Gem::Version
26
24
  version: '0'
25
+ prerelease: false
26
+ type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sinatra
29
- requirement: !ruby/object:Gem::Requirement
29
+ version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.4.2
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
37
35
  requirements:
38
36
  - - ~>
39
37
  - !ruby/object:Gem::Version
40
38
  version: 1.4.2
39
+ prerelease: false
40
+ type: :runtime
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
43
48
  requirement: !ruby/object:Gem::Requirement
44
49
  requirements:
45
- - - ! '>='
50
+ - - '>='
46
51
  - !ruby/object:Gem::Version
47
52
  version: '0'
48
- type: :runtime
49
53
  prerelease: false
54
+ type: :runtime
55
+ - !ruby/object:Gem::Dependency
56
+ name: puma
50
57
  version_requirements: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ! '>='
59
+ - - '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: puma
57
62
  requirement: !ruby/object:Gem::Requirement
58
63
  requirements:
59
- - - ! '>='
64
+ - - '>='
60
65
  - !ruby/object:Gem::Version
61
66
  version: '0'
62
- type: :runtime
63
67
  prerelease: false
68
+ type: :runtime
69
+ - !ruby/object:Gem::Dependency
70
+ name: opener-webservice
64
71
  version_requirements: !ruby/object:Gem::Requirement
65
72
  requirements:
66
- - - ! '>='
73
+ - - '>='
67
74
  - !ruby/object:Gem::Version
68
75
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: opener-webservice
71
76
  requirement: !ruby/object:Gem::Requirement
72
77
  requirements:
73
- - - ! '>='
78
+ - - '>='
74
79
  - !ruby/object:Gem::Version
75
80
  version: '0'
76
- type: :runtime
77
81
  prerelease: false
82
+ type: :runtime
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
78
85
  version_requirements: !ruby/object:Gem::Requirement
79
86
  requirements:
80
- - - ! '>='
87
+ - - '>='
81
88
  - !ruby/object:Gem::Version
82
89
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
90
  requirement: !ruby/object:Gem::Requirement
86
91
  requirements:
87
- - - ! '>='
92
+ - - '>='
88
93
  - !ruby/object:Gem::Version
89
94
  version: '0'
90
- type: :development
91
95
  prerelease: false
96
+ type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: cucumber
92
99
  version_requirements: !ruby/object:Gem::Requirement
93
100
  requirements:
94
- - - ! '>='
101
+ - - '>='
95
102
  - !ruby/object:Gem::Version
96
103
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: cucumber
99
104
  requirement: !ruby/object:Gem::Requirement
100
105
  requirements:
101
- - - ! '>='
106
+ - - '>='
102
107
  - !ruby/object:Gem::Version
103
108
  version: '0'
104
- type: :development
105
109
  prerelease: false
110
+ type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
106
113
  version_requirements: !ruby/object:Gem::Requirement
107
114
  requirements:
108
- - - ! '>='
115
+ - - '>='
109
116
  - !ruby/object:Gem::Version
110
117
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: pry
113
118
  requirement: !ruby/object:Gem::Requirement
114
119
  requirements:
115
- - - ! '>='
120
+ - - '>='
116
121
  - !ruby/object:Gem::Version
117
122
  version: '0'
118
- type: :development
119
123
  prerelease: false
124
+ type: :development
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
120
127
  version_requirements: !ruby/object:Gem::Requirement
121
128
  requirements:
122
- - - ! '>='
129
+ - - '>='
123
130
  - !ruby/object:Gem::Version
124
131
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rake
127
132
  requirement: !ruby/object:Gem::Requirement
128
133
  requirements:
129
- - - ! '>='
134
+ - - '>='
130
135
  - !ruby/object:Gem::Version
131
136
  version: '0'
132
- type: :development
133
137
  prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ! '>='
137
- - !ruby/object:Gem::Version
138
- version: '0'
138
+ type: :development
139
139
  description: Converts KAF input into JSON
140
- email:
140
+ email:
141
141
  executables:
142
142
  - kaf2json
143
143
  - kaf2json-server
@@ -148,6 +148,7 @@ files:
148
148
  - bin/kaf2json
149
149
  - bin/kaf2json-server
150
150
  - config.ru
151
+ - config/kaf2json.xsl
151
152
  - lib/opener/kaf_to_json.rb
152
153
  - lib/opener/kaf_to_json/public/markdown.css
153
154
  - lib/opener/kaf_to_json/server.rb
@@ -158,24 +159,24 @@ files:
158
159
  homepage: http://opener-project.github.com/
159
160
  licenses: []
160
161
  metadata: {}
161
- post_install_message:
162
+ post_install_message:
162
163
  rdoc_options: []
163
164
  require_paths:
164
165
  - lib
165
166
  required_ruby_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
- - - ! '>='
168
+ - - '>='
168
169
  - !ruby/object:Gem::Version
169
170
  version: 1.9.2
170
171
  required_rubygems_version: !ruby/object:Gem::Requirement
171
172
  requirements:
172
- - - ! '>='
173
+ - - '>='
173
174
  - !ruby/object:Gem::Version
174
175
  version: '0'
175
176
  requirements: []
176
- rubyforge_project:
177
+ rubyforge_project:
177
178
  rubygems_version: 2.2.2
178
- signing_key:
179
+ signing_key:
179
180
  specification_version: 4
180
181
  summary: Converts KAF input into JSON
181
182
  test_files: []