Closed kdenny closed 5 years ago
Hi @kdenny,
The dataset you're trying to pass to your engine seems to be a Dataset
object. Currently the Dataset
object is just an helper class used to create a JSON/dictionary dataset from other formats (only YAML currently).
The dataset you pass to the engine must be a dictionary.
From YAML files you can either use the CLI to convert the YAML dataset into a JSON dataset or you can do it directly in Python converting the Dataset
object into a dictionary using the (misleadingly named) Dataset.json
property:
import io
from snips_nlu import SnipsNLUEngine
from snips_nlu.dataset import Dataset
dataset_path = "path/to_a/yaml_dataset.yml"
with io.open(dataset_path) as f:
dataset = Dataset.from_yaml_files("en", [f])
nlu_engine = SnipsNLUEngine().fit(dataset.json)
Thanks @ClemDoum ! I had just figured this out on my own right before seeing this message.
Once #840 is merged and released, it will possible to directlty use a Dataset
object to fit a SnipsNLUEngine
.
Hi,
I have been trying to write a little Django module to: 1) read from a collection of Entity and Intent models 2) write a YAML write 3) create a snips dataset from this parsing model
I am currently completing steps 1 and 2 okay, but on step 3 the following error is occurring:
" File "/Users/kevindenny/Documents/snips-django/dj_snips/querybot/write_yaml.py", line 57, in make_nlu_model_yaml nlu_engine = nlu_engine.fit(dataset, force_retrain=False) File "/Users/kevindenny/Documents/snips-django/env/lib/python3.7/site-packages/snips_nlu/common/log_utils.py", line 30, in wrapped res = fn(*args, **kwargs) File "/Users/kevindenny/Documents/snips-django/env/lib/python3.7/site-packages/snips_nlu/nlu_engine/nlu_engine.py", line 94, in fit dataset = validate_and_format_dataset(dataset) File "/Users/kevindenny/Documents/snips-django/env/lib/python3.7/site-packages/snips_nlu/dataset/validation.py", line 32, in validate_and_format_dataset if dataset.get(VALIDATED, False): AttributeError: 'Dataset' object has no attribute 'get' "
Any insight into this is greatly appreciated :)