datawow 1.2.2 → 1.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7bbe023397f8e704c76670d54282d08317390110f5a2fb419dc9cc7ab7bf2f3
4
- data.tar.gz: 2a5cb0c30d0fc78abcb343ba391b2175d366ea747f41b12bc991da3d39806a7b
3
+ metadata.gz: c3327f5b0eb5bc87cfdf05a5ca08fd195b55afafa5fe6d8a13699a4b0b1e74ba
4
+ data.tar.gz: 3daca2dd22d3bf42f0997039a16d1fef769dc479830fc9fc3844d6653bd1a7c8
5
5
  SHA512:
6
- metadata.gz: 04c5e48264c5a5af8102f6343225fdf0de5e84e99b5a541c02eae1f1d53c71eaa9b495b9b00f96b86950f782ff61d8e4a83190d766fdacd8c5642abadcfaabf9
7
- data.tar.gz: aa8d6828ae082ee2dec4260cdf524678f49af8ab51a66f2e6502bc05841c3c290ddecf4e073785d51d17fa0eae51e344e68f37fe3fc8cfd800e95ec4bfce281c
6
+ metadata.gz: 744842567a1293bea6161ca0bdf3c7b270e166eff1666a8f519b03e3cd23225d4a6efc3b9fad03d598edd9bba2699ba13a2ab6b5e274a30b86feadbd08dd70f3
7
+ data.tar.gz: aca984e0fb36b3985523d7c417da9a7ff6bf05b7100c8e7fb484f8ba4e011f8b2e5eff2528640b29b489e747f6dfd962457dc9d928c7eeddd3eb0772fe13944e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datawow (1.2.2)
4
+ datawow (1.3.2)
5
5
  json (~> 1.8, >= 1.8.3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -6,7 +6,7 @@ HTTP RESTFul for calling DataWow APIs
6
6
 
7
7
  # Installation
8
8
  ```ruby
9
- gem 'datawow', '~> 1.2.2'
9
+ gem 'datawow', '~> 1.3.2'
10
10
  ```
11
11
 
12
12
  #### Generate setting
@@ -48,6 +48,7 @@ There are 3 APIs for text class
48
48
  Datawow.text_closed_question
49
49
  Datawow.text_category
50
50
  Datawow.text_conversation
51
+ Datawow.text_ja
51
52
  ```
52
53
  ---
53
54
 
@@ -76,7 +77,7 @@ Datawow.[class].all({token: '_token'})
76
77
  ```
77
78
  ---
78
79
  ## Nanameue with Consensus
79
- ##### There are 2 ways to use the library
80
+ ##### There are 2 ways to use the library
80
81
 
81
82
  Firstly, __dynamic token__. if you have multiple project to work with, You could call library by using module name
82
83
  #### `create`
@@ -107,7 +108,7 @@ Secondly, we have initiated each modules since the library being called, so you
107
108
  ```ruby
108
109
  Datawow.project_key = '_token'
109
110
  ```
110
- ##### Start workgin with a provieded method
111
+ ##### Start working with provided methods
111
112
  #### `create`
112
113
  ```ruby
113
114
  Datawow.nanameue_human.create({data: "image URL"})
@@ -122,6 +123,28 @@ Datawow.nanameue_human.find_by({id: "_image_id"})
122
123
  ```ruby
123
124
  Datawow.nanameue_human.all({page: '_page', per_page: '_per_page'})
124
125
  ```
126
+ ---
127
+
128
+ ## Text AI Japanese
129
+ ##### Set your project key
130
+ ```ruby
131
+ Datawow.project_key = '_token'
132
+ ```
133
+
134
+ #### `create`
135
+ ```ruby
136
+ Datawow.text_ja.create({ data: 'フーバーバズ', custom_id: 'custom_id', postback_method: 'GET', postback_url: 'https://datawow.io' })
137
+ ```
138
+
139
+ #### `find_by`
140
+ ```ruby
141
+ Datawow.text_ja.find_by({ id: '_text_id' })
142
+ ```
143
+
144
+ #### `all`
145
+ ```ruby
146
+ Datawow.text_ja.all({page: '_page', per_page: '_per_page'})
147
+ ```
125
148
 
126
149
  # Setting default token
127
150
 
data/datawow.gemspec CHANGED
@@ -5,8 +5,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'datawow'
8
- s.version = '1.2.2'
9
- s.date = '2019-01-03'
8
+ s.version = '1.3.2'
9
+ s.date = '2019-01-04'
10
10
  s.summary = 'HTTP RESTFul for calling DataWow APIs'
11
11
  s.description = 'Moderation suite'
12
12
  s.post_install_message = File.read('INSTALL.md') if File.exist?('INSTALL.md')
data/lib/datawow.rb CHANGED
@@ -15,6 +15,7 @@ require_relative 'datawow/models/predictions/predictors'
15
15
  require_relative 'datawow/models/texts/text_categories'
16
16
  require_relative 'datawow/models/texts/text_closed_questions'
17
17
  require_relative 'datawow/models/texts/text_conversations'
18
+ require_relative 'datawow/models/texts/text_ja'
18
19
 
19
20
  require_relative 'datawow/models/videos/video_classifications'
20
21
 
@@ -45,6 +46,10 @@ module Datawow
45
46
  TextConversation.new
46
47
  end
47
48
 
49
+ def text_ja
50
+ TextJa.new
51
+ end
52
+
48
53
  def image_closed_question
49
54
  ImageClosedQuestion.new
50
55
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datawow
4
+ # :nodoc:
5
+ class TextJa
6
+ include Datawow::Models::Interface
7
+
8
+ attr_writer :project_key
9
+
10
+ def initialize(token = nil)
11
+ @project_key = token
12
+ @type = :text
13
+ @query_str = false
14
+ @path = 'text_ai/text_ja'
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Datawow
2
- VERSION = '1.2.2'.freeze
2
+ VERSION = '1.3.2'.freeze
3
3
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Datawow
6
+ class TextJaTest < TestBase
7
+ def test_all
8
+ stub_request(:get, TEXT_JA_URL)
9
+ .to_return(body: JSON.generate(text_jas), status: 200)
10
+ response = model.all
11
+
12
+ assert_instance_of(Response, response)
13
+ assert_equal(200, response.status)
14
+ refute_nil(response.data)
15
+ refute_nil(response.meta)
16
+ end
17
+
18
+ def test_create
19
+ stub_request(:post, TEXT_JA_URL)
20
+ .to_return(body: JSON.generate(text_jas), status: 201)
21
+ response = model.create(options)
22
+
23
+ assert_instance_of(Response, response)
24
+ assert_equal(201, response.status)
25
+ refute_nil(response.data)
26
+ refute_nil(response.meta)
27
+ end
28
+
29
+ def test_find
30
+ stub_request(:get, "#{TEXT_JA_URL}/1")
31
+ .to_return(body: JSON.generate(text_ja), status: 200)
32
+ response = model.find_by(id: '1')
33
+
34
+ assert_instance_of(Response, response)
35
+ assert_equal(200, response.status)
36
+ refute_nil(response.data)
37
+ refute_nil(response.meta)
38
+ end
39
+
40
+ private
41
+
42
+ def model
43
+ @model ||= TextJa.new
44
+ @model.project_key = 'test'
45
+ @model
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,35 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": "5c2eb38f0df256348de69a1f",
5
+ "created_at": "2019-01-04T08:14:55.372+07:00",
6
+ "custom_id": null,
7
+ "data": "foobar",
8
+ "processed_at": "2019-01-04T08:14:55.371+07:00",
9
+ "project_id": 202,
10
+ "results": {
11
+ "declined": 0.001,
12
+ "developing_model": {
13
+ "approved": 0.9909,
14
+ "pros-sexual": 0.0046,
15
+ "sns": 0.045
16
+ },
17
+ "pros_fasttext": 0.001,
18
+ "sexual_fasttext": 0.001,
19
+ "sexual_fasttext_romanji": 0.001,
20
+ "sns_fasttext": 0.001
21
+ },
22
+ "staff_id": 999998,
23
+ "status": "done"
24
+ }
25
+ ],
26
+ "meta": {
27
+ "code": 200,
28
+ "message": "success",
29
+ "current_page": 1,
30
+ "next_page": -1,
31
+ "prev_page": -1,
32
+ "total_pages": 1,
33
+ "total_count": 2
34
+ }
35
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "data": {
3
+ "id": "5c2eb38f0df256348de69a1f",
4
+ "created_at": "2019-01-04T08:14:55.372+07:00",
5
+ "custom_id": null,
6
+ "data": "foobar",
7
+ "processed_at": "2019-01-04T08:14:55.371+07:00",
8
+ "project_id": 202,
9
+ "results": {
10
+ "declined": 0.001,
11
+ "developing_model": {
12
+ "approved": 0.9909,
13
+ "pros-sexual": 0.0046,
14
+ "sns": 0.045
15
+ },
16
+ "pros_fasttext": 0.001,
17
+ "sexual_fasttext": 0.001,
18
+ "sexual_fasttext_romanji": 0.001,
19
+ "sns_fasttext": 0.001
20
+ },
21
+ "staff_id": 999998,
22
+ "status": "done"
23
+ },
24
+ "meta": {
25
+ "code": 201,
26
+ "message": "success"
27
+ }
28
+ }
data/test/test_helper.rb CHANGED
@@ -13,7 +13,8 @@ class TestBase < Minitest::Test
13
13
  :image_closed_questions, :image_message, :image_messages, :image_photo_tag,
14
14
  :image_photo_tags, :prediction, :predictions, :videos, :video,
15
15
  :text_categories, :text_category, :text_conversations, :text_conversation,
16
- :text_closed_questions, :text_closed_question, :nanameue_human, :nanameue_humans
16
+ :text_closed_questions, :text_closed_question, :nanameue_human, :nanameue_humans,
17
+ :text_ja, :text_jas
17
18
 
18
19
  IMAGE_CHOICES_URL = 'https://kiyo-image.datawow.io/api/v1/images/choices'.freeze
19
20
  IMAGE_CHOICE_URL = 'https://kiyo-image.datawow.io/api/v1/images/choice'.freeze
@@ -30,6 +31,7 @@ class TestBase < Minitest::Test
30
31
  TEXT_CATEGORY_URL = 'https://kiyo-text.datawow.io/api/v1/text/text_categories'.freeze
31
32
  TEXT_CONVERSATION_URL = 'https://kiyo-text.datawow.io/api/v1/text/text_conversations'.freeze
32
33
  TEXT_CLOSED_QUESTION_URL = 'https://kiyo-text.datawow.io/api/v1/text/text_closed_questions'.freeze
34
+ TEXT_JA_URL = 'https://kiyo-text.datawow.io/api/v1/text_ai/text_ja'.freeze
33
35
 
34
36
  def setup
35
37
  @image_choices = FileReader.new('test/fixtures/image_choice/all.json').read_json
@@ -52,6 +54,8 @@ class TestBase < Minitest::Test
52
54
  @text_conversations = FileReader.new('test/fixtures/text_conversation/all.json').read_json
53
55
  @text_closed_question = FileReader.new('test/fixtures/text_closed_question/create.json').read_json
54
56
  @text_closed_questions = FileReader.new('test/fixtures/text_closed_question/all.json').read_json
57
+ @text_ja = FileReader.new('test/fixtures/text_ja/create.json').read_json
58
+ @text_jas = FileReader.new('test/fixtures/text_ja/all.json').read_json
55
59
  @options = {
56
60
  token: 'project token'
57
61
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datawow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesdakorn Samittiauttakorn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-03 00:00:00.000000000 Z
11
+ date: 2019-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -124,6 +124,7 @@ files:
124
124
  - lib/datawow/models/texts/text_categories.rb
125
125
  - lib/datawow/models/texts/text_closed_questions.rb
126
126
  - lib/datawow/models/texts/text_conversations.rb
127
+ - lib/datawow/models/texts/text_ja.rb
127
128
  - lib/datawow/models/videos/video_classifications.rb
128
129
  - lib/datawow/version.rb
129
130
  - lib/generators/datawow/install_generator.rb
@@ -139,6 +140,7 @@ files:
139
140
  - test/datawow/text_categories_test.rb
140
141
  - test/datawow/text_closed_questions_test.rb
141
142
  - test/datawow/text_conversations_test.rb
143
+ - test/datawow/text_ja_test.rb
142
144
  - test/datawow/video_classifications_test.rb
143
145
  - test/datawow_test.rb
144
146
  - test/fixtures/image_choice/all.json
@@ -159,6 +161,8 @@ files:
159
161
  - test/fixtures/text_closed_question/create.json
160
162
  - test/fixtures/text_conversation/all.json
161
163
  - test/fixtures/text_conversation/create.json
164
+ - test/fixtures/text_ja/all.json
165
+ - test/fixtures/text_ja/create.json
162
166
  - test/fixtures/video_classification/all.json
163
167
  - test/fixtures/video_classification/create.json
164
168
  - test/helper/file_reader.rb