首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure认知文本翻译服务在输入html时没有返回适当的响应

Azure认知文本翻译服务在输入html时没有返回适当的响应
EN

Stack Overflow用户
提问于 2022-11-09 09:17:13
回答 1查看 37关注 0票数 0

我使用的是非常简单的文本翻译服务,但是我的输入是" html“字符串,当响应成功返回时,内联html文本和样式属性会被错误地放置。不知道为什么会发生。我还尝试使用相同的HTML输入(检查了输入HTML的XML解析正确性)直接调用API,而不通过postman调用任何代理代码,但问题是相同的,文本和标记到处都是错误的。请帮帮忙。

API调用:

代码语言:javascript
复制
https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es&textType=html" 

输入有效载荷:

代码语言:javascript
复制
[{text: "<div class=\"customClassCode\"><p><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">Simple text should be displayed and translated to the </span><a href=\"https://www.google.com\" rel=\"noopener noreferrer\" target=\"_blank\" class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">new that</a><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\"> were choosenHow we need to understand that it is so bad experience</span></p></div>"}]

响应(文本翻译成功后,Azure认知服务)

代码语言:javascript
复制
<div class="customClassCode"><p><span class="ql-size-xlargeplus" style="background-color: rgb(0, 128, 128);">El texto simple debe mostrarse y traducirse a los </span><a href="https://www.google.com" rel="noopener noreferrer" target="_blank" class="ql-size-xlargeplus" style="background-color: rgb(0, 128, 128);">nuevos</a> que <span class="ql-size-xlargeplus" style="background-color: rgb(0, 128, 128);"> se eligieronCómo debemos entender que es una experiencia tan mala</span></p></div>

问题:响应中的行在其中提到"nuevos“格式,应该是基于输入文本的"nuevos”(都在锚标签内),这并不是因为某种奇怪的原因而发生的。

EN

回答 1

Stack Overflow用户

发布于 2022-11-10 13:06:27

在从我身边复制问题后,我发现问题是空间问题。给出你提供的输入文本,

代码语言:javascript
复制
[{"text": "<div class=\"customClassCode\"><p><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">Simple text should be displayed and translated to the </span><a href=\"https://www.google.com\" rel=\"noopener noreferrer\" target=\"_blank\" class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">new that</a><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\"> were choosenHow we need to understand that it is so bad experience</span></p></div>"}]

请求Url: https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es&textType=html 请求类型: Post

收到邮递员的回复如下所示,

接下来,尝试提供如下所示的输入文本,

代码语言:javascript
复制
[{"text": "<div class=\"customClassCode\"><p><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">Simple text should be displayed and translated to the </span><a href=\"https://www.google.com\" rel=\"noopener noreferrer\" target=\"_blank\" class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">newthat</a><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\"> were choosenHow we need to understand that it is so bad experience</span></p></div>"}]

收到邮递员的回复如下所示,

`在技术上,在这种情况下,使用空格作为分隔符。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74372426

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档