opener-opinion-detector 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05d2440d3f9d646e1cfa9ca3bd0d38ed74310620
4
- data.tar.gz: e62d7f8156727de6cb63040d19c6d4730419e7e5
3
+ metadata.gz: 308a21347b8aa4e28890b619e3ef76ae0ae8ddb5
4
+ data.tar.gz: 4cda0fd31a9050f345eca7b9ac33da21d03f5286
5
5
  SHA512:
6
- metadata.gz: d4e3fddf177214d3b63e7338bd3aefc7b59f0a87a888dd407195ae2938c886fded5e732e51a9a960a14f6a46998d76e8da83c3485498b572bc0de680e24f3c2f
7
- data.tar.gz: cda2cceb291359c7c19676786a86e581c1690e4db6adf217ba8dc3f05f9e86d8063bcc8243fcb52ffdb9ed321d1e376ed0f1c574d2261bb6ffdc6c7003950fde
6
+ metadata.gz: 453cd80301f4b713ed39f181c206cbcd748e13cb8a4878a062d0be0d2457b7ccc35cde5e8238b57becdbbc936483b94460d4d74e8f38eb73f01223ff0172a119
7
+ data.tar.gz: e191424cfb9bfaff6aff3ad457890328ce9df757f441b5f7a60afd094c5ecaeca9e521a07fdee3887298a9a69162de09bef4750edc6c5ab21f1489a033474840
data/README.md CHANGED
@@ -5,11 +5,7 @@ Component that wraps a machine learned Opinion Detector in Python.
5
5
 
6
6
  ### Confused by some terminology?
