calculations 0.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/calculations.rb +66 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: db2d46e0769cd4d87f1403b87c932f45a33baeab
4
+ data.tar.gz: 84f40cb1527ed167e3f2ee2445f3a65dd4d00916
5
+ SHA512:
6
+ metadata.gz: 84d9523efa41e7e72a77ce3b21c83e8874cb0ca50ae41f4b39ab325afd0e6171c12e0ebd297460737b37f45f19c06b12f0a91746f7baa95aba8d23806b10d992
7
+ data.tar.gz: d9657e0d93d8b21f3e58c1daf4bd2c9684f320e3d1c770ca5e9d615f330cfe85f96c72c6d76c9ee07478da983531eb5c515656a3d316eb2df276deeefc3fcd9e
@@ -0,0 +1,66 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ module Calculations
6
+
7
+ APPLICATION_ID = 'f0fbbd27'
8
+ APPLICATION_KEY = '96f38c241b5806804a1cef7b23a4adec'
9
+
10
+ def self.call_api(endpoint, parameters)
11
+ puts "hello this is achyut"
12
+ url = URI.parse("https://api.aylien.com/api/v1/#{endpoint}")
13
+ headers = {
14
+ "Accept" => "application/json",
15
+ "X-AYLIEN-TextAPI-Application-ID" => APPLICATION_ID,
16
+ "X-AYLIEN-TextAPI-Application-Key" => APPLICATION_KEY
17
+ }
18
+
19
+ http = Net::HTTP.new(url.host, url.port)
20
+ http.use_ssl = true
21
+ request = Net::HTTP::Post.new(url.request_uri)
22
+
23
+ request.initialize_http_header(headers)
24
+
25
+ request.set_form_data(parameters)
26
+ puts "end of the statement"
27
+ response = http.request(request)
28
+
29
+ JSON.parse response.body
30
+
31
+
32
+ end
33
+
34
+
35
+
36
+ def self.recommends(result)
37
+ @present = result
38
+ @flag = true
39
+ @words = result
40
+ # @check = @words.scan(/\b[it][[:alpha:]]*/i)
41
+ # @words = @present.split("")
42
+ puts "hfsdccxkzzzzzzzzzzzzzzxxxxxxxxxzzzzzzzzzzzzzzzzzzzzzzz"
43
+ puts @words.scan(/\b[wb][[:alpha:]]*/i)
44
+ @check = @words.scan(/\b[wb][[:alpha:]]*/i)
45
+
46
+ if @check.include?("worst") || @check.include?("bad") || @check.include?("not")
47
+
48
+ puts "String includes 'bad'"
49
+ end
50
+ puts "hi"
51
+ parameters = {"text" => @words}
52
+ puts parameters
53
+ language = call_api("sentiment", parameters)
54
+ puts "done??"
55
+ puts language
56
+ puts "#{language["polarity"]}"
57
+ # puts @sentiment
58
+ puts "Language: #{language["lang"]} (#{language["confidence"]})"
59
+ # puts call_api("sentiment", @parameters)
60
+ @result = language["polarity"]
61
+ puts "++++++++++++++@result"
62
+ return @result
63
+
64
+
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: calculations
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Achyut A Vadavadagi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Just provide the statement and check the users condition
14
+ email: achyut.rymec@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/calculations.rb
20
+ homepage: http://rubygems.org/gems/calculations
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubyforge_project:
39
+ rubygems_version: 2.6.8
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: provides the User statement polarity value
43
+ test_files: []