Yoctol Natural Language Understanding SDK
Project description
# yoctol-nlu-py
Yoctol Natural Language Understanding SDK for python.
## Install
```
pip install yoctol-nlu
```
## Usage
### Intent Classifier Service
For new user:
```python
from ynlu import IntentClassifierClient
client = IntentClassifierClient(
token='TOKEN',
)
client.create_classifier(
name='clf_for_test'
)
# to get the classifier id:
# print(client.classifier_id)
# create intent, utterances pairs
# This is a idempotent action, since it will check every item if it is added before.
success, msg = client.add_intent_utterance_pairs([
{'intent': '打招呼', 'utterance': '嗨'},
{'intent': '感謝', 'utterance': '謝謝'},
{'intent': '說再見', 'utterance': '再見'},
{'intent': '打招呼', 'utterance': '早安'},
{'intent': '打招呼', 'utterance': '你好'},
{'intent': '感謝', 'utterance': '非常感謝'},
{'intent': '說再見', 'utterance': '掰掰'},
{'intent': '感謝', 'utterance': '有你真好'},
{'intent': '說再見', 'utterance': '下次見'},
])
if success:
train_success, msg = client.train()
if train_success:
result = client.predict('你好嗎') # This is a action without side-effects
```
For existing classifier:
```python
from ynlu import IntentClassifierClient
client = IntentClassifierClient(
token='TOKEN',
)
client.get_classifier(classifier_id='CLASSIFIER_ID')
result = client.predict('你好嗎')
```
Yoctol Natural Language Understanding SDK for python.
## Install
```
pip install yoctol-nlu
```
## Usage
### Intent Classifier Service
For new user:
```python
from ynlu import IntentClassifierClient
client = IntentClassifierClient(
token='TOKEN',
)
client.create_classifier(
name='clf_for_test'
)
# to get the classifier id:
# print(client.classifier_id)
# create intent, utterances pairs
# This is a idempotent action, since it will check every item if it is added before.
success, msg = client.add_intent_utterance_pairs([
{'intent': '打招呼', 'utterance': '嗨'},
{'intent': '感謝', 'utterance': '謝謝'},
{'intent': '說再見', 'utterance': '再見'},
{'intent': '打招呼', 'utterance': '早安'},
{'intent': '打招呼', 'utterance': '你好'},
{'intent': '感謝', 'utterance': '非常感謝'},
{'intent': '說再見', 'utterance': '掰掰'},
{'intent': '感謝', 'utterance': '有你真好'},
{'intent': '說再見', 'utterance': '下次見'},
])
if success:
train_success, msg = client.train()
if train_success:
result = client.predict('你好嗎') # This is a action without side-effects
```
For existing classifier:
```python
from ynlu import IntentClassifierClient
client = IntentClassifierClient(
token='TOKEN',
)
client.get_classifier(classifier_id='CLASSIFIER_ID')
result = client.predict('你好嗎')
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yoctol-nlu-0.2.1.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for yoctol_nlu-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c1515d5c6db43e3a5f1a5bdbb8a05213c582572f9a828c3a708441e36ed5b2 |
|
MD5 | e664ee88aee3a62822de786682ea9e16 |
|
BLAKE2b-256 | 9f4b332d730611abc32edff8b89396e2f7ab4bb06cf26d7b6ee3349e315b60d6 |