我正在尝试使用mapReduce框架来开发僧伽罗语书籍的搜索引擎。
在mapReduce框架中,有以下功能。
def execute(self, data, mapper, reducer):
print(data)
for line in data:
record = json.loads(line)
mapper(record)
for key in self.intermediate:
reducer(key, self.intermediate[key])
#jenc = json.JSONEncoder(encoding='latin-1')
jenc = json.JSONEncoder()
banana = {}
for item in self.result:
print(jenc.encode(item))
#romeo = {item[0] : item[1]}
#banana.update(romeo)
#print json.dumps(banana)
但是当我输入sinhala文本输入时,会出现如下错误
Traceback (most recent call last):
File "/home/ashirwada/Project/Project/inverted_index.py", line 67, in <module>
mr.execute(text, mapper, reducer)
File "/home/ashirwada/Project/Project/MapReduce.py", line 18, in execute
record = json.loads(line)
File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/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)
为什么会出现此错误?