如何解决使用 C# 中的 Google Cloud Translation Service 根据拼写而不是其含义翻译单词
我有一个应用程序,用户可以在其中添加阿拉伯语和英语客户端,我的用例很简单:
为此,我使用了 Google Cloud Translation API
using System;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.Translation.V2;
class Program
{
static async Task Main(string[] args)
{
var jsonPath = "C:/gcloud/key.json";
var credential = GoogleCredential.FromFile(jsonPath);
var client = TranslationClient.Create(credential);
var text = "مراد"; // arabic name that is spelled "Mourad"
var response = client.TranslateText(text,LanguageCodes.English,LanguageCodes.arabic,TranslationModel.ServiceDefault);
Console.WriteLine(response.TranslatedText);
// current output "Intend"
// expected output "Mourad"
}
}
所以我的主要障碍是如何获得等效名称而不是文本(名称)的翻译 通过一个使用谷歌翻译的例子来说明:
因此,这将阿拉伯名称 مراد 翻译为 Inend,这是不正确的,就我而言,我想要“Mourad”。
我很难找到它,因为我不知道如何表达这种翻译。 所以我的问题很简单:如何使用 C# 中的 Google Cloud Translation Service 根据名称的拼写和含义翻译名称?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。