snipsco / snips-nlu

Snips Python library to extract meaning from text
https://snips-nlu.readthedocs.io
Apache License 2.0
3.88k stars 515 forks source link

[Windows] Error when loading JSON dataset from the tutorial #870

Open ncsrikar opened 4 years ago

ncsrikar commented 4 years ago

datasetyaml.txt datasetjson.txt Error: The yaml files and Json files uploaded as txt. I created the json just as told in tutorial. From the yaml in the example itself. Traceback (most recent call last): File "snips.py", line 12, in json.load(f) File "C:\Users\Srikar\AppData\Local\Programs\Python\Python37\lib\site-packages\simplejson__init.py", line 471, in load use_decimal=use_decimal, **kw) File "C:\Users\Srikar\AppData\Local\Programs\Python\Python37\lib\site-packages\simplejson\init__.py", line 525, in loads return _default_decoder.decode(s) File "C:\Users\Srikar\AppData\Local\Programs\Python\Python37\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "C:\Users\Srikar\AppData\Local\Programs\Python\Python37\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

adrienball commented 4 years ago

Could you please provide the code you are using to load the JSON? We can't help you without that.

ncsrikar commented 4 years ago

Sorry, I forgot to add the code. Here it is.

`from snips_nlu import SnipsNLUEngine import io import simplejson as json

from snips_nlu import SnipsNLUEngine from snips_nlu.default_configs import CONFIG_EN engine = SnipsNLUEngine(config=CONFIG_EN)

default_engine = SnipsNLUEngine() with io.open("dataset.json") as f: dataset = json.load(f)

engine.fit(dataset)`

adrienball commented 4 years ago

I can't reproduce but anyway it's not related to Snips NLU, if the json library can't load your json file it means that it's not a valid json. I suggest you double check the file you are trying to load and make sure it's valid. Best

ncsrikar commented 4 years ago

The json was created by the command given in the Snips NLU tutorial. Anyway thanks for your help.

erwanlc commented 4 years ago

Hi, I have exactly the same issue. I followed the documentation on how Training Dataset Format. I copy paste the flight example but when I try to load the generated JSON, I get the error: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@ncsrikar did you find a solution for that ?

[EDIT] I found the issue, it appears that on my Windows, the json generated by the command snips-nlu was somehow corrupted. By copy pasting the content of the file in a newly created json document, it solves the problem.

adrienball commented 4 years ago

This issue seems to be windows specific. This stackoverflow issue may help: https://stackoverflow.com/questions/16573332/jsondecodeerror-expecting-value-line-1-column-1-char-0