qna_maker 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/qna_maker/alteration.rb +10 -0
- data/lib/qna_maker/answer.rb +11 -0
- data/lib/qna_maker/endpoints/create_kb.rb +55 -0
- data/lib/qna_maker/endpoints/delete_kb.rb +49 -0
- data/lib/qna_maker/endpoints/download_alterations.rb +29 -0
- data/lib/qna_maker/endpoints/download_kb.rb +24 -0
- data/lib/qna_maker/endpoints/generate_answer.rb +35 -0
- data/lib/qna_maker/endpoints/publish_kb.rb +26 -0
- data/lib/qna_maker/endpoints/train_kb.rb +19 -0
- data/lib/qna_maker/endpoints/update_kb.rb +13 -0
- data/lib/qna_maker/errors.rb +25 -0
- data/lib/qna_maker/string.rb +9 -0
- data/lib/qna_maker/version.rb +3 -0
- data/lib/qna_maker.rb +33 -0
- data/qna_maker.gemspec +30 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d4103f532e31d381a82ed32c049d72a21547b3fae676d97630db2b5d1fc66a8b
|
4
|
+
data.tar.gz: ae4efc18758b6a37e439f7d999d47ecf6e0f4b3d44f6d30ba907d72bff6daa2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 35f412b81b086f3b167e234453665cc8992514fd486b2271600245053d7cc2723cd50cf9b0076dd1f741753bbb79aede1d391c7f3e2c24259667f73ac9a727c9
|
7
|
+
data.tar.gz: 07c989011fd502a8073e6513970d18a3701703cfe53a4b366352b918886e676d54770a952f4b7cba024b2a0ff3bf514429a5d30b0943a5c78d1c3f12ff95ae78
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at Birdie0@users.noreply.github.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Birdie0
|
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,71 @@
|
|
1
|
+
# QnAMaker
|
2
|
+
|
3
|
+
API wrapper for [QnA Maker](https://qnamaker.ai)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'qna_maker'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install qna_maker
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'qna_maker'
|
25
|
+
|
26
|
+
client = QnAMaker::Client.new('kb_id' , 'subscription_key')
|
27
|
+
# => #<QnAMaker::Client @knowledgebase_id="kb_id", @subscription_key="subscription_key", ...>
|
28
|
+
|
29
|
+
answers = client.generate_answer('hi')
|
30
|
+
# => [#<QnAMaker::Answer @answer="hello", @questions=["hi"], @score=100.0>]
|
31
|
+
|
32
|
+
puts answers.first.answer
|
33
|
+
# => hello
|
34
|
+
```
|
35
|
+
|
36
|
+
## Development status
|
37
|
+
|
38
|
+
Gem is under active development! It isn't finished yet!
|
39
|
+
|
40
|
+
### Todo list
|
41
|
+
|
42
|
+
* [ ] Methods
|
43
|
+
* [x] **POST** - Create Knowledge Base
|
44
|
+
* [x] **DELETE** - Delete Knowledge Base
|
45
|
+
* [x] **GET** - Download Alterations
|
46
|
+
* [x] **GET** - Download Knowledge Base
|
47
|
+
* [x] **POST** - Generate answer
|
48
|
+
* [x] **PUT** - Publish Knowledge Base
|
49
|
+
* [ ] **PATCH** - Train Knowledge Base
|
50
|
+
* [ ] **PATCH** - Update Alterations
|
51
|
+
* [ ] **PATCH** - Update Knowledge Base
|
52
|
+
* [ ] Documentation
|
53
|
+
* [ ] Tests
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
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.
|
58
|
+
|
59
|
+
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).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Birdie0/qna_maker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
68
|
+
|
69
|
+
## Code of Conduct
|
70
|
+
|
71
|
+
Everyone interacting in the QnAMaker project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Birdie0/qna_maker/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'qna_maker'
|
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
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module QnAMaker
|
2
|
+
class Client
|
3
|
+
def create_kb(name, qna_pairs = [], urls = [])
|
4
|
+
response = @http.post(
|
5
|
+
"#{BASE_URL}/create",
|
6
|
+
json: {
|
7
|
+
name: name,
|
8
|
+
qnaPairs: qna_pairs.map { |pair| { question: pair[0], answer: pair[1] } },
|
9
|
+
urls: urls
|
10
|
+
}
|
11
|
+
)
|
12
|
+
|
13
|
+
case response.code
|
14
|
+
when 201
|
15
|
+
QnA.new(
|
16
|
+
response.parse['kbId'],
|
17
|
+
@subscription_key,
|
18
|
+
response.parse['dataExtractionResults']
|
19
|
+
)
|
20
|
+
when 400
|
21
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
22
|
+
when 401
|
23
|
+
raise UnauthorizedError, response.parse['error']['message']
|
24
|
+
else
|
25
|
+
raise UnknownError, 'Oh no!'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.create_kb(name, subscription_key, qna_pairs = [], urls = [])
|
30
|
+
response = HTTP.headers('Ocp-Apim-Subscription-Key' => subscription_key).post(
|
31
|
+
"#{BASE_URL}/create",
|
32
|
+
json: {
|
33
|
+
name: name,
|
34
|
+
qnaPairs: qna_pairs.map { |pair| { question: pair[0], answer: pair[1] } },
|
35
|
+
urls: urls
|
36
|
+
}
|
37
|
+
)
|
38
|
+
|
39
|
+
case response.code
|
40
|
+
when 201
|
41
|
+
QnA.new(
|
42
|
+
response.parse['kbId'],
|
43
|
+
subscription_key,
|
44
|
+
response.parse['dataExtractionResults']
|
45
|
+
)
|
46
|
+
when 400
|
47
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
48
|
+
when 401
|
49
|
+
raise UnauthorizedError, response.parse['error']['message']
|
50
|
+
else
|
51
|
+
raise UnknownError, 'Oh no!'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module QnAMaker
|
2
|
+
class Client
|
3
|
+
def delete_kb
|
4
|
+
response = @http.delete(
|
5
|
+
"#{BASE_URL}/#{knowledgebase_id}"
|
6
|
+
)
|
7
|
+
|
8
|
+
case response.code
|
9
|
+
when 204
|
10
|
+
nil
|
11
|
+
when 400
|
12
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
13
|
+
when 401
|
14
|
+
raise UnauthorizedError, response.parse['error']['message']
|
15
|
+
when 403
|
16
|
+
raise QuotaExceededError, response.parse['error']['message'].join(' ')
|
17
|
+
when 404
|
18
|
+
raise NotFoundError, response.parse['error']['message'].join(' ')
|
19
|
+
when 409
|
20
|
+
raise ConflictError, response.parse['error']['message'].join(' ')
|
21
|
+
else
|
22
|
+
raise UnknownError, 'Oh no!'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.delete_kb(knowledgebase_id, subscription_key)
|
27
|
+
response = HTTP.headers('Ocp-Apim-Subscription-Key' => subscription_key).delete(
|
28
|
+
"#{BASE_URL}/#{knowledgebase_id}"
|
29
|
+
)
|
30
|
+
|
31
|
+
case response.code
|
32
|
+
when 204
|
33
|
+
nil
|
34
|
+
when 400
|
35
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
36
|
+
when 401
|
37
|
+
raise UnauthorizedError, response.parse['error']['message']
|
38
|
+
when 403
|
39
|
+
raise QuotaExceededError, response.parse['error']['message'].join(' ')
|
40
|
+
when 404
|
41
|
+
raise NotFoundError, response.parse['error']['message'].join(' ')
|
42
|
+
when 409
|
43
|
+
raise ConflictError, response.parse['error']['message'].join(' ')
|
44
|
+
else
|
45
|
+
raise UnknownError, 'Oh no!'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module QnAMaker
|
2
|
+
class Client
|
3
|
+
def download_alterations
|
4
|
+
response = @http.get(
|
5
|
+
"#{BASE_URL}/#{@knowledgebase_id}/downloadAlterations"
|
6
|
+
)
|
7
|
+
|
8
|
+
case response.code
|
9
|
+
when 200
|
10
|
+
response.parse['wordAlterations'].map do |alteration|
|
11
|
+
Alteration.new(
|
12
|
+
alteration['word'].normalize,
|
13
|
+
alteration['alterations'].map(&:normalize)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
when 400
|
17
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
18
|
+
when 401
|
19
|
+
raise UnauthorizedError, response.parse['error']['message']
|
20
|
+
when 403
|
21
|
+
raise QuotaExceededError, response.parse['error']['message'].join(' ')
|
22
|
+
when 404
|
23
|
+
raise NotFoundError, response.parse['error']['message'].join(' ')
|
24
|
+
else
|
25
|
+
raise UnknownError, 'Oh no!'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module QnAMaker
|
2
|
+
class Client
|
3
|
+
def download_kb
|
4
|
+
response = @http.get(
|
5
|
+
"#{BASE_URL}/#{@knowledgebase_id}"
|
6
|
+
)
|
7
|
+
|
8
|
+
case response.code
|
9
|
+
when 200
|
10
|
+
response.parse
|
11
|
+
when 400
|
12
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
13
|
+
when 401
|
14
|
+
raise UnauthorizedError, response.parse['error']['message']
|
15
|
+
when 403
|
16
|
+
raise QuotaExceededError, response.parse['error']['message'].join(' ')
|
17
|
+
when 404
|
18
|
+
raise NotFoundError, response.parse['error']['message'].join(' ')
|
19
|
+
else
|
20
|
+
raise UnknownError, 'Oh no!'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module QnAMaker
|
2
|
+
class Client
|
3
|
+
def generate_answer(question, top = 1)
|
4
|
+
response = @http.post(
|
5
|
+
"#{BASE_URL}/#{@knowledgebase_id}/generateAnswer",
|
6
|
+
json: { question: question, top: top }
|
7
|
+
)
|
8
|
+
|
9
|
+
case response.code
|
10
|
+
when 200
|
11
|
+
response.parse['answers'].map do |answer|
|
12
|
+
Answer.new(
|
13
|
+
answer['answer'].normalize,
|
14
|
+
answer['questions'].map(&:normalize),
|
15
|
+
answer['score']
|
16
|
+
)
|
17
|
+
end
|
18
|
+
when 400
|
19
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
20
|
+
when 401
|
21
|
+
raise UnauthorizedError, response.parse['error']['message']
|
22
|
+
when 403
|
23
|
+
raise QuotaExceededError, response.parse['error']['message'].join(' ')
|
24
|
+
when 404
|
25
|
+
raise NotFoundError, response.parse['error']['message'].join(' ')
|
26
|
+
when 408
|
27
|
+
raise OperationTimeOutError, response.parse['error']['message'].join(' ')
|
28
|
+
when 429
|
29
|
+
raise RateLimitExceededError, response.parse['error']['message'].join(' ')
|
30
|
+
else
|
31
|
+
raise UnknownError, 'Oh no!'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module QnAMaker
|
2
|
+
class Client
|
3
|
+
def publish_kb
|
4
|
+
response = @http.put(
|
5
|
+
"#{BASE_URL}/#{@knowledgebase_id}"
|
6
|
+
)
|
7
|
+
|
8
|
+
case response.code
|
9
|
+
when 204
|
10
|
+
nil
|
11
|
+
when 400
|
12
|
+
raise BadArgumentError, response.parse['error']['message'].join(' ')
|
13
|
+
when 401
|
14
|
+
raise UnauthorizedError, response.parse['error']['message']
|
15
|
+
when 404
|
16
|
+
raise NotFoundError, response.parse['error']['message'].join(' ')
|
17
|
+
when 403
|
18
|
+
raise QuotaExceededError, response.parse['error']['message'].join(' ')
|
19
|
+
when 409
|
20
|
+
raise ConflictError, response.parse['error']['message'].join(' ')
|
21
|
+
else
|
22
|
+
raise UnknownError, 'Oh no!'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# def train_kb(user_question, kb_question, kb_answer)
|
2
|
+
# response = HTTP.patch(
|
3
|
+
# full_url(:train_kb),
|
4
|
+
# json: {
|
5
|
+
# feedbackRecords: [{
|
6
|
+
# userId: '1',
|
7
|
+
# userQuestion: user_question,
|
8
|
+
# kbQuestion: kb_question,
|
9
|
+
# kbAnswer: kb_answer
|
10
|
+
# }]
|
11
|
+
# }
|
12
|
+
# )
|
13
|
+
# case response.code
|
14
|
+
# when 204
|
15
|
+
# 'Success!'
|
16
|
+
# else
|
17
|
+
# response.code
|
18
|
+
# end
|
19
|
+
# end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# def update_kb(add = [], delete = [])
|
2
|
+
# response = HTTP.patch(
|
3
|
+
# full_url(:update_kb),
|
4
|
+
# json: { add: { qnaPairs: add }, delete: { qnaPairs: delete } }
|
5
|
+
# )
|
6
|
+
|
7
|
+
# case response.code
|
8
|
+
# when 204
|
9
|
+
# 'Success!'
|
10
|
+
# else
|
11
|
+
# response.code
|
12
|
+
# end
|
13
|
+
# end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module QnAMaker
|
2
|
+
class BadArgumentError < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class NotFoundError < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
class UnauthorizedError < StandardError
|
9
|
+
end
|
10
|
+
|
11
|
+
class QuotaExceededError < StandardError
|
12
|
+
end
|
13
|
+
|
14
|
+
class OperationTimeOutError < StandardError
|
15
|
+
end
|
16
|
+
|
17
|
+
class RateLimitExceededError < StandardError
|
18
|
+
end
|
19
|
+
|
20
|
+
class ConflictError < StandardError
|
21
|
+
end
|
22
|
+
|
23
|
+
class UnknownError < StandardError
|
24
|
+
end
|
25
|
+
end
|
data/lib/qna_maker.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'qna_maker/version'
|
2
|
+
|
3
|
+
require 'qna_maker/alteration'
|
4
|
+
require 'qna_maker/answer'
|
5
|
+
require 'qna_maker/errors'
|
6
|
+
require 'qna_maker/string'
|
7
|
+
|
8
|
+
require 'qna_maker/endpoints/create_kb'
|
9
|
+
require 'qna_maker/endpoints/delete_kb'
|
10
|
+
require 'qna_maker/endpoints/download_alterations'
|
11
|
+
require 'qna_maker/endpoints/download_kb'
|
12
|
+
require 'qna_maker/endpoints/generate_answer'
|
13
|
+
require 'qna_maker/endpoints/publish_kb'
|
14
|
+
# require 'qna_maker/endpoints/train_kb'
|
15
|
+
# require 'qna_maker/endpoints/update_kb'
|
16
|
+
# require 'qna_maker/endpoints/update_alterations'
|
17
|
+
|
18
|
+
require 'http'
|
19
|
+
|
20
|
+
module QnAMaker
|
21
|
+
class Client
|
22
|
+
BASE_URL = 'https://westus.api.cognitive.microsoft.com/QnAMaker/v2.0/knowledgebases'.freeze
|
23
|
+
|
24
|
+
attr_reader :knowledgebase_id, :subscription_key, :data_extraction_results
|
25
|
+
|
26
|
+
def initialize(knowledgebase_id, subscription_key, data_extraction_results = [])
|
27
|
+
@knowledgebase_id = knowledgebase_id
|
28
|
+
@subscription_key = subscription_key
|
29
|
+
@data_extraction_results = data_extraction_results
|
30
|
+
@http = HTTP.headers('Ocp-Apim-Subscription-Key' => @subscription_key)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/qna_maker.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'qna_maker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'qna_maker'
|
8
|
+
spec.version = QnAMaker::VERSION
|
9
|
+
spec.authors = ['Birdie0']
|
10
|
+
spec.email = ['Birdie0@users.noreply.github.com']
|
11
|
+
|
12
|
+
spec.summary = 'API wrapper for https://qnamaker.ai'
|
13
|
+
spec.description = 'API wrapper that allows to use QnA Maker with your application'
|
14
|
+
spec.homepage = 'https://github.com/Birdie0/qna_maker'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'htmlentities', '~> 4.3', '>= 4.3.4'
|
25
|
+
spec.add_dependency 'http', '~> 3.0'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qna_maker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Birdie0
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: htmlentities
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.3.4
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.3.4
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: http
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.16'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.16'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '10.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '10.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.0'
|
89
|
+
description: API wrapper that allows to use QnA Maker with your application
|
90
|
+
email:
|
91
|
+
- Birdie0@users.noreply.github.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- ".gitignore"
|
97
|
+
- ".rspec"
|
98
|
+
- ".rubocop.yml"
|
99
|
+
- ".travis.yml"
|
100
|
+
- CODE_OF_CONDUCT.md
|
101
|
+
- Gemfile
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.md
|
104
|
+
- Rakefile
|
105
|
+
- bin/console
|
106
|
+
- bin/setup
|
107
|
+
- lib/qna_maker.rb
|
108
|
+
- lib/qna_maker/alteration.rb
|
109
|
+
- lib/qna_maker/answer.rb
|
110
|
+
- lib/qna_maker/endpoints/create_kb.rb
|
111
|
+
- lib/qna_maker/endpoints/delete_kb.rb
|
112
|
+
- lib/qna_maker/endpoints/download_alterations.rb
|
113
|
+
- lib/qna_maker/endpoints/download_kb.rb
|
114
|
+
- lib/qna_maker/endpoints/generate_answer.rb
|
115
|
+
- lib/qna_maker/endpoints/publish_kb.rb
|
116
|
+
- lib/qna_maker/endpoints/train_kb.rb
|
117
|
+
- lib/qna_maker/endpoints/update_kb.rb
|
118
|
+
- lib/qna_maker/errors.rb
|
119
|
+
- lib/qna_maker/string.rb
|
120
|
+
- lib/qna_maker/version.rb
|
121
|
+
- qna_maker.gemspec
|
122
|
+
homepage: https://github.com/Birdie0/qna_maker
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.7.6
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: API wrapper for https://qnamaker.ai
|
146
|
+
test_files: []
|