IBM Watson Concept Insights 概念搜索使用 Curl 将 mutiple/an id 数组作为参数传递
IBM Watson Concept Insights conceptual search using Curl to pass mutiple/an array of ids as a parameter
因此,我正在尝试在 IBM Concept Insights 上使用 Curl 在查询中传递多个 ID ("Array of concept")。根据这个网站上的文档,我应该可以做到,但我不知道如何让它工作 -> http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/concept-insights/api/v2/?curl#conceptual_search
如果我使用 link 上提供的 "example request" 并将其修改为至少在同一个获取数据命令上添加另一个查询,这就是我认为它的工作方式。
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}”。 :)
在您的示例中,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
}]
}
您需要 url 对 json 数组进行编码,以便了解以下概念:
["/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 的一部分。
您应该使用 --data-urlencode "ids=..."
而不是 -d "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"
因此,我正在尝试在 IBM Concept Insights 上使用 Curl 在查询中传递多个 ID ("Array of concept")。根据这个网站上的文档,我应该可以做到,但我不知道如何让它工作 -> http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/concept-insights/api/v2/?curl#conceptual_search
如果我使用 link 上提供的 "example request" 并将其修改为至少在同一个获取数据命令上添加另一个查询,这就是我认为它的工作方式。
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}”。 :)
在您的示例中,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
}]
}
您需要 url 对 json 数组进行编码,以便了解以下概念:
["/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 的一部分。
您应该使用 --data-urlencode "ids=..."
-d "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"