简体   繁体   中英

Unable to load Sentihood dataset Json file in Python

Sentihood Dataset is a dataset for Target Aspect-based Sentiment Analysis. Its Test and Train file are available in Json format. However, when I try loading it using the json module of python, it gives the following error-

JSONDecodeError: Expecting value: line 7 column 1 (char 6)

Is there some other way of loading Json files? I don't have much knowledge of Json and hence would appreciate any help. Link for Sentihood dataset : https://github.com/uclmr/jack/tree/master/data/sentihood

My code is simply:

with open("sentihood-train.json", "r") as read_it: 
    data = json.load(read_it)

When file is reading json.loads needs file content which can be done by following way. Pass f.read() in json.loads line.

import json
with open("test.json",mode='r') as f:
    d = json.loads(f.read())  # changed this line
    print(d)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM