问题描述
我使用以下命令运行从 here 获取的 docker 映像:
docker run -e ANNOTATORS=truecase,ner -p 9000:9000 -ti nlpBox/corenlp
使用前端时,可以很好地识别人/实体 john smith:
前端发出这个:
http://localhost:9000/?properties=%7B%22annotators%22%3A%20%22tokenize%2Cssplit%2Cner%22%2C%20%22date%22%3A%20%222021-07-23T11%3A18%3A21%22%7D&pipelineLanguage=en
解码:
http://localhost:9000/?properties={"annotators": "tokenize,ssplit,ner","date": "2021-07-23T11:18:21"}&pipelineLanguage=en
我的 C# 代码是:
var client = new RestClient(@"http://localhost:9000/")
{
Timeout = 5000 // default 100 s
};
var request = new RestRequest(Method.POST)
{
RequestFormat = DataFormat.Json
};
request.AddParameter("properties",@"{""annotators"":""truecase,tokenize,ner"",""date"": ""2021-07-23T11:29:23""}",ParameterType.QueryString);
request.AddParameter("pipelineLanguage","en",ParameterType.QueryString);
request.AddHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
request.AddBody(@"hello john smith" );
var response = client.Execute(request);
不幸的是,它没有在返回的 JSON 中返回/识别此人:
剪辑
{
"index": 3,"word": "john","originalText": "john","lemma": "john","characterOffsetBegin": 7,"characterOffsetEnd": 11,"pos": "NNP","ner": "O","truecase": "INIT_UPPER","truecaseText": "John","before": " ","after": " "
},{
"index": 4,"word": "smith","originalText": "smith","lemma": "smith","characterOffsetBegin": 12,"characterOffsetEnd": 17,"truecaseText": "Smith","after": ""
},
剪辑
如果我将 John Smith 大写(我不想这样做),我会得到正确答案:
{
"index": 3,"word": "John","originalText": "John","lemma": "John","ner": "PERSON","after": " "
},{
"index": 4,"word": "Smith","originalText": "Smith","lemma": "Smith","after": ""
},
我可以破解这个并确保每个单词都以大写字母开头,但在理想的世界中,我想避免这种情况。谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)