我想从文本中使用Spacy的NER为德文文本提取命名实体。我将该服务公开为REST POST请求,该请求将源文本作为输入并返回名称实体(人员,位置,组织)列表的字典(地图)。这些服务使用Linux服务器上托管的Flask Restplus进行公开。其他模板无法正确解析json rest api响应
考虑了样本的文字,我获得以下的REST API通过扬鞭UI曝光使用POST请求响应:
{
"ner_locations": [
"Deutschland",
"Niederlanden"
],
"ner_organizations": [
"Miele & Cie. KG",
"Bayer CropScience AG"
],
"ner_persons": [
"Sebastian Krause",
"Alex Schröder"
]
}
当我使用Spring的RestTemplate到发表于在Linux服务器从春天启动托管API请求应用程序(在Eclipse中的Windows操作系统上)。 json解析正确完成。我添加了以下使用UTF-8编码的行。
restTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
但是当我部署的Linux机器和POST请求在今年春季启动应用程序,为NER标注API,该ner_persons不能正确解析。虽然远程调试,我得到如下回应
{
"ner_locations": [
"Deutschland",
"Niederlanden"
],
"ner_organizations": [
"Miele & Cie. KG",
"Bayer CropScience AG"
],
"ner_persons": [
"Sebastian ",
"Krause",
"Alex ",
"Schröder"
]
}
我无法理解为什么,但人没有组织的情况下,会出现这种奇怪的行为。