7
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.
8
+ This software is part of a larger collection of natural language processing tools known as "the OpeNER project". You can find more information about the project at [the OpeNER portal](http://opener-project.github.io). There you can also find references to terms like KAF (an XML standard to represent linguistic annotations in texts), component, cores, scenario's and pipelines.
13
9
 
14
10
  Quick Use Example
15
11
  -----------------
@@ -18,17 +14,13 @@ Installing the opinion-detector can be done by executing:
18
14
 
19
15
  gem install opener-opinion-detector
20
16
 
21
- Please bare in mind that all components in OpeNER take KAF as an input and
22
- output KAF by default.
17
+ Please bare in mind that all components in OpeNER take KAF as an input and output KAF by default.
23
18
 
24
19
  ### Command line interface
25
20
 
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.
21
+ You should now be able to call the opinion detector as a regular shell command: by its name. Once installed the gem normally sits in your path so you can call it directly from anywhere.
28
22
 
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.
23
+ This application reads a text from standard input in order process it. It needs models to work. There is a free set of models available trained on a news corpus.
32
24
 
33
25
  cat englist.kaf | opinion-detector \
34
26
  --resource-path /path/to/models \
@@ -36,7 +28,6 @@ corpus.
36
28
 
37
29
  You have to download the models separately. You can download them here:
38
30
 
39
-
40
31
  This will output:
41
32
 
42
33
  ```
@@ -49,26 +40,20 @@ You can launch a webservice by executing:
49
40
 
50
41
  opinion-detector-server
51
42
 
52
- This will launch a mini webserver with the webservice. It defaults to port 9292,
53
- so you can access it at <http://localhost:9292>.
43
+ This will launch a mini webserver with the webservice. It defaults to port 9292, so you can access it at <http://localhost:9292>.
54
44
 
55
- To launch it on a different port provide the `-p [port-number]` option like
56
- this:
45
+ To launch it on a different port provide the `-p [port-number]` option like this:
57
46
 
58
47
  opinion-detector-server -p 1234
59
48
 
60
49
  It then launches at <http://localhost:1234>
61
50
 
62
- Documentation on the Webservice is provided by surfing to the urls provided
63
- above. For more information on how to launch a webservice run the command with
64
- the ```-h``` option.
51
+ Documentation on the Webservice is provided by surfing to the urls provided above. For more information on how to launch a webservice run the command with the ```-h``` option.
65
52
 
66
53
 
67
54
  ### Daemon
68
55
 
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:
56
+ Last but not least the opinion detector comes shipped with a daemon that can read jobs (and write) jobs to and from Amazon SQS queues. For more information type:
72
57
 
73
58
  opinion-detector-daemon -h
74
59
 
@@ -76,8 +61,7 @@ information type:
76
61
  Description of dependencies
77
62
  ---------------------------
78
63
 
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)
64
+ This component runs best if you run it in an environment suited for OpeNER 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
65
 
82
66
  At least you need the following system setup:
83
67
 
@@ -100,8 +84,7 @@ Language Extension
100
84
  The Core
101
85
  --------
102
86
 
103
- The component is a fat wrapper around the actual language technology core. You
104
- can find the core technolies in the following repository
87
+ The component is a fat wrapper around the actual language technology core. You can find the core technolies in the following repository
105
88
 
106
89
  * [opinion-detector-base](https://github.com/opener-project/opinion-detector-base)
107
90
 
@@ -114,8 +97,8 @@ Where to go from here
114
97
  Report problem/Get help
115
98
  -----------------------
116
99
 
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).
100
+ If you encounter problems, please email <support@opener-project.eu> or leave an issue in the
101
+ [issue tracker](https://github.com/opener-project/opinion-detector/issues).
119
102
 
120
103
 
121
104
  Contributing
@@ -1,8 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'puma/cli'
4
+ require 'optparse'
5
+ require 'opener/core/resource_switcher'
4
6
 
5
- rack_config = File.expand_path('../../config.ru', __FILE__)
7
+ # Puma sadly does not provide a system that allows us to cleanly inject custom
8
+ # options into their CLI. At the same time Puma doesn't provide an easy system
9
+ # of starting it *without* using the `Puma::CLI` class.
10
+ #
11
+ # To work around these problems we create our own parser and ignore any invalid
12
+ # option errors it throws up. This parser is used to handle options for the
13
+ # resource switcher.
6
14
 
7
- cli = Puma::CLI.new([rack_config] + ARGV)
8
- cli.run
15
+ rack_config = File.expand_path('../../config.ru', __FILE__)
16
+ switcher = Opener::Core::ResourceSwitcher.new
17
+ switcher_opts = {}
18
+ show_help = false
19
+
20
+ parser = OptionParser.new do |opts|
21
+ opts.banner = "Usage: #{File.basename($0)} [OPTIONS]"
22
+
23
+ opts.separator "\nOptions:\n"
24
+
25
+ # Don't abort in this block as we otherwise can't show Puma's help message.
26
+ opts.on('-h', '--help', 'Shows this help message') do
27
+ show_help = true
28
+
29
+ puts parser
30
+ end
31
+
32
+ switcher.bind(opts, switcher_opts)
33
+
34
+ opts.separator "\nPuma Usage:\n\n"
35
+ end
36
+
37
+ begin
38
+ # Parse destructively so that Puma doesn't break on our custom options.
39
+ parser.parse!(ARGV)
40
+ rescue OptionParser::InvalidOption
41
+ # Catch errors generated by Puma options and ignore them.
42
+ end
43
+
44
+ # Trigger the Puma help message since we overwrite this option and parse
45
+ # destructively.
46
+ if show_help
47
+ ARGV << '--help'
48
+ end
49
+
50
+ switcher.install(switcher_opts)
51
+
52
+ Puma::CLI.new([rack_config] + ARGV).run
@@ -1,9 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'opener/daemons'
4
+ require 'opener/core/resource_switcher'
5
+
4
6
  require_relative '../lib/opener/opinion_detector'
5
7
 
6
- options = Opener::Daemons::OptParser.parse!(ARGV)
8
+ switcher = Opener::Core::ResourceSwitcher.new
9
+ switcher_opts = {}
10
+
11
+ parser = Opener::Daemons::OptParser.new do |opts|
12
+ switcher.bind(opts, switcher_opts)
13
+ end
14
+
15
+ options = parser.parse!(ARGV)
7
16
  daemon = Opener::Daemons::Daemon.new(Opener::OpinionDetector, options)
8
17
 
9
- daemon.start
18
+ switcher.install(switcher_opts)
19
+ daemon.start
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class OpinionDetector
3
- VERSION = "1.0.3"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-opinion-detector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - development@olery.com