2016-04-21 2 views
0

IBM Concept InsightsのCurlを使用して、複数のID(「概念の配列」)をクエリーに渡そうとしています。このサイトのドキュメントによると、私はそれを行うことができるはずですが、それを動作させる方法を理解できません - >http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/concept-insights/api/v2/?curl#conceptual_searchIBM Watson Concept Insights Curlを使用した概念検索で、複数のIDの配列をパラメーターとして渡す

リンク上でprodivededを使用し、少なくとも同じget dataコマンドで別のクエリを追加すると、これはうまくいくと思います。

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}」に置き換えています。 :)あなたの例では

答えて

1

代わりの-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" 
+0

これはトリックでした! – blacknred0

0

を、idsPOST要求に身体の一部として送信されているが、APIは、クエリとをGET される要求であることを期待します。それは二つの概念人工知能HTMLを使用して、概念検索を行います

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" 

は以下のcurlコマンドを試してみてください。

出力:

{ 
    "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する必要があります。最後に使用しhttp://meyerweb.com/eric/tools/dencoder/

%5B%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%2FArtificial_intelligence%22%2C%20%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%HTML%22%5D 

のようなオンラインのURLエンコーダを使用して

["/graphs/wikipedia/en-20120601/concepts/Artificial_intelligence", "/graphs/wikipedia/en-20120601/concepts/Machine_learning"] 

URLの一部としてids=<encoded array>

+1

おかげで、ドイツ語を!意味がある。おそらく、複数のIDが使用されるかどうかを示すためにIBMのドキュメントを更新する必要があり、JSON配列をURL用にエンコードする必要があります。 – blacknred0

関連する問題