forked from pool/python-padaos
Accepting request 698064 from home:pgajdos
- version update to 0.1.10 * Fix space issue - added sources https://github.com/MycroftAI/padaos/issues/7 + LICENSE + test_padaos.py OBS-URL: https://build.opensuse.org/request/show/698064 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-padaos?expand=0&rev=11
This commit is contained in:
parent
6227503427
commit
fe86fffa2f
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright 2018 Matthew D. Scholefield
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3
padaos-0.1.10.tar.gz
Normal file
3
padaos-0.1.10.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2ac05fcbc826873c574568aa5ce09945d6ea987bee10399e766eb8f7c6356d72
|
||||
size 3231
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:47be66fed43f35b5347722aa45ee3c2df64ea1718cf805b2f1da81ed2c98ee83
|
||||
size 3221
|
@ -1,3 +1,13 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Apr 26 06:09:11 UTC 2019 - pgajdos@suse.com
|
||||
|
||||
- version update to 0.1.10
|
||||
* Fix space issue
|
||||
- added sources
|
||||
https://github.com/MycroftAI/padaos/issues/7
|
||||
+ LICENSE
|
||||
+ test_padaos.py
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Feb 2 22:46:55 UTC 2019 - Antonio Larrosa <alarrosa@suse.com>
|
||||
|
||||
|
@ -20,13 +20,17 @@
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-padaos
|
||||
Version: 0.1.9
|
||||
Version: 0.1.10
|
||||
Release: 0
|
||||
Summary: An intent parser
|
||||
License: MIT
|
||||
Group: Development/Languages/Python
|
||||
Url: http://github.com/MatthewScholefield/padaos
|
||||
Source: https://files.pythonhosted.org/packages/source/p/padaos/padaos-%{version}.tar.gz
|
||||
Source0: https://files.pythonhosted.org/packages/source/p/padaos/padaos-%{version}.tar.gz
|
||||
# https://github.com/MycroftAI/padaos/issues/7
|
||||
Source1: https://raw.githubusercontent.com/MycroftAI/padaos/master/LICENSE
|
||||
Source2: https://raw.githubusercontent.com/MycroftAI/padaos/master/test_padaos.py
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
@ -42,6 +46,7 @@ regex. Each intent is a single compiled regex matcher.
|
||||
|
||||
%prep
|
||||
%setup -q -n padaos-%{version}
|
||||
cp %{SOURCE1} %{SOURCE2} .
|
||||
|
||||
%build
|
||||
%python_build
|
||||
@ -50,7 +55,11 @@ regex. Each intent is a single compiled regex matcher.
|
||||
%python_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%pytest
|
||||
|
||||
%files %{python_files}
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
%{python_sitelib}/padaos.*
|
||||
%{python_sitelib}/__pycache__/padaos.*
|
||||
|
53
test_padaos.py
Normal file
53
test_padaos.py
Normal file
@ -0,0 +1,53 @@
|
||||
from padaos import IntentContainer
|
||||
|
||||
|
||||
class TestIntentContainer:
|
||||
def setup(self):
|
||||
self.container = IntentContainer()
|
||||
|
||||
def test(self):
|
||||
self.container.add_intent('hello', [
|
||||
'hello', 'hi', 'how are you', "what's up"
|
||||
])
|
||||
self.container.add_intent('buy', [
|
||||
'buy {item}', 'purchase {item}', 'get {item}', 'get {item} for me'
|
||||
])
|
||||
self.container.add_entity('item', [
|
||||
'milk', 'cheese'
|
||||
])
|
||||
self.container.add_intent('drive', [
|
||||
'drive me to {place}', 'take me to {place}', 'navigate to {place}'
|
||||
])
|
||||
self.container.add_intent('eat', [
|
||||
'eat {fruit}', 'eat some {fruit}', 'munch on (some|) {fruit}'
|
||||
])
|
||||
self.container.compile()
|
||||
assert self.container.calc_intent('hello')['name'] == 'hello'
|
||||
assert not self.container.calc_intent('bye')['name']
|
||||
assert self.container.calc_intent('buy milk') == {
|
||||
'name': 'buy', 'entities': {'item': 'milk'}
|
||||
}
|
||||
assert self.container.calc_intent('eat some bananas') == {
|
||||
'name': 'eat', 'entities': {'fruit': 'bananas'}
|
||||
}
|
||||
|
||||
def test_case(self):
|
||||
self.container.add_intent('test', ['Testing cAPitalizAtion'])
|
||||
assert self.container.calc_intent('teStiNg CapitalIzation')['name'] == 'test'
|
||||
|
||||
def test_punctuation(self):
|
||||
self.container.add_intent('test', ['Test! Of: Punctuation'])
|
||||
assert self.container.calc_intent('test of !punctuation...')['name'] == 'test'
|
||||
|
||||
def test_spaces(self):
|
||||
self.container.add_intent('test', ['this is a test'])
|
||||
assert self.container.calc_intent('thisisatest')['name'] is None
|
||||
self.container.add_intent('test2', ['this has(one|two)options'])
|
||||
assert self.container.calc_intent('this has two options')['name'] == 'test2'
|
||||
assert self.container.calc_intent('th is is a test')['name'] is None
|
||||
|
||||
self.container.add_intent('test3', ['I see {thing} (in|on) {place}'])
|
||||
assert self.container.calc_intent('I see a bin test')['name'] is None
|
||||
assert self.container.calc_intent('I see a bin in there') == {
|
||||
'name': 'test3', 'entities': {'thing': 'a bin', 'place': 'there'}
|
||||
}
|
Loading…
Reference in New Issue
Block a user