adapt-charyf 0.2.1
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -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 +102 -0
- data/Rakefile +6 -0
- data/adapt-charyf.gemspec +49 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/lib/adapt/generators/intent/intent_generator.rb +19 -0
- data/lib/adapt/generators/intent/templates/intents/adapt_private.rb.tt +3 -0
- data/lib/adapt/generators/intent/templates/intents/adapt_public.rb.tt +9 -0
- data/lib/adapt/processor.rb +94 -0
- data/lib/adapt/routing_builder.rb +104 -0
- data/lib/adapt/version.rb +3 -0
- data/lib/adapt-charyf.rb +14 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0f8601022ff9f62ba29e03141606deb809bfa3a0
|
4
|
+
data.tar.gz: 8bd5cba22a6272d5ced8e1c4bcb9d297a938c15d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3bbcd028c0d0b35885b459f7a738ab18b976afbb01c627553bfbb41d05247b394561c6931e703861222fe576087714a151445453a3d41a53ff756acf32d6166e
|
7
|
+
data.tar.gz: 28214649a4437c363f39f0274be2b2b0ca87dda4beae6f0483cce44268ae750c72c37cf7e56d6d4216a0a00fb6a8a8c98d5527c87fcd0419225a0d3dfacdcf4c
|
data/.gitignore
ADDED
data/.rspec
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 richard.ludvigh@gmail.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) 2017 Richard Ludvigh
|
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,102 @@
|
|
1
|
+
# Adapt-Charyf
|
2
|
+
|
3
|
+
Adapt-Charyf is a ruby wrapper around Mycroft's Intent parser library [mycroft/Adapt](https://github.com/MycroftAI/adapt). This wrapper provides charyf interface to defining and determining intents.
|
4
|
+
|
5
|
+
# Getting Started
|
6
|
+
|
7
|
+
Add this line to your charyf application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'adapt-chartf'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install adapt-charyf
|
20
|
+
|
21
|
+
Make sure the python library is installed
|
22
|
+
```pip install -e git+https://github.com/mycroftai/adapt#egg=adapt-parser``` [or use pip3 if desired]
|
23
|
+
|
24
|
+
Adapt-charyf uses ```pycall``` gem to handle python calls.
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
When launching any ruby application using adapt-charyf, ensure that
|
29
|
+
```ENV['PYTHON'] = /path/to/python/with/adapt/libary```
|
30
|
+
is set to python version that has adapt-parser installed.
|
31
|
+
|
32
|
+
Defining the intent is very similiar to original adapt library.
|
33
|
+
|
34
|
+
### Entities
|
35
|
+
|
36
|
+
Firstly we define entites that will occur in our utterances.
|
37
|
+
|
38
|
+
**Register an keyword entity**
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Skill.public_routing_for :adapt do |routing|
|
42
|
+
routing.register_keywords 'greet', 'Hello', 'Hi'
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Keyword entity is defined by its name *greet* and followed by all phrases in this entity.
|
47
|
+
For entity *greet* we define two works *Hi* and *Hello*.
|
48
|
+
|
49
|
+
**Register regex entity**
|
50
|
+
|
51
|
+
User may register regex entity as well.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Skill.public_routing_for :adapt do |routing|
|
55
|
+
routing.register_regex 'in (?P<location>.*)'
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
Regex entity requires a regex with one named capture. This named capture is then used as the name of the entity.
|
60
|
+
Example above defines new regex entity with name *location*.
|
61
|
+
|
62
|
+
> Adapt regex entities use python's syntax as there is no current 1:1 mapping between ruby and python regex syntax.
|
63
|
+
However defining named capture is very similiar.
|
64
|
+
|
65
|
+
All defined entities are available in the scope of particular skill and are not visible to other skills.
|
66
|
+
Once can imagine defining entity *hello* as *Skill:Hello*, thus not coliding with other skills.
|
67
|
+
|
68
|
+
### Intent
|
69
|
+
|
70
|
+
Once our entities are defined and correctly named we can start building intents.
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Skill.public_routing_for :adapt do |routing|
|
74
|
+
routing.intent('GreetIntent')
|
75
|
+
.required('greet')
|
76
|
+
#.optional('another_entity')
|
77
|
+
.route_to('base', 'hello')
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
Example above defines new intent *GreetIntent*, with one required entity. We can also define optional entities which does not need to occur in the utterance.
|
82
|
+
Last step of defining is setting the *routing*. By specifying **route_to('base', 'hello')** we define that matched intent should be routed to **Skill::BaseController** into action **hello**.
|
83
|
+
|
84
|
+
Routing can't be defined outside the scope of the skill as it is automatically nested into skill namespace.
|
85
|
+
|
86
|
+
## Development
|
87
|
+
|
88
|
+
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.
|
89
|
+
|
90
|
+
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).
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/adapt-charyf. 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.
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
99
|
+
|
100
|
+
## Code of Conduct
|
101
|
+
|
102
|
+
Everyone interacting in the CharyfAdaptProcessor project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/adapt-charyf/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'adapt/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "adapt-charyf"
|
8
|
+
spec.version = Adapt::VERSION
|
9
|
+
spec.authors = ["Richard Ludvigh"]
|
10
|
+
spec.email = ["richard.ludvigh@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Charyf intent processor wrapper for MycroftAI/adapt library'
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = 'https://github.com/Charyf/charyf-adapt-processor'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.required_ruby_version = '>= 2.1'
|
18
|
+
|
19
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
20
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
21
|
+
# if spec.respond_to?(:metadata)
|
22
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
23
|
+
# else
|
24
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
# "public gem pushes."
|
26
|
+
# end
|
27
|
+
|
28
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
29
|
+
f.match(%r{^(test|spec|features)/})
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_runtime_dependency "charyf", "~> 0"
|
36
|
+
spec.add_runtime_dependency "pycall", "~> 1.0.3"
|
37
|
+
|
38
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
+
spec.add_development_dependency "pry"
|
42
|
+
|
43
|
+
spec.post_install_message = <<-EOM
|
44
|
+
Make sure MycroftAI/adapt python library is installed [https://github.com/MycroftAI/adapt].
|
45
|
+
Also set the ENV[PYTHON] variable to python executable with the library installed.
|
46
|
+
|
47
|
+
Read -> Speak -> Chat!
|
48
|
+
EOM
|
49
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'adapt-charyf'
|
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
|
+
Adapt = Adapt::Intent::Processor
|
14
|
+
|
15
|
+
require "irb"
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'charyf/utils/generators/named_base'
|
2
|
+
|
3
|
+
module Adapt
|
4
|
+
module Generators
|
5
|
+
class IntentGenerator < Charyf::Generators::NamedBase
|
6
|
+
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
def public_routing
|
10
|
+
template 'intents/adapt_public.rb', File.join('app/skills', skill_content_path, 'intents', 'adapt_public.rb')
|
11
|
+
end
|
12
|
+
|
13
|
+
def private_routing
|
14
|
+
template 'intents/adapt_private.rb', File.join('app/skills', skill_content_path, 'intents', 'adapt_private.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'pycall/import'
|
2
|
+
|
3
|
+
require_relative 'routing_builder'
|
4
|
+
|
5
|
+
module Adapt
|
6
|
+
module Intent
|
7
|
+
class Processor < Charyf::Engine::Intent::Processor::Base
|
8
|
+
|
9
|
+
strategy_name :adapt
|
10
|
+
|
11
|
+
MUTEX = Mutex.new.freeze
|
12
|
+
private_constant :MUTEX
|
13
|
+
|
14
|
+
class << self
|
15
|
+
include PyCall::Import
|
16
|
+
|
17
|
+
def get_for(skill_name = nil)
|
18
|
+
engine = engine(skill_name)
|
19
|
+
|
20
|
+
self.new(skill_name, engine)
|
21
|
+
end
|
22
|
+
|
23
|
+
def engine(skill_name = nil)
|
24
|
+
MUTEX.synchronize {
|
25
|
+
return _engines[skill_name] ||= init_engine
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def init_engine
|
30
|
+
unless @_python_loaded
|
31
|
+
pyfrom 'adapt.intent', import: :IntentBuilder
|
32
|
+
pyfrom 'adapt.engine', import: :IntentDeterminationEngine
|
33
|
+
@_python_loaded = true
|
34
|
+
end
|
35
|
+
|
36
|
+
IntentDeterminationEngine.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def _engines
|
40
|
+
@engines ||= {}
|
41
|
+
end
|
42
|
+
|
43
|
+
def _intents
|
44
|
+
@intents ||= {}
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(skill_name, engine)
|
50
|
+
@skill_name = skill_name
|
51
|
+
@engine = engine
|
52
|
+
end
|
53
|
+
|
54
|
+
def load(skill_name, block)
|
55
|
+
builder = Adapt::RoutingBuilder.new(skill_name)
|
56
|
+
|
57
|
+
block.call(builder)
|
58
|
+
|
59
|
+
intents = builder.build(@engine, IntentBuilder)
|
60
|
+
|
61
|
+
# TODO handle already existing
|
62
|
+
intents.each do |intent|
|
63
|
+
self.class._intents[intent.name] = intent
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def determine(request)
|
68
|
+
adapt_intent = nil
|
69
|
+
text = Charyf.application.parser.normalize(request.text)
|
70
|
+
generator = @engine.determine_intent(text)
|
71
|
+
begin
|
72
|
+
adapt_intent = PyCall.builtins.next(generator)
|
73
|
+
rescue PyCall::PyError
|
74
|
+
# ignored
|
75
|
+
end
|
76
|
+
|
77
|
+
return unknown unless adapt_intent
|
78
|
+
|
79
|
+
confidence = adapt_intent['confidence']
|
80
|
+
app_intent = self.class._intents[adapt_intent['intent_type']]
|
81
|
+
|
82
|
+
|
83
|
+
matches = app_intent.entities.map { |e| e.keys.first }.inject({}) do |h, entity|
|
84
|
+
h[self.class.unscope_name(app_intent.skill_name, entity)] = adapt_intent[entity]
|
85
|
+
h
|
86
|
+
end
|
87
|
+
|
88
|
+
Charyf::Engine::Intent.new(app_intent.skill_name, app_intent.controller, app_intent.action, confidence, matches)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Adapt
|
2
|
+
class RoutingBuilder
|
3
|
+
|
4
|
+
class InvalidState < StandardError; end
|
5
|
+
|
6
|
+
class Intent
|
7
|
+
attr_reader :skill_name, :name, :controller, :action, :entities
|
8
|
+
|
9
|
+
def initialize(skill_name, name)
|
10
|
+
@skill_name = skill_name
|
11
|
+
@name = name
|
12
|
+
@controller = nil
|
13
|
+
@action = nil
|
14
|
+
|
15
|
+
@entities = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def required(entity)
|
19
|
+
entity = Adapt::Intent::Processor.scoped_name(@skill_name, entity)
|
20
|
+
@entities << {entity => :required}
|
21
|
+
|
22
|
+
return self
|
23
|
+
end
|
24
|
+
|
25
|
+
def optional(entity)
|
26
|
+
entity = Adapt::Intent::Processor.scoped_name(@skill_name, entity)
|
27
|
+
@entities << {entity => :optional}
|
28
|
+
|
29
|
+
return self
|
30
|
+
end
|
31
|
+
|
32
|
+
def route_to(controller, action)
|
33
|
+
@controller = controller
|
34
|
+
@action = action
|
35
|
+
end
|
36
|
+
end # End of Intent.class
|
37
|
+
|
38
|
+
def initialize(skill_name)
|
39
|
+
@skill_name = skill_name
|
40
|
+
|
41
|
+
@keywords = {}
|
42
|
+
@regexps = []
|
43
|
+
@intents = []
|
44
|
+
end
|
45
|
+
|
46
|
+
def register_keywords(category, word, *words)
|
47
|
+
words = [word] + words
|
48
|
+
|
49
|
+
(@keywords[Adapt::Intent::Processor.scoped_name(@skill_name, category)] ||= []).push(words).flatten!
|
50
|
+
end
|
51
|
+
|
52
|
+
def register_regex(regex)
|
53
|
+
@regexps << scope_regex(regex)
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def intent(name)
|
58
|
+
intent = Intent.new(@skill_name, Adapt::Intent::Processor.scoped_name(@skill_name,name.to_s.gsub(' ', '')))
|
59
|
+
@intents << intent
|
60
|
+
|
61
|
+
intent
|
62
|
+
end
|
63
|
+
|
64
|
+
def build(engine, intent_builder_class)
|
65
|
+
@keywords.each do |group, words|
|
66
|
+
words.each do |word|
|
67
|
+
engine.register_entity(word, group)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
@regexps.each do |regexp|
|
72
|
+
engine.register_regex_entity(regexp)
|
73
|
+
end
|
74
|
+
|
75
|
+
@intents.each do |intent|
|
76
|
+
builder = intent_builder_class.new(intent.name)
|
77
|
+
|
78
|
+
intent.entities.each do |entity|
|
79
|
+
entity, method = entity.first
|
80
|
+
case method
|
81
|
+
when :required
|
82
|
+
builder.require(entity)
|
83
|
+
when :optional
|
84
|
+
builder.optionally(entity)
|
85
|
+
else
|
86
|
+
raise InvalidState.new('You should never end up here')
|
87
|
+
end
|
88
|
+
|
89
|
+
adapt_intent = builder.build
|
90
|
+
engine.register_intent_parser(adapt_intent)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
@intents
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def scope_regex(regex)
|
100
|
+
regex.to_s.gsub(/\(\?P\<(.*)\>/, "(?P<#{Adapt::Intent::Processor.scoped_name(@skill_name, '\1').gsub('.', '_')}>")
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
data/lib/adapt-charyf.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'charyf'
|
2
|
+
require_relative 'adapt/processor'
|
3
|
+
|
4
|
+
module Adapt
|
5
|
+
class Extension < Charyf::Extension
|
6
|
+
|
7
|
+
generators do
|
8
|
+
require_relative 'adapt/generators/intent/intent_generator'
|
9
|
+
end
|
10
|
+
|
11
|
+
config.generators.skill_hooks :intents, :adapt => true
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adapt-charyf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Ludvigh
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: charyf
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pycall
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.15'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Charyf intent processor wrapper for MycroftAI/adapt library
|
98
|
+
email:
|
99
|
+
- richard.ludvigh@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- adapt-charyf.gemspec
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- lib/adapt-charyf.rb
|
116
|
+
- lib/adapt/generators/intent/intent_generator.rb
|
117
|
+
- lib/adapt/generators/intent/templates/intents/adapt_private.rb.tt
|
118
|
+
- lib/adapt/generators/intent/templates/intents/adapt_public.rb.tt
|
119
|
+
- lib/adapt/processor.rb
|
120
|
+
- lib/adapt/routing_builder.rb
|
121
|
+
- lib/adapt/version.rb
|
122
|
+
homepage: https://github.com/Charyf/charyf-adapt-processor
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message: |
|
127
|
+
Make sure MycroftAI/adapt python library is installed [https://github.com/MycroftAI/adapt].
|
128
|
+
Also set the ENV[PYTHON] variable to python executable with the library installed.
|
129
|
+
|
130
|
+
Read -> Speak -> Chat!
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.1'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.6.8
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Charyf intent processor wrapper for MycroftAI/adapt library
|
150
|
+
test_files: []
|