Open lhjner opened 5 years ago
我发现似乎是他读数据的方式有点问题
我发现似乎是他读数据的方式有点问题
对,没错,是读取.json文件时的错误,跟.json文件本身没有关系
同学,你有没有遇到用BucketIterator生成迭代器会生成一个无限循环的迭代器的情况?这个迭代器有问题么?
2019-12-07
lxyyy123
发件人:lhjner notifications@github.com 发送时间:2019-12-04 20:45 主题:Re: [lx865712528/EMNLP2018-JMEE] json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1) (#20) 收件人:"lx865712528/EMNLP2018-JMEE"EMNLP2018-JMEE@noreply.github.com 抄送:"xiaoya6666"lxyyy123@163.com,"Comment"comment@noreply.github.com
我发现似乎是他读数据的方式有点问题 对,没错,是读取.json文件时的错误,跟.json文件本身没有关系 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
把对应那行的数据删了就行了,有个文件夹里面有训练集列表
@lhjner 您好,请问您知道这个json问题怎么改吗?
@lhjner hello,我也遇到这个问题,请问你解决了吗?可以分享一下解决方法吗?
@lhjner 您好,请问您知道这个json问题怎么改吗?
不是json文件的问题,是他读取文件的代码有问题,他是按行读取然后对每行解析成json对象,但是我预处理后的json文件最外层是list,照他这个方式第一行读出来是个“[/n”;可以尝试一下把整个文件读进来解析成一个json对象然后再迭代处理。 def parse_example(self, path, fields): examples = []
with open(path, "r", encoding="utf-8") as f:
json_input = json.load(f)
for line in json_input:
ex = self.parse_sentence(line, fields)
if ex is not None:
examples.append(ex)
您好,我用stanfordnlp处理了数据,遇到json.decoder.JSONDecodeError问题,很多人说是json文件的问题,但是我用了sample.json也遇到同样问题. 希望得到您的解答,谢谢! Namespace(batch=128, dev='ace-05-splits/dev.json', device='cpu', earlystop=999999, epochs=9223372036854775807, finetune=None, hps=None, l2decay=0, lr=0.001, maxnorm=3, optimizer='adam', out='out', restart=999999, seed=42, test='ace-05-splits/test.json', train='ace-05-splits/sample.json', webd='word2vec.txt') Running on cpu loading corpus from ace-05-splits/sample.json Traceback (most recent call last): File "enet/run/ee/runner.py", line 241, in
EERunner().run()
File "enet/run/ee/runner.py", line 99, in run
keep_events=1)
File "/home/lhj/coding/EMNLP2018-JMEE-master/enet/corpus/Data.py", line 191, in init
super(ACE2005Dataset, self).init(path, fields, **kwargs)
File "/home/lhj/coding/EMNLP2018-JMEE-master/enet/corpus/Corpus.py", line 20, in init
examples = self.parse_example(path, fields)
File "/home/lhj/coding/EMNLP2018-JMEE-master/enet/corpus/Data.py", line 202, in parse_example
jl = json.loads(line,encoding="utf-8")
File "/home/lhj/anaconda3/envs/jmee/lib/python3.5/json/init.py", line 319, in loads
return _default_decoder.decode(s)
File "/home/lhj/anaconda3/envs/jmee/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/lhj/anaconda3/envs/jmee/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)