Skip to main content

Yoctol Natural Language Understanding SDK

Project description

# yoctol-nlu-py
Yoctol Natural Language Understanding SDK for python.

## Install
Use Python3.
```
pip install yoctol-nlu
```

## Usage

### Intent Classifier Service

For new user:
```python
from time import sleep
from ynlu import IntentClassifierClient

client = IntentClassifierClient(
token='TOKEN',
)

# create a classifier
# If the name exist, will use the existed one.
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.
client.add_intent_utterance_pairs([
{'intent': '打招呼', 'utterance': '嗨'},
{'intent': '感謝', 'utterance': '謝謝'},
{'intent': '說再見', 'utterance': '再見'},
{'intent': '打招呼', 'utterance': '早安'},
{'intent': '打招呼', 'utterance': '你好'},
{'intent': '感謝', 'utterance': '非常感謝'},
{'intent': '說再見', 'utterance': '掰掰'},
{'intent': '感謝', 'utterance': '有你真好'},
{'intent': '說再見', 'utterance': '下次見'},
])

client.train() # async train

while True:
if client.classifier_is_training():
sleep(1)
continue
break

result = client.predict('你好嗎') # This is a action without side-effects
'''
>>> result
[{'score': 0.7828801870346069, 'intent': '打招呼'},
{'score': 0.11771836876869202, 'intent': '感謝'},
{'score': 0.0994015485048294, 'intent': '說再見'}]
'''
```

For existing classifier:
```python
from ynlu import IntentClassifierClient

client = IntentClassifierClient(
token='TOKEN',
)

client.set_classifier(classifier_id='CLASSIFIER_ID')

result = client.predict('你好嗎')
```

Project details


Release history Release notifications

History Node

0.7.1

History Node

0.7.0

History Node

0.6.0

History Node

0.5.0

History Node

0.4.0

This version
History Node

0.3.0

History Node

0.2.4

History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
yoctol_nlu-0.3.0-py3-none-any.whl (7.3 kB) Copy SHA256 hash SHA256 Wheel 3.5 Jul 17, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page