watson-personality-insights 0.1.0 → 0.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 736a3587eea3f4c238a448c24b78aa8bae5bff79
|
4
|
+
data.tar.gz: 5a4925046650ad5346143a61d7c0ab6b6066f25e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d611f641f283789f0fe7d7dc0bda013d1bec301e58f5b306ce68b82f4c7340b9b009bbc0cf8d349c327bbfefe127d0c0d3a59f0bde10b237951047c6a8c650
|
7
|
+
data.tar.gz: dc983a9e1958c9312f3c37cadadaa3be796a53b973b0025a9e11313720024d858785f4b32e815282f41250ba87d22b90256caa024b0379714941deacc90be1e8
|
data/README.md
CHANGED
@@ -1,61 +1,41 @@
|
|
1
|
-
#
|
1
|
+
# WatsonPersonalityInsights
|
2
2
|
|
3
|
-
|
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/watson-personality-insights`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
|
-
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
7
|
-
##
|
7
|
+
## Installation
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
After creating an instance of the Personality Insights service, select Service Credentials from the navigation on the left side of its dashboard page to see the username and password that are associated with the instance. For more information, see [Obtaining credentials for Watson services](https://www.ibm.com/watson/developercloud/doc/common/getting-started-credentials.html).
|
12
|
-
|
13
|
-
After create bluemix account and create username and passowrd credencials, you can use another gem for env variables as ([dotenv](https://github.com/bkeepers/dotenv), [figaro](https://github.com/laserlemon/figaro) or which you want to create env variables).
|
14
|
-
|
15
|
-
Then in (.env) file you should add:
|
9
|
+
Add this line to your application's Gemfile:
|
16
10
|
|
17
11
|
```ruby
|
18
|
-
|
19
|
-
personality_insights_username=$your_password_from_bluemix
|
12
|
+
gem 'watson-personality-insights'
|
20
13
|
```
|
21
14
|
|
22
|
-
|
15
|
+
And then execute:
|
23
16
|
|
24
|
-
|
25
|
-
You can install this library
|
17
|
+
$ bundle
|
26
18
|
|
27
|
-
|
19
|
+
Or install it yourself as:
|
28
20
|
|
29
|
-
|
21
|
+
$ gem install watson-personality-insights
|
30
22
|
|
31
|
-
|
32
|
-
require 'watson-personality-insights'
|
33
|
-
```
|
23
|
+
## Usage
|
34
24
|
|
35
|
-
|
36
|
-
PersonalityInsights works with Rails > 4.1 onwards. You can add it to your Gemfile with:
|
25
|
+
TODO: Write usage instructions here
|
37
26
|
|
38
|
-
|
39
|
-
gem 'watson-personality-insights'
|
40
|
-
```
|
27
|
+
## Development
|
41
28
|
|
42
|
-
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
43
30
|
|
44
|
-
|
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
45
32
|
|
46
|
-
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/WatsonPersonalityInsights.
|
47
36
|
|
48
|
-
Generates a personality profile for the author of the input text. The service accepts a maximum of 20 MB of input content. It can analyze text in Arabic, English, Japanese, or Spanish and return its results in a variety of languages. You can provide plain text, HTML, or JSON input. The service returns output in JSON format by default, but you can request the output in CSV format.
|
49
37
|
|
50
|
-
```ruby
|
51
|
-
@watson_personality = PersonalityInsights::Profile.new(json_file_url)
|
52
|
-
@watson_personality.get_profile(
|
53
|
-
version: '2016-10-20',
|
54
|
-
consumption_preferences: true,
|
55
|
-
raw_scores: true
|
56
|
-
)
|
57
|
-
```
|
58
|
-
|
59
38
|
## License
|
60
39
|
|
61
|
-
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
@@ -2,7 +2,7 @@ module PersonalityInsights
|
|
2
2
|
module ActiveMethod
|
3
3
|
class Base < ActiveMethod::Extra
|
4
4
|
include PersonalityInsights::Generator::PersonalityRequest
|
5
|
-
attr_accessor :username, :password, :json_result, :options, :file
|
5
|
+
attr_accessor :username, :password, :json_result, :options, :file, :content_language, :accept, :accept_language
|
6
6
|
|
7
7
|
def initialize(file)
|
8
8
|
@file = file
|
@@ -14,6 +14,9 @@ module PersonalityInsights
|
|
14
14
|
request = Net::HTTP::Post.new(uri)
|
15
15
|
request.basic_auth(@username, @password)
|
16
16
|
request.content_type = "application/json"
|
17
|
+
request["Content-Language"] = @options[:content_language] unless @options[:content_language].nil?
|
18
|
+
request["Accept"] = @options[:accept] unless @options[:accept].nil?
|
19
|
+
request["Accept-Language"] = @options[:accept_language] unless @options[:accept_language].nil?
|
17
20
|
request.body = ""
|
18
21
|
request.body << File.read(@file).delete("\r\n")
|
19
22
|
response(uri, request)
|