要将文档发送到 Cloud NLP API,我们使用以下 JSON 格式(根据文档)
{
"document":{
"type":"PLAIN_TEXT",
"content":"Joanne Rowling, who writes under the pen names J. K. Rowling and Robert Galbraith, is a British novelist and screenwriter who wrote the Harry Potter fantasy series. i am suffering without resolution.only communication coming about fees without knowledge of card.wrist ever banking experience."
},
"encodingType":"UTF8"
}
这种格式非常适合我正在使用的 curl 命令。
curl "https://language.googleapis.com/v1/documents:analyzeEntities?key=${API_KEY}" -s -X POST -H "Content-Type: application/json" --data-binary @request.json
但是,如果要添加多个文档,我该怎么做?我尝试了几种方法,例如在“文档”下制作字典列表。但它不起作用。其中一种尝试如下所示。
{
"document":{[{
"type":"PLAIN_TEXT",
"content":"Joanne Rowling, who writes under the pen names J. K. Rowling and Robert Galbraith, is a British novelist and screenwriter who wrote the Harry Potter fantasy series. i am suffering without resolution.only communication coming about fees without knowledge of card.wrist ever banking experience."
},
{
"type":"PLAIN_TEXT",
"content":"Joanne Rowling, who writes under the pen names J. K. Rowling and Robert Galbraith, is a British novelist and screenwriter who wrote the Harry Potter fantasy series. i am suffering without resolution.only communication coming about fees without knowledge of card.wrist ever banking experience."
}
]},
"encodingType":"UTF8"
}
我收到类似的错误
"message": "Invalid JSON payload received. Expected an object key or }.\n{\n\"document\":{[\n {\"\n ^",