stanford_corenlp_xml_adapter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +25 -0
- data/.gitignore +63 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Dockerfile +21 -0
- data/Gemfile +6 -0
- data/Guardfile +82 -0
- data/LICENSE +21 -0
- data/README.md +207 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/docker-web-dev +1 -0
- data/bin/docker-web-dev-bash +1 -0
- data/bin/docker-web-dev-guard +1 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +24 -0
- data/docker-entrypoint.sh +8 -0
- data/lib/stanford_corenlp_xml_adapter.rb +35 -0
- data/lib/stanford_corenlp_xml_adapter/nokogiri_mixins.rb +25 -0
- data/lib/stanford_corenlp_xml_adapter/version.rb +3 -0
- data/stanford_corenlp_xml_adapter.gemspec +32 -0
- metadata +190 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d6656655d80da112c54ff784c96fba02aac24f8b
|
4
|
+
data.tar.gz: 9b213f477670f597b1c1b4eea8c9fadf036491fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd0c3d1f030a7f3eb38c6b13a566106d2953203f0548d4ac57e41d576a592c58ecdf00ba885d546448fb719937b89fdc0f8a5946c2aae6f4b933aebbf983d847
|
7
|
+
data.tar.gz: 2db9102c1e9588f11f286f9c11a9521ce401ba6f3e2322025697142fbb161c9a86fb2ba59bf41b42904d8930eb82ac83e5c8758848105611c9ecd24849645b2a
|
data/.dockerignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#Ignore bundler config.
|
2
|
+
/.bundle
|
3
|
+
|
4
|
+
/log/*
|
5
|
+
/tmp/*
|
6
|
+
|
7
|
+
# Ignore .idea files
|
8
|
+
.idea/
|
9
|
+
|
10
|
+
# Ignore Byebug command history file.
|
11
|
+
.byebug_history
|
12
|
+
|
13
|
+
.ruby-gemset
|
14
|
+
node_modules
|
15
|
+
|
16
|
+
public/dist/*.json
|
17
|
+
|
18
|
+
public/dist/js/*.js
|
19
|
+
public/dist/js/*.map
|
20
|
+
|
21
|
+
public/dist/css/*.css
|
22
|
+
public/dist/css/*.map
|
23
|
+
vendor/cache
|
24
|
+
|
25
|
+
.env
|
data/.gitignore
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
|
52
|
+
/.bundle/
|
53
|
+
/.yardoc
|
54
|
+
/Gemfile.lock
|
55
|
+
/_yardoc/
|
56
|
+
/coverage/
|
57
|
+
/doc/
|
58
|
+
/pkg/
|
59
|
+
/spec/reports/
|
60
|
+
/tmp/
|
61
|
+
|
62
|
+
# rspec failure tracking
|
63
|
+
.rspec_status
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
FROM ruby:2.3.4
|
2
|
+
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
|
3
|
+
# for nokogiri
|
4
|
+
RUN apt-get install -y libxml2-dev libxslt1-dev
|
5
|
+
# for capybara-webkit
|
6
|
+
#RUN apt-get install -y libqt4-webkit libqt4-dev xvfb
|
7
|
+
RUN mkdir -p /app
|
8
|
+
WORKDIR /app
|
9
|
+
COPY . ./
|
10
|
+
COPY ./docker-entrypoint.sh /
|
11
|
+
RUN chmod +x /docker-entrypoint.sh
|
12
|
+
ENTRYPOINT ["/docker-entrypoint.sh"]
|
13
|
+
ENV BUNDLE_PATH=/bundle \
|
14
|
+
BUNDLE_BIN=/bundle/bin \
|
15
|
+
GEM_HOME=/bundle
|
16
|
+
ENV PATH="${BUNDLE_BIN}:${PATH}"
|
17
|
+
ARG RAILS_ENV=development
|
18
|
+
ENV RAILS_ENV $RAILS_ENV
|
19
|
+
#RUN if [ "$RAILS_ENV" = "production" ] ; then echo "production env" && gem install bundler && bundle install --without development test development_scraper production_scraper ; else echo "non-production env $RAILS_ENV" && gem install bundler && bundle install --without development_scraper production_scraper ; fi
|
20
|
+
#EXPOSE 3000
|
21
|
+
#CMD ["rails", "server", "-b", "0.0.0.0"]
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
#directories %w(lib lib/scraypa/ lib/scraypa/eye/ spec) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
=begin
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
# Feel free to open issues for suggestions and improvements
|
31
|
+
# RSpec files
|
32
|
+
rspec = dsl.rspec
|
33
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
34
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
35
|
+
watch(rspec.spec_files)
|
36
|
+
# Ruby files
|
37
|
+
ruby = dsl.ruby
|
38
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
39
|
+
# Rails files
|
40
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
41
|
+
dsl.watch_spec_files_for(rails.app_files)
|
42
|
+
dsl.watch_spec_files_for(rails.views)
|
43
|
+
watch(rails.controllers) do |m|
|
44
|
+
[
|
45
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
46
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
47
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
48
|
+
]
|
49
|
+
end
|
50
|
+
# Rails config changes
|
51
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
52
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
53
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
54
|
+
# Capybara features specs
|
55
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
56
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
57
|
+
# Turnip features and steps
|
58
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
59
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
60
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
=end
|
64
|
+
|
65
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
66
|
+
require "guard/rspec/dsl"
|
67
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
68
|
+
|
69
|
+
# RSpec files
|
70
|
+
rspec = dsl.rspec
|
71
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
72
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
73
|
+
watch(rspec.spec_files)
|
74
|
+
|
75
|
+
# Ruby files
|
76
|
+
ruby = dsl.ruby
|
77
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
78
|
+
|
79
|
+
#watch(%r{^spec/.+_spec\.rb$})
|
80
|
+
#watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
81
|
+
#watch('spec/spec_helper.rb') { "spec" }
|
82
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Josh Weir
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
# stanford-corenlp-xml-adapter
|
2
|
+
Nokogiri based Ruby adapter to the output returned by Stanford CoreNLP XML Server.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'stanford_corenlp_xml_adapter'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install stanford_corenlp_xml_adapter
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Stanford CoreNLP XML Server output:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
xml_str =
|
26
|
+
%{<?xml version="1.0" encoding="UTF-8"?>
|
27
|
+
<?xml-stylesheet href="CoreNLP-to-HTML.xsl" type="text/xsl"?>
|
28
|
+
<root>
|
29
|
+
<document>
|
30
|
+
<sentences>
|
31
|
+
<sentence id="1" sentimentValue="2" sentiment="Neutral">
|
32
|
+
<tokens>
|
33
|
+
<token id="1">
|
34
|
+
<word>Hello</word>
|
35
|
+
<lemma>hello</lemma>
|
36
|
+
<CharacterOffsetBegin>0</CharacterOffsetBegin>
|
37
|
+
<CharacterOffsetEnd>5</CharacterOffsetEnd>
|
38
|
+
<POS>UH</POS>
|
39
|
+
<NER>O</NER>
|
40
|
+
<Speaker>PER0</Speaker>
|
41
|
+
</token>
|
42
|
+
<token id="2">
|
43
|
+
<word>world</word>
|
44
|
+
<lemma>world</lemma>
|
45
|
+
<CharacterOffsetBegin>6</CharacterOffsetBegin>
|
46
|
+
<CharacterOffsetEnd>11</CharacterOffsetEnd>
|
47
|
+
<POS>NN</POS>
|
48
|
+
<NER>O</NER>
|
49
|
+
<Speaker>PER0</Speaker>
|
50
|
+
</token>
|
51
|
+
<token id="3">
|
52
|
+
<word>!</word>
|
53
|
+
<lemma>!</lemma>
|
54
|
+
<CharacterOffsetBegin>11</CharacterOffsetBegin>
|
55
|
+
<CharacterOffsetEnd>12</CharacterOffsetEnd>
|
56
|
+
<POS>.</POS>
|
57
|
+
<NER>O</NER>
|
58
|
+
<Speaker>PER0</Speaker>
|
59
|
+
</token>
|
60
|
+
</tokens>
|
61
|
+
<parse>(ROOT (S (VP (NP (INTJ (UH Hello)) (NP (NN world)))) (. !))) </parse>
|
62
|
+
<dependencies type="basic-dependencies">
|
63
|
+
<dep type="root">
|
64
|
+
<governor idx="0">ROOT</governor>
|
65
|
+
<dependent idx="2">world</dependent>
|
66
|
+
</dep>
|
67
|
+
<dep type="discourse">
|
68
|
+
<governor idx="2">world</governor>
|
69
|
+
<dependent idx="1">Hello</dependent>
|
70
|
+
</dep>
|
71
|
+
</dependencies>
|
72
|
+
<dependencies type="collapsed-dependencies">
|
73
|
+
<dep type="root">
|
74
|
+
<governor idx="0">ROOT</governor>
|
75
|
+
<dependent idx="2">world</dependent>
|
76
|
+
</dep>
|
77
|
+
<dep type="discourse">
|
78
|
+
<governor idx="2">world</governor>
|
79
|
+
<dependent idx="1">Hello</dependent>
|
80
|
+
</dep>
|
81
|
+
</dependencies>
|
82
|
+
<dependencies type="collapsed-ccprocessed-dependencies">
|
83
|
+
<dep type="root">
|
84
|
+
<governor idx="0">ROOT</governor>
|
85
|
+
<dependent idx="2">world</dependent>
|
86
|
+
</dep>
|
87
|
+
<dep type="discourse">
|
88
|
+
<governor idx="2">world</governor>
|
89
|
+
<dependent idx="1">Hello</dependent>
|
90
|
+
</dep>
|
91
|
+
</dependencies>
|
92
|
+
</sentence>
|
93
|
+
<sentence id="2" sentimentValue="2" sentiment="Neutral">
|
94
|
+
<tokens>
|
95
|
+
<token id="4">
|
96
|
+
<word>I</word>
|
97
|
+
<lemma>I</lemma>
|
98
|
+
<POS>UH</POS>
|
99
|
+
<NER>O</NER>
|
100
|
+
<Speaker>PER0</Speaker>
|
101
|
+
</token>
|
102
|
+
<token id="5">
|
103
|
+
<word>am</word>
|
104
|
+
<lemma>am</lemma>
|
105
|
+
<POS>NN</POS>
|
106
|
+
<NER>O</NER>
|
107
|
+
<Speaker>PER0</Speaker>
|
108
|
+
</token>
|
109
|
+
<token id="6">
|
110
|
+
<word>Josh</word>
|
111
|
+
<lemma>josh</lemma>
|
112
|
+
<POS>NN</POS>
|
113
|
+
<NER>O</NER>
|
114
|
+
<Speaker>PER0</Speaker>
|
115
|
+
</token>
|
116
|
+
<token id="7">
|
117
|
+
<word>.</word>
|
118
|
+
<lemma>.</lemma>
|
119
|
+
<POS>.</POS>
|
120
|
+
<NER>O</NER>
|
121
|
+
<Speaker>PER0</Speaker>
|
122
|
+
</token>
|
123
|
+
</tokens>
|
124
|
+
<parse>(ROOT (S (VP (NP (INTJ (UH Hello)) (NP (NN world)))) (. !))) </parse>
|
125
|
+
<dependencies type="basic-dependencies">
|
126
|
+
<dep type="root">
|
127
|
+
<governor idx="0">ROOT</governor>
|
128
|
+
<dependent idx="2">world</dependent>
|
129
|
+
</dep>
|
130
|
+
<dep type="discourse">
|
131
|
+
<governor idx="2">world</governor>
|
132
|
+
<dependent idx="1">Hello</dependent>
|
133
|
+
</dep>
|
134
|
+
</dependencies>
|
135
|
+
<dependencies type="collapsed-dependencies">
|
136
|
+
<dep type="root">
|
137
|
+
<governor idx="0">ROOT</governor>
|
138
|
+
<dependent idx="2">world</dependent>
|
139
|
+
</dep>
|
140
|
+
<dep type="discourse">
|
141
|
+
<governor idx="2">world</governor>
|
142
|
+
<dependent idx="1">Hello</dependent>
|
143
|
+
</dep>
|
144
|
+
</dependencies>
|
145
|
+
<dependencies type="collapsed-ccprocessed-dependencies">
|
146
|
+
<dep type="root">
|
147
|
+
<governor idx="0">ROOT</governor>
|
148
|
+
<dependent idx="2">world</dependent>
|
149
|
+
</dep>
|
150
|
+
<dep type="discourse">
|
151
|
+
<governor idx="2">world</governor>
|
152
|
+
<dependent idx="1">Hello</dependent>
|
153
|
+
</dep>
|
154
|
+
</dependencies>
|
155
|
+
</sentence>
|
156
|
+
</sentences>
|
157
|
+
</document>
|
158
|
+
</root>}
|
159
|
+
```
|
160
|
+
|
161
|
+
Retrieve the doc as a Nokogiri object:
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
doc = StanfordCorenlpXmlAdapter.doc xml_str
|
165
|
+
```
|
166
|
+
|
167
|
+
Search the `doc`:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
#doc sentences
|
171
|
+
doc.sentences
|
172
|
+
|
173
|
+
#doc tokens
|
174
|
+
doc.tokens
|
175
|
+
|
176
|
+
#tokens within a particular sentence
|
177
|
+
tokens = doc.sentences[1].tokens
|
178
|
+
|
179
|
+
#token word
|
180
|
+
tokens[0]._word
|
181
|
+
#token part-of-speech
|
182
|
+
tokens[0].pos
|
183
|
+
#token ner
|
184
|
+
tokens[0].ner
|
185
|
+
|
186
|
+
#token words within a partiuclar sentence
|
187
|
+
doc.sentences[1]._words
|
188
|
+
|
189
|
+
#doc can be used as a nokogiri object
|
190
|
+
doc.sentences.map{|s|
|
191
|
+
s.xpath("tokens//token//word").map(&:text).join(' ')
|
192
|
+
}
|
193
|
+
```
|
194
|
+
|
195
|
+
## Development
|
196
|
+
|
197
|
+
After checking out the repo, create a docker volume for bundle cache `docker volume create --name bundle_cache` then run `bin/docker-web-dev` to auto install dependencies that are not yet installed and drop you into shell. Then, run `rspec` to run the tests. To run guard: `bin/docker-web-dev-guard`.
|
198
|
+
|
199
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
200
|
+
|
201
|
+
## Contributing
|
202
|
+
|
203
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joshweir/stanford_corenlp_xml_adapter.
|
204
|
+
|
205
|
+
## License
|
206
|
+
|
207
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "stanford_corenlp_xml_adapter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/docker-web-dev
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
docker-compose run --rm --service-ports web
|
@@ -0,0 +1 @@
|
|
1
|
+
docker-compose run --rm --service-ports web /bin/bash
|
@@ -0,0 +1 @@
|
|
1
|
+
docker-compose run --rm --service-ports web guard
|
data/bin/setup
ADDED
data/docker-compose.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
version: '3.1'
|
2
|
+
services:
|
3
|
+
web:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
dockerfile: Dockerfile
|
7
|
+
args:
|
8
|
+
- RAILS_ENV=${RAILS_ENV:-development}
|
9
|
+
command: bash #bash -c "rm -f /app/tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
|
10
|
+
restart: always
|
11
|
+
volumes:
|
12
|
+
- .:/app
|
13
|
+
- bundle_cache:/bundle
|
14
|
+
stdin_open: true
|
15
|
+
tty: true
|
16
|
+
#ports:
|
17
|
+
# - "3000:3000"
|
18
|
+
#depends_on:
|
19
|
+
# - db
|
20
|
+
environment:
|
21
|
+
- RAILS_ENV=${RAILS_ENV:-development}
|
22
|
+
volumes:
|
23
|
+
bundle_cache:
|
24
|
+
external: true
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "stanford_corenlp_xml_adapter/version"
|
2
|
+
require "stanford_corenlp_xml_adapter/nokogiri_mixins"
|
3
|
+
require "nokogiri"
|
4
|
+
|
5
|
+
class Nokogiri::XML::Document
|
6
|
+
include NokogiriMixins
|
7
|
+
end
|
8
|
+
|
9
|
+
class Nokogiri::XML::Element
|
10
|
+
include NokogiriMixins
|
11
|
+
end
|
12
|
+
|
13
|
+
module StanfordCorenlpXmlAdapter
|
14
|
+
class InvalidXML < StandardError; end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def doc doc
|
18
|
+
begin
|
19
|
+
doc = Nokogiri::XML(doc) {|config| config.strict}
|
20
|
+
rescue Nokogiri::XML::SyntaxError => e
|
21
|
+
raise InvalidXML, "#{e.message} xml: #{doc}"
|
22
|
+
end
|
23
|
+
raise InvalidXML,
|
24
|
+
"document node does not exist! xml: #{doc}" unless
|
25
|
+
document_node_exists?(doc)
|
26
|
+
doc
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def document_node_exists? doc
|
32
|
+
doc.xpath("//root//document").length > 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module NokogiriMixins
|
2
|
+
def sentences
|
3
|
+
self.xpath("//sentences//sentence")
|
4
|
+
end
|
5
|
+
|
6
|
+
def tokens
|
7
|
+
self.xpath(".//tokens//token")
|
8
|
+
end
|
9
|
+
|
10
|
+
def _words
|
11
|
+
self.xpath(".//word")
|
12
|
+
end
|
13
|
+
|
14
|
+
def _word
|
15
|
+
self.at_xpath(".//word")
|
16
|
+
end
|
17
|
+
|
18
|
+
def pos
|
19
|
+
self.at_xpath(".//POS")
|
20
|
+
end
|
21
|
+
|
22
|
+
def ner
|
23
|
+
self.at_xpath(".//NER")
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "stanford_corenlp_xml_adapter/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stanford_corenlp_xml_adapter"
|
8
|
+
spec.version = StanfordCorenlpXmlAdapter::VERSION
|
9
|
+
spec.authors = ["joshweir"]
|
10
|
+
#spec.email = [""]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby adapter to the output returned by Stanford CoreNLP XML Server.}
|
13
|
+
spec.homepage = "https://github.com/joshweir/stanford-corenlp-xml-adapter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.15" #"~> 1.14"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "rspec-rails", "~> 3.5"
|
27
|
+
spec.add_development_dependency "gem-release"
|
28
|
+
spec.add_development_dependency "rb-fsevent"
|
29
|
+
spec.add_development_dependency "guard-rspec"
|
30
|
+
spec.add_dependency "activesupport"
|
31
|
+
spec.add_dependency "nokogiri"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stanford_corenlp_xml_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- joshweir
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gem-release
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
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: rb-fsevent
|
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: guard-rspec
|
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: activesupport
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
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: nokogiri
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
executables: []
|
142
|
+
extensions: []
|
143
|
+
extra_rdoc_files: []
|
144
|
+
files:
|
145
|
+
- ".dockerignore"
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".travis.yml"
|
149
|
+
- Dockerfile
|
150
|
+
- Gemfile
|
151
|
+
- Guardfile
|
152
|
+
- LICENSE
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- bin/console
|
156
|
+
- bin/docker-web-dev
|
157
|
+
- bin/docker-web-dev-bash
|
158
|
+
- bin/docker-web-dev-guard
|
159
|
+
- bin/setup
|
160
|
+
- docker-compose.yml
|
161
|
+
- docker-entrypoint.sh
|
162
|
+
- lib/stanford_corenlp_xml_adapter.rb
|
163
|
+
- lib/stanford_corenlp_xml_adapter/nokogiri_mixins.rb
|
164
|
+
- lib/stanford_corenlp_xml_adapter/version.rb
|
165
|
+
- stanford_corenlp_xml_adapter.gemspec
|
166
|
+
homepage: https://github.com/joshweir/stanford-corenlp-xml-adapter
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.6.13
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: Ruby adapter to the output returned by Stanford CoreNLP XML Server.
|
190
|
+
test_files: []
|