sentra 0.1.0

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: 7efc86242cd415505a44f9b1715b24c641e41ec8
4
+ data.tar.gz: c011383f92edaeabd3658656b03b62dd4b4099f8
5
+ SHA512:
6
+ metadata.gz: 9616bc1f01ed65d3c52f3a63c5a863781f724ddabcca65f5e672ca1e0e84d22bfabf5dc41f8e9976712c65cfaa0f1ea03089192bcc8450f457c18de8754297c0
7
+ data.tar.gz: a86228133e52b2facaf6322f128bd426da4d047f56d1c2e691fd8e0765d29561347db95506591add6cea8d6e57abd48c438f1df2655e9bc81f8bf02190320a86
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gem 'sinatra'
3
+ gem 'trinidad'
4
+ gem 'rest_client'
5
+ # Specify your gem's dependencies in sentra.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 kshakirov
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Sentra
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sentra`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'sentra'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install sentra
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to.
32
+
33
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/test*.rb']
7
+ t.verbose = true
8
+ end
data/bin/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require "sentra"
3
+
4
+ run Sentra::SentraService
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sentra"
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
+ puts "Starting work"
14
+
15
+ require "irb"
16
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/sentra/opr.rb ADDED
@@ -0,0 +1,57 @@
1
+ require_relative ENV['OPR_JAR'] + "/opr-nlp-pipeline-jar-with-dependencies.jar"
2
+ require_relative ENV['OPR_JAR']+ "/junixsocket-1.3.jar"
3
+
4
+ module HyperLastic
5
+ include_package "crriskdata.opr.hyperelastic"
6
+ import "crriskdata.opr.hyperelastic"
7
+
8
+ end
9
+
10
+ module OprData
11
+ include_package "crriskdata.opr.data"
12
+ import "crriskdata.opr.data"
13
+
14
+ end
15
+
16
+ module Net
17
+ include_package "java.net"
18
+ import "java.net"
19
+ end
20
+
21
+ module Util
22
+ include_package "java.util"
23
+ import "java.util"
24
+ end
25
+
26
+ module Text
27
+ include_package "java.text"
28
+ import "java.text"
29
+ end
30
+
31
+ module SemanticService
32
+ include_package "crriskdata.opr.nlp.storm.rabbitmq"
33
+ import "crriskdata.opr.nlp.storm.rabbitmq"
34
+
35
+ end
36
+
37
+ module ArticleTools
38
+ class ArticleSerializer
39
+ def initialize
40
+ @simpleFormat = OprData::SimpleFormat.new(OprData::Article)
41
+ end
42
+
43
+ def write_to_xml_string article
44
+
45
+ out = java.io.ByteArrayOutputStream.new()
46
+ @simpleFormat.format(out, article)
47
+ out.close()
48
+ out.toString("UTF-8")
49
+ end
50
+
51
+ def read_from_xml_string str
52
+ java_str = java.lang.String.new(str)
53
+ input = java.io.ByteArrayInputStream.new(java_str.getBytes("UTF-8"))
54
+ @simpleFormat.parse(input)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,35 @@
1
+ require 'csv'
2
+ require 'rest_client'
3
+ require 'json'
4
+ module CSV_MODULE
5
+ class MyCSV
6
+ def initialize filename, scheme=nil
7
+ @filename = filename
8
+ @scheme = scheme
9
+ end
10
+
11
+ def get_queries
12
+ queries = []
13
+ CSV.foreach(@filename, :headers=> true) do |row|
14
+ queries.push(row.to_hash)
15
+ #p row.to_hash
16
+ end
17
+ queries
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ module RestClient2
24
+ include RestClient
25
+
26
+ def self.get(url, headers={}, &block)
27
+ Request.execute(:method => :get, :url => url, :headers => headers,
28
+ :timeout => $timeout, :open_timeout => $open_timeout, &block)
29
+ end
30
+
31
+ def self.post(url, payload, headers={}, &block)
32
+ Request.execute(:method => :post, :url => url, :payload => payload, :headers => headers,
33
+ :timeout => 3000, :open_timeout => 3000, &block)
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module Sentra
2
+ VERSION = "0.1.0"
3
+ end
data/lib/sentra.rb ADDED
@@ -0,0 +1,55 @@
1
+ require "sentra/version"
2
+ require 'sinatra/base'
3
+ require 'sinatra'
4
+ require 'trinidad'
5
+ require 'json'
6
+ require 'sentra/opr'
7
+ require 'sentra/rest_client'
8
+
9
+ module Sentra
10
+ # Your code goes here...
11
+
12
+ puts "Hello, gem "
13
+ class SentraService < Sinatra::Base
14
+ configure do
15
+ set :server, :trinidad
16
+ end
17
+
18
+
19
+ Rack::Utils.key_space_limit = 30000000
20
+
21
+ before do
22
+ content_type :json
23
+ headers 'Access-Control-Allow-Origin' => '*',
24
+ 'Access-Control-Allow-Methods' => ['OPTIONS', 'GET', 'POST', 'PUT'],
25
+ 'Access-Control-Allow-Headers' => ['Origin', 'X-Requested-With', 'Content-Type', 'Accept']
26
+ end
27
+
28
+
29
+ post '/get_sentiments' do
30
+ puts "hello"
31
+ query = request.body.read.to_s
32
+ query = JSON.parse(query)
33
+
34
+ p query['id']
35
+
36
+ article = OprData::Article.new;
37
+ calendar = Util::Calendar.getInstance();
38
+ article.setUrl(Net::URL.new("file://All_losses.csv#1118"));
39
+ article.setDate(calendar.getTime)
40
+ article.setTitle("Ref #1117")
41
+ article.setChannel('GENERAL')
42
+ article.setContent(query['content'])
43
+ #serializer = ArticleTools::ArticleSerializer.new
44
+ # article = serializer.read_from_xml_string(params[:query])
45
+ queue = SemanticService::UnixSocketClient.new()
46
+ queue.writeArticle(article)
47
+ result = queue.readArticle()
48
+
49
+ result
50
+ end
51
+
52
+
53
+ run!
54
+ end
55
+ end
data/sentra.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sentra/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sentra"
8
+ spec.version = Sentra::VERSION
9
+ spec.authors = ["kshakirov"]
10
+ spec.email = ["kirill.shakirov4@gmail.com"]
11
+
12
+ spec.summary = %q{sentra web service}
13
+ spec.description = %q{sentra web service}
14
+ spec.homepage = "https://rubygems.org"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ if spec.respond_to?(:metadata)
23
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
24
+ end
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.9"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "minitest"
29
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sentra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kshakirov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: '1.9'
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '10.0'
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
55
+ description: sentra web service
56
+ email:
57
+ - kirill.shakirov4@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/config.ru
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/sentra.rb
73
+ - lib/sentra/opr.rb
74
+ - lib/sentra/rest_client.rb
75
+ - lib/sentra/version.rb
76
+ - sentra.gemspec
77
+ homepage: https://rubygems.org
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'' to prevent pushes to
82
+ rubygems.org, or delete to allow pushes to any server.'
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.1.9
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: sentra web service
103
+ test_files: []