因此,我试图在查询上传递多个ids (“概念数组”),使用的是IBM概念洞察上的Curl。根据这个站点上的文档,我应该能够做到这一点,但是我不知道如何使它工作-> search。
如果我使用链接上标出的“示例请求”并修改它,至少在同一个get数据命令上添加另一个查询,我认为这就是它的工作方式。
curl -u "{username}":"{password}" -G -d "ids=[\"/graphs/wikipedia/en-20120601/concepts/Artificial_intelligence\", \"/graphs/wikipedia/en-20120601/concepts/HTML\"]" "https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/public/ibmresearcher/conceptual_search"当我输入该命令时,不会得到任何结果。连一个错误都没有。
有什么想法吗?
请不要指出显而易见的..。当然,我将"{username}":"{password}“替换为我的凭据。:)
发布于 2016-04-22 14:48:22
而不是-d "ids=...",您应该使用--data-urlencode "ids=..."
这应该是可行的:
curl -u "%ci-username%":"%ci-password%" -G --data-urlencode "ids=[\"/graphs/wikipedia/en-20120601/concepts/Artificial_intelligence\", \"/graphs/wikipedia/en-20120601/concepts/HTML\"]" "https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/public/ibmresearcher/conceptual_search"发布于 2016-04-22 02:26:46
在您的示例中,ids是在POST请求中作为主体的一部分发送的,但是API希望它在查询中,请求是GET。
试试下面的curl命令:
curl -u "{username}":"{password}" "https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/public/ibmresearcher/conceptual_search?ids=%5B%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%2FArtificial_intelligence%22%2C%20%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%HTML%22%5D&cursor=0&limit=10"它将使用两个概念(、人工智能、和HTML )进行概念搜索。
输出:
{
"query_concepts": [{
"id": "/graphs/wikipedia/en-20120601/concepts/Artificial_intelligence",
"label": "Artificial intelligence"
}, {
"id": "/graphs/wikipedia/en-20120601/concepts/Machine_learning",
"label": "Machine learning"
}],
"results": [{
"explanation_tags": [{
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Machine_Learning",
"label": "Machine Learning"
},
"score": 0.99816346,
"parts_index": 0,
"text_index": [
1024,
1089
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Machine_Intelligence",
"label": "Machine Intelligence"
},
"score": 0.9945005,
"parts_index": 0,
"text_index": [
2097,
2117
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Artificial_intelligences",
"label": "Artificial intelligences"
},
"score": 0.9945005,
"parts_index": 0,
"text_index": [
2557,
2580
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/International_Conference_on_Machine_Learning",
"label": "International Conference on Machine Learning"
},
"score": 0.9817866,
"parts_index": 0,
"text_index": [
2658,
2712
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/ICML",
"label": "ICML"
},
"score": 0.9817866,
"parts_index": 0,
"text_index": [
2714,
2718
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Feature_selection",
"label": "Feature selection"
},
"score": 0.97459584,
"parts_index": 1,
"text_index": [
1521,
1538
]
}],
"id": "/corpora/public/ibmresearcher/documents/il-NOAMS",
"label": "Slonim, Noam",
"score": 0.99739265
}]
}您需要对json数组进行url编码,以便对以下概念进行编码:
["/graphs/wikipedia/en-20120601/concepts/Artificial_intelligence", "/graphs/wikipedia/en-20120601/concepts/Machine_learning"]使用像http://meyerweb.com/eric/tools/dencoder/这样的在线URL编码器
%5B%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%2FArtificial_intelligence%22%2C%20%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%HTML%22%5D最后,使用ids=<encoded array>作为URL的一部分。
https://stackoverflow.com/questions/36779022
复制相似问题