opener-polarity-tagger 2.1.3

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: 5806b5da96e82286d0132e95e448877d7ec43466
4
+ data.tar.gz: bdfaa274cf5c5b4271622f5f53d1cf78334b5035
5
+ SHA512:
6
+ metadata.gz: 5acef595d1928be9b6579b99e4e1fecca11516ec61aab4e21534bc8e9655ef257c4ecf306febb4bd96ccb1a187446cf14856161b288526976f475d9f13fc7c9d
7
+ data.tar.gz: cd8f33e64e819b98db91aee02b6d4ef5b666801b556fa0366b02f8c05c9aa52217904bc0594a50bc895a61af8205fcda7c2ee93a4fd6a7b923e3141552b1d2e3
data/README.md ADDED
@@ -0,0 +1,144 @@
1
+ Introduction
2
+ ------------
3
+
4
+ This repository contains the code for the OpeNER polarity tagger. This tool tags words in a KAF file with polarity information, which basically is:
5
+
6
+ * Polarity information, which represents positive or negative facts in a certain domain. Good, cheap and clean can be positive words in a hotel domain, while
7
+ bad, expensive and dirty could be negative ones.
8
+ * Sentiment modifiers, which modify the polarity of a surrounding polarity word. For instance very or no are sentiment modifiers
9
+
10
+ The polarity tagger supports the following languages:
11
+
12
+ * Dutch
13
+ * German
14
+ * English
15
+ * French
16
+ * Italian
17
+ * Spanish
18
+
19
+ ### Confused by some terminology?
20
+
21
+ This software is part of a larger collection of natural language processing
22
+ tools known as "the OpeNER project". You can find more information about the
23
+ project at [the OpeNER portal](http://opener-project.github.io). There you can
24
+ also find references to terms like KAF (an XML standard to represent linguistic
25
+ annotations in texts), component, cores, scenario's and pipelines.
26
+
27
+ Quick Use Example
28
+ -----------------
29
+
30
+ Installing the polarity-tagger can be done by executing:
31
+
32
+ gem install opener-polarity-tagger
33
+
34
+ The polarity tagger uses python. So it is advised to run a virtualenv before
35
+ installing the gem.
36
+
37
+ Please bare in mind that all components in OpeNER take KAF as an input and
38
+ output KAF by default.
39
+
40
+ ### Command line interface
41
+
42
+ You should now be able to call the polarity tagger as a regular shell
43
+ command: by its name. Once installed the gem normally sits in your path so you can call it directly from anywhere.
44
+
45
+ This aplication reads a text from standard input in order process it.
46
+
47
+ cat some_kind_of_kaf_file.kaf | polarity-tagger
48
+
49
+
50
+ This will output:
51
+
52
+ ```
53
+ <term lemma="donner" morphofeat="VP3s" pos="V" tid="t119" type="open">
54
+ <span>
55
+ <!--donne-->
56
+ <target id="w119"/>
57
+ </span>
58
+ <sentiment polarity="neutral" resource="General domain lexicon for French . Vicomtech_general_lexicon_french"/>
59
+ </term>
60
+ ```
61
+
62
+ ### Webservices
63
+
64
+ You can launch a webservice by executing:
65
+
66
+ polarity-tagger-server
67
+
68
+ This will launch a mini webserver with the webservice. It defaults to port 9292,
69
+ so you can access it at <http://localhost:9292>.
70
+
71
+ To launch it on a different port provide the `-p [port-number]` option like
72
+ this:
73
+
74
+ polarity-tagger-server -p 1234
75
+
76
+ It then launches at <http://localhost:1234>
77
+
78
+ Documentation on the Webservice is provided by surfing to the urls provided
79
+ above. For more information on how to launch a webservice run the command with
80
+ the ```-h``` option.
81
+
82
+
83
+ ### Daemon
84
+
85
+ Last but not least the polarity tagger comes shipped with a daemon that
86
+ can read jobs (and write) jobs to and from Amazon SQS queues. For more
87
+ information type:
88
+
89
+ polarity-tagger-daemon -h
90
+
91
+
92
+ Description of dependencies
93
+ ---------------------------
94
+
95
+ This component runs best if you run it in an environment suited for OpeNER
96
+ components. You can find an installation guide and helper tools in the [OpeNER installer](https://github.com/opener-project/opener-installer) and an
97
+ [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
98
+
99
+ At least you need the following system setup:
100
+
101
+ ### Depenencies for normal use:
102
+
103
+ * Ruby 1.9.3 or newer
104
+ * Python 2.6 or newer
105
+ * Lxml installed
106
+
107
+ Domain Adaption
108
+ ---------------
109
+
110
+ TODO
111
+
112
+ Language Extension
113
+ ------------------
114
+
115
+ TODO
116
+
117
+ The Core
118
+ --------
119
+
120
+ The component is a fat wrapper around the actual language technology core. You
121
+ can find the core technolies in the ```core/``` folder.
122
+
123
+ Where to go from here
124
+ ---------------------
125
+
126
+ * [Check the project websitere](http://opener-project.github.io)
127
+ * [Checkout the webservice](http://opener.olery.com/polarity-tagger)
128
+
129
+ Report problem/Get help
130
+ -----------------------
131
+
132
+ If you encounter problems, please email <support@opener-project.eu> or leave an
133
+ issue in the [issue tracker](https://github.com/opener-project/polarity-tagger/issues).
134
+
135
+
136
+ Contributing
137
+ ------------
138
+
139
+ 1. Fork it <http://github.com/opener-project/polarity-tagger/fork>
140
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
141
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
142
+ 4. Push to the branch (`git push origin my-new-feature`)
143
+ 5. Create new Pull Request
144
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/opener/polarity_tagger'
4
+
5
+ cli = Opener::PolarityTagger::CLI.new(:args => ARGV)
6
+ cli.run(STDIN.tty? ? nil : STDIN.read)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'opener/daemons'
4
+
5
+ exec_path = File.expand_path('../../exec/polarity-tagger.rb', __FILE__)
6
+
7
+ Opener::Daemons::Controller.new(
8
+ :name => 'polarity-tagger',
9
+ :exec_path => exec_path
10
+ )
@@ -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/polarity_tagger', __FILE__)
2
+ require File.expand_path('../lib/opener/polarity_tagger/server', __FILE__)
3
+
4
+ run Opener::PolarityTagger::Server
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env python
2
+
3
+ ##############################
4
+ # #
5
+ # Polarity tagger for dutch,english and German #
6
+ # 22-jan-2013: added code for reading the language code and create the lexicon
7
+ #
8
+ ##############################
9
+
10
+ __desc='VUA polarity tagger multilanguage'
11
+ __last_edited='21may2014'
12
+ VERSION="1.2"
13
+
14
+
15
+ from collections import defaultdict
16
+ import sys
17
+ import os
18
+ import argparse
19
+ import logging
20
+
21
+ this_folder = os.path.dirname(os.path.realpath(__file__))
22
+
23
+ # This updates the load path to ensure that the local site-packages directory
24
+ # can be used to load packages (e.g. a locally installed copy of lxml).
25
+ sys.path.append(os.path.join(this_folder, 'site-packages/pre_install'))
26
+
27
+
28
+ from lxml import etree
29
+ from VUKafParserPy import KafParser
30
+ from VUSentimentLexicon import LexiconSent, show_lexicons
31
+
32
+ logging.basicConfig(stream=sys.stderr,format='%(asctime)s - %(levelname)s - %(message)s',level=logging.DEBUG)
33
+
34
+
35
+ def calculateOverallPolarity(accPol,numNegators):
36
+ guess='neutral'
37
+
38
+ totalPositive = accPol['positive'] + 2*accPol['positive positive']
39
+ totalNegative = accPol['negative'] + 2*accPol['negative negative'] + numNegators
40
+
41
+ if totalPositive==0 and totalNegative==0: guess='neutral'
42
+ elif totalPositive > totalNegative: guess='positive'
43
+ elif totalPositive < totalNegative: guess='negative'
44
+ elif numNegators>0: guess='negative'
45
+ else: guess='neutral'
46
+
47
+ return guess
48
+
49
+
50
+
51
+ if __name__ == '__main__':
52
+
53
+ terms = []
54
+
55
+ ##CLI options
56
+ argument_parser = argparse.ArgumentParser(description='Tags a text with polarities at lemma level')
57
+ argument_parser.add_argument("--no-time",action="store_false", default=True, dest="my_time_stamp",help="For not including timestamp in header")
58
+ argument_parser.add_argument("--ignore-pos", action="store_true", default=False , dest="ignore_pos", help="Ignore the pos labels")
59
+ argument_parser.add_argument("--show-lexicons", action="store", choices = ('nl','en','de','es','it','fr'), default=None,dest='show_lexicons',help="Show lexicons for the given language and exit")
60
+ argument_parser.add_argument("--lexicon", action="store", default=None, dest="lexicon", help="Lexicon identifier, check with --show-lexicons LANG for options")
61
+ argument_parser.add_argument("--lexicon-path", action="store", default=None, dest="lexicon_path", help="The path of the lexicons")
62
+ argument_parser.add_argument("--silent",dest="silent",action='store_true', help='Turn off debug info')
63
+ argument_parser.add_argument('--version', action='version', version='%(prog)s '+VERSION)
64
+
65
+ arguments = argument_parser.parse_args()
66
+ #############
67
+
68
+ if arguments.show_lexicons is not None:
69
+ show_lexicons(arguments.show_lexicons, arguments.lexicon_path)
70
+ sys.exit(0)
71
+
72
+ logging.basicConfig(stream=sys.stderr,format='%(asctime)s - %(levelname)s - %(message)s',level=logging.DEBUG)
73
+
74
+ if arguments.silent:
75
+ logging.getLogger().setLevel(logging.ERROR)
76
+
77
+
78
+ numNegators = 0
79
+ ## READ the data and create structure for terms
80
+ if not sys.stdin.isatty():
81
+ ## READING FROM A PIPE
82
+ logging.debug('Reading from standard input')
83
+ fic = sys.stdin
84
+ else:
85
+ print>>sys.stderr,'Input stream required.'
86
+ print>>sys.stderr,'Example usage: cat myUTF8file.kaf.xml |',sys.argv[0]
87
+ print>>sys.stderr,sys.argv[0]+' -h for help'
88
+ sys.exit(-1)
89
+
90
+
91
+
92
+
93
+ kafParserObj = KafParser(fic)
94
+
95
+ for term in kafParserObj.getTerms():
96
+ terms.append(term)
97
+
98
+
99
+
100
+ logging.debug('Number of terms loaded '+str(len(terms)))
101
+
102
+
103
+ ## Load lexicons
104
+
105
+ lang = kafParserObj.getLanguage()
106
+ ##lexSent = LexiconSent(lang,'general')
107
+ lexSent = LexiconSent(lang,arguments.lexicon,arguments.lexicon_path) ##Default lexicons
108
+ ################
109
+
110
+
111
+ ## For each term, establish its sentiment polarity
112
+ acc_polarity = defaultdict(int)
113
+
114
+ for term in terms:
115
+ lemma = term.getLemma()
116
+ if lemma!=None:
117
+ lemma = lemma.lower()
118
+
119
+ kaf_pos = term.getPos()
120
+ if arguments.ignore_pos:
121
+ kaf_pos = None
122
+ sentiment_attribs = {}
123
+
124
+ ## POLARITY
125
+ polarity, polarity_pos = lexSent.getPolarity(lemma,kaf_pos)
126
+ if polarity!='unknown':
127
+ sentiment_attribs['polarity']=polarity
128
+
129
+ ## NEGATORS
130
+ if lexSent.isNegator(lemma):
131
+ numNegators+=1
132
+ sentiment_attribs['sentiment_modifier']='shifter'
133
+ polarity_pos=None
134
+
135
+ ## INTENSIFIERS
136
+ if lexSent.isIntensifier(lemma):
137
+ sentiment_attribs['sentiment_modifier']='intensifier'
138
+ polarity_pos=None
139
+
140
+
141
+ if len(sentiment_attribs) != 0:
142
+ sentiment_attribs['resource']=lexSent.getResource()
143
+ kafParserObj.addPolarityToTerm(term.getId(),sentiment_attribs,polarity_pos)
144
+ acc_polarity[polarity]+=1
145
+
146
+ ## Next term
147
+ previousLemma = lemma
148
+
149
+
150
+ kafParserObj.addLinguisticProcessor(__desc,__last_edited+'_'+VERSION,'terms', arguments.my_time_stamp)
151
+ kafParserObj.saveToFile(sys.stdout)
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'opener/daemons'
4
+ require_relative '../lib/opener/polarity_tagger'
5
+
6
+ options = Opener::Daemons::OptParser.parse!(ARGV)
7
+ daemon = Opener::Daemons::Daemon.new(Opener::PolarityTagger, options)
8
+
9
+ daemon.start
data/ext/hack/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rake'
2
+ require_relative 'support'
3
+
4
+ desc 'Verifies the requirements'
5
+ task :requirements do
6
+ verify_requirements
7
+ end
8
+
9
+ task :default => :requirements do
10
+ path = File.join(PYTHON_SITE_PACKAGES, 'pre_install')
11
+
12
+ pip_install(PRE_INSTALL_REQUIREMENTS, path)
13
+ end
@@ -0,0 +1,38 @@
1
+ require 'opener/build-tools'
2
+
3
+ include Opener::BuildTools::Requirements
4
+ include Opener::BuildTools::Python
5
+ include Opener::BuildTools::Files
6
+
7
+ # Directory where packages will be installed to.
8
+ PYTHON_SITE_PACKAGES = File.expand_path(
9
+ '../../../core/site-packages',
10
+ __FILE__
11
+ )
12
+
13
+ # Directory containing the temporary files.
14
+ TMP_DIRECTORY = File.expand_path('../../../tmp', __FILE__)
15
+
16
+ # Path to the pip requirements file used to install requirements before
17
+ # packaging the Gem.
18
+ PRE_BUILD_REQUIREMENTS = File.expand_path(
19
+ '../../../pre_build_requirements.txt',
20
+ __FILE__
21
+ )
22
+
23
+ # Path to the pip requirements file used to install requirements upon Gem
24
+ # installation.
25
+ PRE_INSTALL_REQUIREMENTS = File.expand_path(
26
+ '../../../pre_install_requirements.txt',
27
+ __FILE__
28
+ )
29
+
30
+ ##
31
+ # Verifies the requirements to install thi Gem.
32
+ #
33
+ def verify_requirements
34
+ require_executable('python')
35
+ require_version('python', python_version, '2.6.0')
36
+ require_executable('pip')
37
+ require_version('pip', pip_version, '1.3.1')
38
+ end
@@ -0,0 +1,92 @@
1
+ require 'open3'
2
+
3
+ require_relative 'polarity_tagger/version'
4
+ require_relative 'polarity_tagger/cli'
5
+
6
+ module Opener
7
+ ##
8
+ # Ruby wrapper around the Python based polarity tagger.
9
+ #
10
+ # @!attribute [r] options
11
+ # @return [Hash]
12
+ #
13
+ class PolarityTagger
14
+ attr_reader :options, :args
15
+
16
+ ##
17
+ # @param [Hash] options
18
+ #
19
+ # @option options [Array] :args Collection of arbitrary arguments to pass
20
+ # to the underlying kernel.
21
+ #
22
+ def initialize(options = {})
23
+ @args = options.delete(:args) || []
24
+ @options = options
25
+ end
26
+
27
+ ##
28
+ # Returns a String containing the command to use for executing the kernel.
29
+ #
30
+ # @return [String]
31
+ #
32
+ def command
33
+ return "#{adjust_python_path} python -E -OO #{kernel} #{lexicon_path} #{args.join(" ")}"
34
+ end
35
+
36
+ def lexicon_path
37
+ if path = options[:resource_path]
38
+ return "--lexicon-path #{path}"
39
+ else
40
+ return nil
41
+ end
42
+ end
43
+
44
+ ##
45
+ # Processes the input and returns an Array containing the output of STDOUT,
46
+ # STDERR and an object containing process information.
47
+ #
48
+ # @param [String] input The text of which to detect the language.
49
+ # @return [Array]
50
+ #
51
+ def run(input)
52
+ return capture(input)
53
+ end
54
+
55
+ protected
56
+ ##
57
+ # @return [String]
58
+ #
59
+ def adjust_python_path
60
+ site_packages = File.join(core_dir, 'site-packages')
61
+ "env PYTHONPATH=#{site_packages}:$PYTHONPATH"
62
+ end
63
+
64
+ ##
65
+ # capture3 method doesn't work properly with Jruby, so
66
+ # this is a workaround
67
+ #
68
+ def capture(input)
69
+ Open3.popen3(*command.split(" ")) {|i, o, e, t|
70
+ out_reader = Thread.new { o.read }
71
+ err_reader = Thread.new { e.read }
72
+ i.write input
73
+ i.close
74
+ [out_reader.value, err_reader.value, t.value]
75
+ }
76
+ end
77
+
78
+ ##
79
+ # @return [String]
80
+ #
81
+ def core_dir
82
+ return File.expand_path('../../../core', __FILE__)
83
+ end
84
+
85
+ ##
86
+ # @return [String]
87
+ #
88
+ def kernel
89
+ return File.join(core_dir, 'poltagger-basic-multi.py')
90
+ end
91
+ end # PolarityTagger
92
+ end # Opener
@@ -0,0 +1,86 @@
1
+ require 'opener/core/resource_switcher'
2
+ require 'opener/core/argv_splitter'
3
+
4
+ module Opener
5
+ class PolarityTagger
6
+ ##
7
+ # CLI wrapper around {Opener::LanguageIdentifier} using OptionParser.
8
+ #
9
+ # @!attribute [r] options
10
+ # @return [Hash]
11
+ # @!attribute [r] option_parser
12
+ # @return [OptionParser]
13
+ #
14
+ class CLI
15
+ attr_reader :options, :option_parser, :resource_switcher
16
+
17
+ ##
18
+ # @param [Hash] options
19
+ #
20
+ def initialize(options = {})
21
+ @options = options
22
+
23
+ @resource_switcher = Opener::Core::ResourceSwitcher.new
24
+ component_options, options[:args] = Opener::Core::ArgvSplitter.split(options[:args])
25
+
26
+ @option_parser = OptionParser.new do |opts|
27
+ opts.program_name = 'polarity-tagger'
28
+ opts.summary_indent = ' '
29
+
30
+ resource_switcher.bind(opts, @options)
31
+
32
+ opts.on('-h', '--help', 'Shows this help message') do
33
+ show_help
34
+ end
35
+
36
+ opts.on('-v', '--version', 'Shows the current version') do
37
+ show_version
38
+ end
39
+
40
+ opts.on('-l', '--log', 'Enable logging to STDERR') do
41
+ @options[:logging] = true
42
+ end
43
+ end
44
+
45
+ option_parser.parse!(component_options)
46
+ force = false
47
+ resource_switcher.install(@options, force)
48
+ end
49
+
50
+ ##
51
+ # @param [String] input
52
+ #
53
+ def run(input)
54
+ tagger = PolarityTagger.new(options)
55
+
56
+ stdout, stderr, process = tagger.run(input)
57
+
58
+ if process.success?
59
+ puts stdout
60
+
61
+ if options[:logging] and !stderr.empty?
62
+ STDERR.puts(stderr)
63
+ end
64
+ else
65
+ abort stderr
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ ##
72
+ # Shows the help message and exits the program.
73
+ #
74
+ def show_help
75
+ abort option_parser.to_s
76
+ end
77
+
78
+ ##
79
+ # Shows the version and exits the program.
80
+ #
81
+ def show_version
82
+ abort "#{option_parser.program_name} v#{VERSION} on #{RUBY_DESCRIPTION}"
83
+ end
84
+ end # CLI
85
+ end # PolarityTagger
86
+ end # Opener
@@ -0,0 +1,284 @@
1
+
2
+ input[type="text"], textarea
3
+ {
4
+ width: 500px;
5
+ }
6
+
7
+ body {
8
+ font-family: Helvetica, arial, sans-serif;
9
+ font-size: 14px;
10
+ line-height: 1.6;
11
+ padding-top: 10px;
12
+ padding-bottom: 10px;
13
+ background-color: white;
14
+ padding: 30px; }
15
+
16
+ body > *:first-child {
17
+ margin-top: 0 !important; }
18
+ body > *:last-child {
19
+ margin-bottom: 0 !important; }
20
+
21
+ a {
22
+ color: #4183C4; }
23
+ a.absent {
24
+ color: #cc0000; }
25
+ a.anchor {
26
+ display: block;
27
+ padding-left: 30px;
28
+ margin-left: -30px;
29
+ cursor: pointer;
30
+ position: absolute;
31
+ top: 0;
32
+ left: 0;
33
+ bottom: 0; }
34
+
35
+ h1, h2, h3, h4, h5, h6 {
36
+ margin: 20px 0 10px;
37
+ padding: 0;
38
+ font-weight: bold;
39
+ -webkit-font-smoothing: antialiased;
40
+ cursor: text;
41
+ position: relative; }
42
+
43
+ h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
44
+ background: url("../../images/modules/styleguide/para.png") no-repeat 10px center;
45
+ text-decoration: none; }
46
+
47
+ h1 tt, h1 code {
48
+ font-size: inherit; }
49
+
50
+ h2 tt, h2 code {
51
+ font-size: inherit; }
52
+
53
+ h3 tt, h3 code {
54
+ font-size: inherit; }
55
+
56
+ h4 tt, h4 code {
57
+ font-size: inherit; }
58
+
59
+ h5 tt, h5 code {
60
+ font-size: inherit; }
61
+
62
+ h6 tt, h6 code {
63
+ font-size: inherit; }
64
+
65
+ h1 {
66
+ font-size: 28px;
67
+ color: black; }
68
+
69
+ h2 {
70
+ font-size: 24px;
71
+ border-bottom: 1px solid #cccccc;
72
+ color: black; }
73
+
74
+ h3 {
75
+ font-size: 18px; }
76
+
77
+ h4 {
78
+ font-size: 16px; }
79
+
80
+ h5 {
81
+ font-size: 14px; }
82
+
83
+ h6 {
84
+ color: #777777;
85
+ font-size: 14px; }
86
+
87
+ p, blockquote, ul, ol, dl, li, table, pre {
88
+ margin: 15px 0; }
89
+
90
+ hr {
91
+ background: transparent url("../../images/modules/pulls/dirty-shade.png") repeat-x 0 0;
92
+ border: 0 none;
93
+ color: #cccccc;
94
+ height: 4px;
95
+ padding: 0; }
96
+
97
+ body > h2:first-child {
98
+ margin-top: 0;
99
+ padding-top: 0; }
100
+ body > h1:first-child {
101
+ margin-top: 0;
102
+ padding-top: 0; }
103
+ body > h1:first-child + h2 {
104
+ margin-top: 0;
105
+ padding-top: 0; }
106
+ body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
107
+ margin-top: 0;
108
+ padding-top: 0; }
109
+
110
+ a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
111
+ margin-top: 0;
112
+ padding-top: 0; }
113
+
114
+ h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
115
+ margin-top: 0; }
116
+
117
+ li p.first {
118
+ display: inline-block; }
119
+
120
+ ul, ol {
121
+ padding-left: 30px; }
122
+
123
+ ul :first-child, ol :first-child {
124
+ margin-top: 0; }
125
+
126
+ ul :last-child, ol :last-child {
127
+ margin-bottom: 0; }
128
+
129
+ dl {
130
+ padding: 0; }
131
+ dl dt {
132
+ font-size: 14px;
133
+ font-weight: bold;
134
+ font-style: italic;
135
+ padding: 0;
136
+ margin: 15px 0 5px; }
137
+ dl dt:first-child {
138
+ padding: 0; }
139
+ dl dt > :first-child {
140
+ margin-top: 0; }
141
+ dl dt > :last-child {
142
+ margin-bottom: 0; }
143
+ dl dd {
144
+ margin: 0 0 15px;
145
+ padding: 0 15px; }
146
+ dl dd > :first-child {
147
+ margin-top: 0; }
148
+ dl dd > :last-child {
149
+ margin-bottom: 0; }
150
+
151
+ blockquote {
152
+ border-left: 4px solid #dddddd;
153
+ padding: 0 15px;
154
+ color: #777777; }
155
+ blockquote > :first-child {
156
+ margin-top: 0; }
157
+ blockquote > :last-child {
158
+ margin-bottom: 0; }
159
+
160
+ table {
161
+ padding: 0; }
162
+ table tr {
163
+ border-top: 1px solid #cccccc;
164
+ background-color: white;
165
+ margin: 0;
166
+ padding: 0; }
167
+ table tr:nth-child(2n) {
168
+ background-color: #f8f8f8; }
169
+ table tr th {
170
+ font-weight: bold;
171
+ border: 1px solid #cccccc;
172
+ text-align: left;
173
+ margin: 0;
174
+ padding: 6px 13px; }
175
+ table tr td {
176
+ border: 1px solid #cccccc;
177
+ text-align: left;
178
+ margin: 0;
179
+ padding: 6px 13px; }
180
+ table tr th :first-child, table tr td :first-child {
181
+ margin-top: 0; }
182
+ table tr th :last-child, table tr td :last-child {
183
+ margin-bottom: 0; }
184
+
185
+ img {
186
+ max-width: 100%; }
187
+
188
+ span.frame {
189
+ display: block;
190
+ overflow: hidden; }
191
+ span.frame > span {
192
+ border: 1px solid #dddddd;
193
+ display: block;
194
+ float: left;
195
+ overflow: hidden;
196
+ margin: 13px 0 0;
197
+ padding: 7px;
198
+ width: auto; }
199
+ span.frame span img {
200
+ display: block;
201
+ float: left; }
202
+ span.frame span span {
203
+ clear: both;
204
+ color: #333333;
205
+ display: block;
206
+ padding: 5px 0 0; }
207
+ span.align-center {
208
+ display: block;
209
+ overflow: hidden;
210
+ clear: both; }
211
+ span.align-center > span {
212
+ display: block;
213
+ overflow: hidden;
214
+ margin: 13px auto 0;
215
+ text-align: center; }
216
+ span.align-center span img {
217
+ margin: 0 auto;
218
+ text-align: center; }
219
+ span.align-right {
220
+ display: block;
221
+ overflow: hidden;
222
+ clear: both; }
223
+ span.align-right > span {
224
+ display: block;
225
+ overflow: hidden;
226
+ margin: 13px 0 0;
227
+ text-align: right; }
228
+ span.align-right span img {
229
+ margin: 0;
230
+ text-align: right; }
231
+ span.float-left {
232
+ display: block;
233
+ margin-right: 13px;
234
+ overflow: hidden;
235
+ float: left; }
236
+ span.float-left span {
237
+ margin: 13px 0 0; }
238
+ span.float-right {
239
+ display: block;
240
+ margin-left: 13px;
241
+ overflow: hidden;
242
+ float: right; }
243
+ span.float-right > span {
244
+ display: block;
245
+ overflow: hidden;
246
+ margin: 13px auto 0;
247
+ text-align: right; }
248
+
249
+ code, tt {
250
+ margin: 0 2px;
251
+ padding: 0 5px;
252
+ white-space: nowrap;
253
+ border: 1px solid #eaeaea;
254
+ background-color: #f8f8f8;
255
+ border-radius: 3px; }
256
+
257
+ pre code {
258
+ margin: 0;
259
+ padding: 0;
260
+ white-space: pre;
261
+ border: none;
262
+ background: transparent; }
263
+
264
+ .highlight pre {
265
+ background-color: #f8f8f8;
266
+ border: 1px solid #cccccc;
267
+ font-size: 13px;
268
+ line-height: 19px;
269
+ overflow: auto;
270
+ padding: 6px 10px;
271
+ border-radius: 3px; }
272
+
273
+ pre {
274
+ background-color: #f8f8f8;
275
+ border: 1px solid #cccccc;
276
+ font-size: 13px;
277
+ line-height: 19px;
278
+ overflow: auto;
279
+ padding: 6px 10px;
280
+ border-radius: 3px; }
281
+ pre code, pre tt {
282
+ background-color: transparent;
283
+ border: none; }
284
+
@@ -0,0 +1,16 @@
1
+ require 'sinatra/base'
2
+ require 'httpclient'
3
+ require 'opener/webservice'
4
+
5
+ module Opener
6
+ class PolarityTagger
7
+ ##
8
+ # Polarity tagger server powered by Sinatra.
9
+ #
10
+ class Server < Webservice
11
+ set :views, File.expand_path('../views', __FILE__)
12
+ text_processor PolarityTagger
13
+ accepted_params :input
14
+ end # Server
15
+ end # PolarityTagger
16
+ end # Opener
@@ -0,0 +1,5 @@
1
+ module Opener
2
+ class PolarityTagger
3
+ VERSION = '2.1.3'
4
+ end # PolarityTagger
5
+ end # Opener
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <link type="text/css" rel="stylesheet" charset="UTF-8" href="markdown.css"/>
5
+ <title>Polarity Tagger Webservice</title>
6
+ </head>
7
+ <body>
8
+ <h1>Polarity Tagger Web Service</h1>
9
+
10
+ <h2>Example Usage</h2>
11
+
12
+ <p>
13
+ <pre>polarity-tagger-server start</pre>
14
+ <pre></pre>
15
+ </p>
16
+
17
+ <h2>Try the webservice</h2>
18
+
19
+ <p>* required</p>
20
+ <p>** When entering a value no response will be displayed in the browser.</p>
21
+
22
+ <form action="<%=url("/")%>" method="POST">
23
+ <div>
24
+ <label for="input"/>Type your text here*</label>
25
+ <br/>
26
+
27
+ <textarea name="input" id="text" rows="10" cols="50"/></textarea>
28
+ </div>
29
+
30
+ <% 10.times do |t| %>
31
+ <div>
32
+ <label for="callbacks">Callback URL <%=t+1%>(**)</label>
33
+ <br />
34
+
35
+ <input id="callbacks" type="text" name="callbacks[]" />
36
+ </div>
37
+ <% end %>
38
+
39
+
40
+ <div>
41
+ <label for="error_callback">Error Callback</label>
42
+ <br />
43
+
44
+ <input id="error_callback" type="text" name="error_callback" />
45
+ </div>
46
+ <input type="submit" value="Submit" />
47
+ </form>
48
+
49
+ <h2>Actions</h2>
50
+
51
+ <p>
52
+ <dl>
53
+ <dt>POST /</dt>
54
+ <dd>Tag the input tokenized text. See arguments listing for more options.</dd>
55
+ <dt>GET /</dt>
56
+ <dd>Show this page</dd>
57
+ </dl>
58
+ </p>
59
+
60
+ <h2>Arguments</h2>
61
+
62
+ <p> The webservice takes the following arguments: </p>
63
+ <p>* required</p>
64
+
65
+ <dl>
66
+ <dt>text*</dt>
67
+ <dd>The input text in KAF format. Sample KAF input:</dd>
68
+ <pre></pre>
69
+
70
+ <dt>callbacks</dt>
71
+ <dd>
72
+ You can provide a list of callback urls. If you provide callback urls
73
+ the POS tagger will run as a background job and a callback
74
+ with the results will be performed (POST) to the first url in the callback
75
+ list. The other urls in callback list will be provided in the "callbacks"
76
+ argument.<br/><br/>
77
+ Using callback you can chain together several OpeNER webservices in
78
+ one call. The first, will call the second, which will call the third, etc.
79
+ See for more information the <a href="http://opener-project.github.io">
80
+ webservice documentation online</a>.
81
+ </dd>
82
+ <dt>error_callback</dt>
83
+ <dd>URL to notify if errors occur in the background process. The error
84
+ callback will do a POST with the error message in the 'error' field.</dd>
85
+ </dt>
86
+
87
+
88
+
89
+ </dl>
90
+
91
+
92
+ <p>
93
+
94
+ </p>
95
+
96
+ </body>
97
+ </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>Language Detector 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,39 @@
1
+ require File.expand_path('../lib/opener/polarity_tagger/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'opener-polarity-tagger'
5
+ gem.version = Opener::PolarityTagger::VERSION
6
+ gem.authors = ['development@olery.com']
7
+ gem.summary = 'Polarity tagger for various languages.'
8
+ gem.description = gem.summary
9
+ gem.homepage = 'http://opener-project.github.com/'
10
+ gem.extensions = ['ext/hack/Rakefile']
11
+
12
+ gem.required_ruby_version = '>= 1.9.2'
13
+
14
+ gem.files = Dir.glob([
15
+ 'core/site-packages/pre_build/**/*',
16
+ 'core/*',
17
+ 'ext/**/*',
18
+ 'lib/**/*',
19
+ 'config.ru',
20
+ '*.gemspec',
21
+ '*_requirements.txt',
22
+ 'README.md',
23
+ 'exec/**/*'
24
+ ]).select { |file| File.file?(file) }
25
+
26
+ gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
27
+
28
+ gem.add_dependency 'opener-build-tools', ['>= 1.0.1']
29
+ gem.add_dependency 'rake'
30
+ gem.add_dependency 'sinatra'
31
+ gem.add_dependency 'httpclient'
32
+ gem.add_dependency 'puma'
33
+ gem.add_dependency 'opener-daemons'
34
+ gem.add_dependency 'opener-webservice'
35
+ gem.add_dependency 'opener-core', ['>= 0.1.1']
36
+
37
+ gem.add_development_dependency 'rspec'
38
+ gem.add_development_dependency 'cucumber'
39
+ end
@@ -0,0 +1,2 @@
1
+ git+ssh://git@github.com/opener-project/VU-kaf-parser.git#egg=VUKafParserPy
2
+ git+ssh://git@github.com/opener-project/VU-sentiment-lexicon.git#egg=VUSentimentLexicon
metadata ADDED
@@ -0,0 +1,205 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opener-polarity-tagger
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.3
5
+ platform: ruby
6
+ authors:
7
+ - development@olery.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opener-build-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httpclient
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: puma
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
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: 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-webservice
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
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: opener-core
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: cucumber
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Polarity tagger for various languages.
154
+ email:
155
+ executables:
156
+ - polarity-tagger-server
157
+ - polarity-tagger-daemon
158
+ - polarity-tagger
159
+ extensions:
160
+ - ext/hack/Rakefile
161
+ extra_rdoc_files: []
162
+ files:
163
+ - README.md
164
+ - bin/polarity-tagger
165
+ - bin/polarity-tagger-daemon
166
+ - bin/polarity-tagger-server
167
+ - config.ru
168
+ - core/poltagger-basic-multi.py
169
+ - exec/polarity-tagger.rb
170
+ - ext/hack/Rakefile
171
+ - ext/hack/support.rb
172
+ - lib/opener/polarity_tagger.rb
173
+ - lib/opener/polarity_tagger/cli.rb
174
+ - lib/opener/polarity_tagger/public/markdown.css
175
+ - lib/opener/polarity_tagger/server.rb
176
+ - lib/opener/polarity_tagger/version.rb
177
+ - lib/opener/polarity_tagger/views/index.erb
178
+ - lib/opener/polarity_tagger/views/result.erb
179
+ - opener-polarity-tagger.gemspec
180
+ - pre_install_requirements.txt
181
+ homepage: http://opener-project.github.com/
182
+ licenses: []
183
+ metadata: {}
184
+ post_install_message:
185
+ rdoc_options: []
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: 1.9.2
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ requirements: []
199
+ rubyforge_project:
200
+ rubygems_version: 2.2.2
201
+ signing_key:
202
+ specification_version: 4
203
+ summary: Polarity tagger for various languages.
204
+ test_files: []
205
+ has_rdoc: