Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TigreGotico/palavreado
dead simple keyword based intent parser
https://github.com/TigreGotico/palavreado
Last synced: about 2 months ago
JSON representation
dead simple keyword based intent parser
- Host: GitHub
- URL: https://github.com/TigreGotico/palavreado
- Owner: TigreGotico
- License: apache-2.0
- Created: 2021-04-29T18:24:49.000Z (over 3 years ago)
- Default Branch: dev
- Last Pushed: 2024-10-25T22:25:32.000Z (2 months ago)
- Last Synced: 2024-11-09T03:08:33.734Z (about 2 months ago)
- Language: Python
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-mycroft-community - Project Link
README
# Palavreado
*A dead-simple keyword based intent parser*
## Example
```python
from palavreado import IntentContainer, IntentCreatorcontainer = IntentContainer()
# keywords
intent = IntentCreator("hello"). \
require('hello', ['hello', 'hi', 'how are you', "what's up"]).\
optionally("world", ["world"])
container.add_intent(intent)# regex
rx = r'\b(at|in|for) (?P.*)'
intent = IntentCreator("time_in_location"). \
require_regex("Location", rx)\
.require("time", ["time"])
container.add_intent(intent)# keyword extraction patterns
intent = IntentCreator("buy"). \
require_autoregex('item',
['buy {item}',
'purchase {item}',
'get {item}',
'get {item} for me'])
container.add_intent(intent)container.calc_intent('hello world')
# {'conf': 1.0,
# 'keywords': {'hello': 'hello', 'world': 'world'},
# 'name': 'hello',
# 'utterance': 'hello world',
# 'utterance_remainder': ''}
container.calc_intent('hello bob')
# {'conf': 0.9666666666666667,
# 'keywords': {'hello': 'hello'},
# 'name': 'hello',
# 'utterance': 'hello bob',
# 'utterance_remainder': 'bob'}
container.calc_intent('hello')
# {'conf': 1.0,
# 'keywords': {'hello': 'hello'},
# 'name': 'hello',
# 'utterance': 'hello',
# 'utterance_remainder': ''}container.calc_intent('buy milk')
# {'conf': 0.8625,
# 'keywords': {'item': 'milk'},
# 'name': 'buy',
# 'utterance': 'buy milk',
# 'utterance_remainder': 'buy'}container.calc_intent('what time is it in London')
#{'conf': 0.8979999999999999,
# 'keywords': {'Location': 'London', 'time': 'time'},
# 'name': 'time_in_location',
# 'utterance': 'what time is it in London',
# 'utterance_remainder': 'what is it in'}```