opener-opinion-detector 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +111 -208
- data/bin/opinion-detector-daemon +10 -0
- data/exec/opinion-detector.rb +9 -0
- data/lib/opener/opinion_detector.rb +1 -1
- data/lib/opener/opinion_detector/cli.rb +9 -9
- data/lib/opener/opinion_detector/version.rb +1 -1
- data/opener-opinion-detector.gemspec +4 -1
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05d2440d3f9d646e1cfa9ca3bd0d38ed74310620
|
4
|
+
data.tar.gz: e62d7f8156727de6cb63040d19c6d4730419e7e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e3fddf177214d3b63e7338bd3aefc7b59f0a87a888dd407195ae2938c886fded5e732e51a9a960a14f6a46998d76e8da83c3485498b572bc0de680e24f3c2f
|
7
|
+
data.tar.gz: cda2cceb291359c7c19676786a86e581c1690e4db6adf217ba8dc3f05f9e86d8063bcc8243fcb52ffdb9ed321d1e376ed0f1c574d2261bb6ffdc6c7003950fde
|
data/README.md
CHANGED
@@ -1,225 +1,128 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
<?xml version='1.0' encoding='UTF-8'?>
|
51
|
-
<KAF xml:lang="en">
|
52
|
-
<kafHeader>
|
53
|
-
<linguisticProcessors layer="text">
|
54
|
-
<lp timestamp="2013-04-11T09:21:29CEST" version="1.0" name="Open-nlp sentence splitter"/>
|
55
|
-
<lp timestamp="2013-04-11T09:21:29CEST" version="1.0" name="Open-nlp tokenizer"/>
|
56
|
-
</linguisticProcessors>
|
57
|
-
<linguisticProcessor layer="terms">
|
58
|
-
<lp timestamp="2013-04-11T09:23:08CEST" version="1.0" name="Basic_polarity_tagger_with_pos"/>
|
59
|
-
</linguisticProcessor>
|
60
|
-
<linguisticProcessor layer="term">
|
61
|
-
<lp timestamp="2013-04-11T09:23:07CEST" version="1.0" name="TreeTagger_from_kaf"/>
|
62
|
-
</linguisticProcessor>
|
63
|
-
</kafHeader>
|
64
|
-
<text>
|
65
|
-
<wf wid="w_1" sent="s_1">This</wf>
|
66
|
-
<wf wid="w_2" sent="s_1">is</wf>
|
67
|
-
<wf wid="w_3" sent="s_1">a</wf>
|
68
|
-
<wf wid="w_4" sent="s_1">very</wf>
|
69
|
-
<wf wid="w_5" sent="s_1">nice</wf>
|
70
|
-
<wf wid="w_6" sent="s_1">hotel</wf>
|
71
|
-
<wf wid="w_7" sent="s_1">in</wf>
|
72
|
-
<wf wid="w_8" sent="s_1">Amsterdam</wf>
|
73
|
-
</text>
|
74
|
-
<terms>
|
75
|
-
<term tid="t_1" lemma="this" morphofeat="DT" type="close" pos="D">
|
76
|
-
<span>
|
77
|
-
<target id="w_1"/>
|
78
|
-
</span>
|
79
|
-
</term>
|
80
|
-
<term tid="t_2" lemma="be" morphofeat="VBZ" type="open" pos="V">
|
81
|
-
<span>
|
82
|
-
<target id="w_2"/>
|
83
|
-
</span>
|
84
|
-
</term>
|
85
|
-
<term tid="t_3" lemma="a" morphofeat="DT" type="close" pos="D">
|
86
|
-
<span>
|
87
|
-
<target id="w_3"/>
|
88
|
-
</span>
|
89
|
-
</term>
|
90
|
-
<term tid="t_4" lemma="very" morphofeat="RB" type="open" pos="A">
|
91
|
-
<span>
|
92
|
-
<target id="w_4"/>
|
93
|
-
</span>
|
94
|
-
<sentiment sentiment_modifier="intensifier" resource="VUA_olery_lexicon_en_lmf"/>
|
95
|
-
</term>
|
96
|
-
<term tid="t_5" lemma="nice" morphofeat="JJ" type="open" pos="G">
|
97
|
-
<span>
|
98
|
-
<target id="w_5"/>
|
99
|
-
</span>
|
100
|
-
<sentiment polarity="positive" resource="VUA_olery_lexicon_en_lmf"/>
|
101
|
-
</term>
|
102
|
-
<term tid="t_6" lemma="hotel" morphofeat="NN" type="open" pos="N">
|
103
|
-
<span>
|
104
|
-
<target id="w_6"/>
|
105
|
-
</span>
|
106
|
-
</term>
|
107
|
-
<term tid="t_7" lemma="in" morphofeat="IN" type="close" pos="P">
|
108
|
-
<span>
|
109
|
-
<target id="w_7"/>
|
110
|
-
</span>
|
111
|
-
</term>
|
112
|
-
<term tid="t_8" lemma="Amsterdam" morphofeat="NP" type="open" pos="R">
|
113
|
-
<span>
|
114
|
-
<target id="w_8"/>
|
115
|
-
</span>
|
116
|
-
</term>
|
117
|
-
</terms>
|
118
|
-
<entities>
|
119
|
-
<entity eid="e15" type="location">
|
120
|
-
<references>
|
121
|
-
<span>
|
122
|
-
<!--Amsterdam -->
|
123
|
-
<target id="t_8" />
|
124
|
-
</span>
|
125
|
-
</references>
|
126
|
-
</entity>
|
127
|
-
</entities>
|
128
|
-
</KAF>
|
129
|
-
|
130
|
-
|
131
|
-
Enjoy!
|
132
|
-
|
133
|
-
## Usage
|
134
|
-
|
135
|
-
Detecting opinion for some text (assuming that the above text is in a file called *english.kaf*):
|
136
|
-
|
137
|
-
cat english.kaf | opinion-detector
|
138
|
-
|
139
|
-
|
140
|
-
Will result in
|
141
|
-
|
142
|
-
<?xml version='1.0' encoding='UTF-8'?>
|
143
|
-
<KAF version="v1.opener" xml:lang="en">
|
144
|
-
<kafHeader>
|
145
|
-
<linguisticProcessors layer="text">
|
146
|
-
<lp name="opennlp-en-tok" timestamp="2013-06-11T13:41:37Z" version="1.0"/>
|
147
|
-
<lp name="opennlp-en-sent" timestamp="2013-06-11T13:41:37Z" version="1.0"/>
|
148
|
-
</linguisticProcessors>
|
149
|
-
<linguisticProcessor layer="term">
|
150
|
-
<lp timestamp="2013-06-12T15:18:03CEST" version="1.0" name="Open nlp pos tagger"/>
|
151
|
-
</linguisticProcessor>
|
152
|
-
</kafHeader>
|
153
|
-
<text>
|
154
|
-
<wf length="4" offset="0" para="1" sent="1" wid="w1">this</wf>
|
155
|
-
<wf length="2" offset="5" para="1" sent="1" wid="w2">is</wf>
|
156
|
-
<wf length="2" offset="8" para="1" sent="1" wid="w3">an</wf>
|
157
|
-
<wf length="7" offset="11" para="1" sent="1" wid="w4">english</wf>
|
158
|
-
<wf length="4" offset="19" para="1" sent="1" wid="w5">text</wf>
|
159
|
-
</text>
|
160
|
-
<terms>
|
161
|
-
<term lemma="this" morphofeat="FM" pos="O" tid="t_1" type="open">
|
162
|
-
<span>
|
163
|
-
<target id="w1"/>
|
164
|
-
</span>
|
165
|
-
</term>
|
166
|
-
<term lemma="is" morphofeat="FM" pos="O" tid="t_2" type="open">
|
167
|
-
<span>
|
168
|
-
<target id="w2"/>
|
169
|
-
</span>
|
170
|
-
</term>
|
171
|
-
<term lemma="an" morphofeat="APPR" pos="P" tid="t_3" type="close">
|
172
|
-
<span>
|
173
|
-
<target id="w3"/>
|
174
|
-
</span>
|
175
|
-
</term>
|
176
|
-
<term lemma="english" morphofeat="FM" pos="O" tid="t_4" type="open">
|
177
|
-
<span>
|
178
|
-
<target id="w4"/>
|
179
|
-
</span>
|
180
|
-
</term>
|
181
|
-
<term lemma="text" morphofeat="FM" pos="O" tid="t_5" type="open">
|
182
|
-
<span>
|
183
|
-
<target id="w5"/>
|
184
|
-
</span>
|
185
|
-
</term>
|
186
|
-
</terms>
|
187
|
-
</KAF>
|
188
|
-
|
189
|
-
## Server
|
190
|
-
|
191
|
-
The Opinion Detector comes equipped with a simple webservice. To start the
|
192
|
-
webservice type:
|
1
|
+
Opinion Detector
|
2
|
+
----------------
|
3
|
+
|
4
|
+
Component that wraps a machine learned Opinion Detector in Python.
|
5
|
+
|
6
|
+
### Confused by some terminology?
|
7
|
+
|
8
|
+
This software is part of a larger collection of natural language processing
|
9
|
+
tools known as "the OpeNER project". You can find more information about the
|
10
|
+
project at [the OpeNER portal](http://opener-project.github.io). There you can
|
11
|
+
also find references to terms like KAF (an XML standard to represent linguistic
|
12
|
+
annotations in texts), component, cores, scenario's and pipelines.
|
13
|
+
|
14
|
+
Quick Use Example
|
15
|
+
-----------------
|
16
|
+
|
17
|
+
Installing the opinion-detector can be done by executing:
|
18
|
+
|
19
|
+
gem install opener-opinion-detector
|
20
|
+
|
21
|
+
Please bare in mind that all components in OpeNER take KAF as an input and
|
22
|
+
output KAF by default.
|
23
|
+
|
24
|
+
### Command line interface
|
25
|
+
|
26
|
+
You should now be able to call the opinion detector as a regular shell
|
27
|
+
command: by its name. Once installed the gem normally sits in your path so you can call it directly from anywhere.
|
28
|
+
|
29
|
+
This application reads a text from standard input in order process it. It needs
|
30
|
+
models to work. There is a free set of models available trained on a news
|
31
|
+
corpus.
|
32
|
+
|
33
|
+
cat englist.kaf | opinion-detector \
|
34
|
+
--resource-path /path/to/models \
|
35
|
+
--resource-url http://opener.s3.amazonaws.com/Models/final_models_news_20140522.zip
|
36
|
+
|
37
|
+
You have to download the models separately. You can download them here:
|
38
|
+
|
39
|
+
|
40
|
+
This will output:
|
41
|
+
|
42
|
+
```
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
### Webservices
|
47
|
+
|
48
|
+
You can launch a webservice by executing:
|
193
49
|
|
194
50
|
opinion-detector-server
|
195
51
|
|
196
52
|
This will launch a mini webserver with the webservice. It defaults to port 9292,
|
197
|
-
so you can access it at:
|
53
|
+
so you can access it at <http://localhost:9292>.
|
198
54
|
|
199
|
-
|
200
|
-
|
201
|
-
To launch it on a different port provide the ```-p [port-number]``` option like
|
55
|
+
To launch it on a different port provide the `-p [port-number]` option like
|
202
56
|
this:
|
203
57
|
|
204
58
|
opinion-detector-server -p 1234
|
205
59
|
|
206
|
-
It then launches at
|
60
|
+
It then launches at <http://localhost:1234>
|
207
61
|
|
208
62
|
Documentation on the Webservice is provided by surfing to the urls provided
|
209
|
-
above.
|
63
|
+
above. For more information on how to launch a webservice run the command with
|
64
|
+
the ```-h``` option.
|
210
65
|
|
211
66
|
|
212
|
-
|
67
|
+
### Daemon
|
213
68
|
|
214
|
-
|
69
|
+
Last but not least the opinion detector comes shipped with a daemon that
|
70
|
+
can read jobs (and write) jobs to and from Amazon SQS queues. For more
|
71
|
+
information type:
|
215
72
|
|
216
|
-
|
217
|
-
2. Create your feature branch (`git checkout -b features/my-new-feature`)
|
218
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
219
|
-
4. Push to the branch (`git push origin features/my-new-feature`)
|
220
|
-
5. If you're confident, merge your changes into master.
|
73
|
+
opinion-detector-daemon -h
|
221
74
|
|
222
|
-
# What's next?
|
223
75
|
|
224
|
-
|
225
|
-
|
76
|
+
Description of dependencies
|
77
|
+
---------------------------
|
78
|
+
|
79
|
+
This component runs best if you run it in an environment suited for OpeNER
|
80
|
+
components. You can find an installation guide and helper tools in the [OpeNER installer](https://github.com/opener-project/opener-installer) and an [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
|
81
|
+
|
82
|
+
At least you need the following system setup:
|
83
|
+
|
84
|
+
### Dependencies for normal use:
|
85
|
+
|
86
|
+
* Ruby 1.9.3 or newer
|
87
|
+
* Python 2.6 or newer
|
88
|
+
* lxml
|
89
|
+
|
90
|
+
Domain Adaption
|
91
|
+
---------------
|
92
|
+
|
93
|
+
TODO
|
94
|
+
|
95
|
+
Language Extension
|
96
|
+
------------------
|
97
|
+
|
98
|
+
TODO
|
99
|
+
|
100
|
+
The Core
|
101
|
+
--------
|
102
|
+
|
103
|
+
The component is a fat wrapper around the actual language technology core. You
|
104
|
+
can find the core technolies in the following repository
|
105
|
+
|
106
|
+
* [opinion-detector-base](https://github.com/opener-project/opinion-detector-base)
|
107
|
+
|
108
|
+
Where to go from here
|
109
|
+
---------------------
|
110
|
+
|
111
|
+
* [Check the project websitere](http://opener-project.github.io)
|
112
|
+
* [Checkout the webservice](http://opener.olery.com/opinion-detector)
|
113
|
+
|
114
|
+
Report problem/Get help
|
115
|
+
-----------------------
|
116
|
+
|
117
|
+
If you encounter problems, please email <support@opener-project.eu> or leave an
|
118
|
+
issue in the [issue tracker](https://github.com/opener-project/opinion-detector/issues).
|
119
|
+
|
120
|
+
|
121
|
+
Contributing
|
122
|
+
------------
|
123
|
+
|
124
|
+
1. Fork it <http://github.com/opener-project/opinion-detector/fork>
|
125
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
126
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
127
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
128
|
+
5. Create new Pull Request
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'opener/core/resource_switcher'
|
2
|
+
|
1
3
|
module Opener
|
2
4
|
class OpinionDetector
|
3
5
|
##
|
@@ -9,18 +11,21 @@ module Opener
|
|
9
11
|
# @return [OptionParser]
|
10
12
|
#
|
11
13
|
class CLI
|
12
|
-
attr_reader :options, :option_parser
|
14
|
+
attr_reader :options, :option_parser, :resource_switcher
|
13
15
|
|
14
16
|
##
|
15
17
|
# @param [Hash] options
|
16
18
|
#
|
17
19
|
def initialize(options = {})
|
18
20
|
@options = DEFAULT_OPTIONS.merge(options)
|
21
|
+
@resource_switcher = Opener::Core::ResourceSwitcher.new
|
19
22
|
|
20
23
|
@option_parser = OptionParser.new do |opts|
|
21
24
|
opts.program_name = 'opinion-detector'
|
22
25
|
opts.summary_indent = ' '
|
23
26
|
|
27
|
+
resource_switcher.bind(opts, @options)
|
28
|
+
|
24
29
|
opts.on('-h', '--help', 'Shows this help message') do
|
25
30
|
show_help
|
26
31
|
end
|
@@ -32,15 +37,10 @@ module Opener
|
|
32
37
|
opts.on('-l', '--log', 'Enables logging to STDERR') do
|
33
38
|
@options[:logging] = true
|
34
39
|
end
|
35
|
-
|
36
|
-
opts.separator <<-EOF
|
37
|
-
|
38
|
-
Examples:
|
39
|
-
|
40
|
-
cat example.kaf | #{opts.program_name}
|
41
|
-
cat example.kaf | #{opts.program_name} -l # Enables logging to STDERR
|
42
|
-
EOF
|
43
40
|
end
|
41
|
+
|
42
|
+
option_parser.parse!(options[:args])
|
43
|
+
resource_switcher.install(@options)
|
44
44
|
end
|
45
45
|
|
46
46
|
##
|
@@ -14,7 +14,8 @@ Gem::Specification.new do |gem|
|
|
14
14
|
'lib/**/*',
|
15
15
|
'config.ru',
|
16
16
|
'*.gemspec',
|
17
|
-
'README.md'
|
17
|
+
'README.md',
|
18
|
+
'exec/**/*'
|
18
19
|
]).select { |file| File.file?(file) }
|
19
20
|
|
20
21
|
gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
|
@@ -24,6 +25,8 @@ Gem::Specification.new do |gem|
|
|
24
25
|
gem.add_dependency 'sinatra', '~>1.4.2'
|
25
26
|
gem.add_dependency 'httpclient'
|
26
27
|
gem.add_dependency 'puma'
|
28
|
+
gem.add_dependency 'opener-daemons'
|
29
|
+
gem.add_dependency 'opener-core', ['>= 0.1.2']
|
27
30
|
gem.add_dependency 'opener-webservice'
|
28
31
|
|
29
32
|
gem.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opener-opinion-detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- development@olery.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opener-opinion-detector-base
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: opener-daemons
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
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: opener-core
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.1.2
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.2
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: opener-webservice
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,13 +183,16 @@ email:
|
|
155
183
|
executables:
|
156
184
|
- opinion-detector-server
|
157
185
|
- opinion-detector
|
186
|
+
- opinion-detector-daemon
|
158
187
|
extensions: []
|
159
188
|
extra_rdoc_files: []
|
160
189
|
files:
|
161
190
|
- README.md
|
162
191
|
- bin/opinion-detector
|
192
|
+
- bin/opinion-detector-daemon
|
163
193
|
- bin/opinion-detector-server
|
164
194
|
- config.ru
|
195
|
+
- exec/opinion-detector.rb
|
165
196
|
- lib/opener/opinion_detector.rb
|
166
197
|
- lib/opener/opinion_detector/cli.rb
|
167
198
|
- lib/opener/opinion_detector/public/markdown.css
|