如何使用curl命令为Watson NLU指定输入文件?

如何使用curl命令为Watson NLU指定输入文件?,curl,nlp,ibm-watson,Curl,Nlp,Ibm Watson,我有一个文本文件,我想通过curl命令输入到Watson的自然语言理解服务中,我想知道如何在传递给服务的数据上指出这一点。我已经让它工作使用一个网址,但想使用不同的来源。在下面的示例中,我想用文件名替换“我喜欢苹果!我不喜欢桔子”。谢谢 curl -X POST -u "apikey:{apikey}" \ "{url}/v1/analyze?version=2019-07-12" \ --request POST \ --header "Content-Type: application/js

我有一个文本文件,我想通过curl命令输入到Watson的自然语言理解服务中,我想知道如何在传递给服务的数据上指出这一点。我已经让它工作使用一个网址,但想使用不同的来源。在下面的示例中,我想用文件名替换“我喜欢苹果!我不喜欢桔子”。谢谢

curl -X POST -u "apikey:{apikey}" \
"{url}/v1/analyze?version=2019-07-12" \
--request POST \
--header "Content-Type: application/json" \
--data '{
  "text": "I love apples! I do not like oranges.",
  "features": {
    "sentiment": {
      "targets": [
        "apples",
        "oranges",
        "broccoli"
      ]
    },
    "keywords": {
      "emotion": true
    }
  }
}'
您可以将--data参数作为.json文件提供,以包含文本,但还需要包含其他查询参数

从API文档中-

其中parameters.json类似于:

 {
   "text": "IBM is an American multinational technology company headquartered in Armonk, New York, United States, with operations in over 170 countries.",
   "features": {
     "entities": {
       "emotion": true,
       "sentiment": true,
       "limit": 2
     },
     "keywords": {
       "emotion": true,
       "sentiment": true,
       "limit": 2
     }
   }
 }
 {
   "text": "IBM is an American multinational technology company headquartered in Armonk, New York, United States, with operations in over 170 countries.",
   "features": {
     "entities": {
       "emotion": true,
       "sentiment": true,
       "limit": 2
     },
     "keywords": {
       "emotion": true,
       "sentiment": true,
       "limit": 2
     }
   }
 }