gpt4 book ai didi

org.apache.tika.language.translate.YandexTranslator类的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 07:39:31 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.tika.language.translate.YandexTranslator类的一些代码示例,展示了YandexTranslator类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YandexTranslator类的具体详情如下:
包路径:org.apache.tika.language.translate.YandexTranslator
类名称:YandexTranslator

YandexTranslator介绍

[英]An implementation of a REST client for the YANDEX Translate API. You can sign up for free access online on the API Key form and set your Application's User Key in the translator.yandex.properties file.
[中]YANDEXTranslate API的REST客户端的实现。您可以在API Key form上在线注册免费访问,并在translator.yandex.properties文件中设置应用程序的用户密钥。

代码示例

代码示例来源:origin: apache/tika

@Before
public void setUp() throws Exception {
  this.translator = new YandexTranslator();
}

代码示例来源:origin: apache/tika

@Override
public String translate(String text, String targetLanguage)
    throws TikaException, IOException {
  return this.translate(text, null, targetLanguage);
}

代码示例来源:origin: com.norconex.collectors/norconex-importer

@Override
public Translator createTranslator() {
  YandexTranslator t = new YandexTranslator();
  t.setApiKey(apiKey);
  return t;
}
@Override

代码示例来源:origin: apache/tika

@Override
public String translate(String text, String sourceLanguage,
    String targetLanguage) throws TikaException, IOException {
  if (!this.isAvailable()) {
    return text;

代码示例来源:origin: org.apache.tika/tika-translate

@Override
public String translate(String text, String sourceLanguage,
    String targetLanguage) throws TikaException, IOException {
  if (!this.isAvailable()) {
    return text;

代码示例来源:origin: apache/tika

@Test
public void test2UNDEFINED_DE_ES_Translation() {
  String inputText = "Guten Tag!!!";
  String expectedText = "Buen Día!!!";
  try{
   String transText = translator.translate(inputText, "es");
  assertNotNull("Text not translated", transText);
  assumeTrue(expectedText.equals(transText));
  }
  catch(TikaException e){
  e.printStackTrace();
  fail(e.getMessage());
  }
  catch(IOException e){
    e.printStackTrace();
    fail(e.getMessage());
  }
}

代码示例来源:origin: apache/tika

@Test
public void test1EN_ES_Translation() {
  String inputText = "Hello World!!!";
  String expectedText = "Hola Mundo!!!";
  try{
   String transText = translator.translate(inputText, "en", "es");
    assertNotNull("Text not translated", transText);
    assumeTrue(expectedText.equals(transText));
}
catch(TikaException e){
  e.printStackTrace();
  fail(e.getMessage());
}
catch(IOException e){
    e.printStackTrace();
    fail(e.getMessage());
  }
}

代码示例来源:origin: org.apache.tika/tika-translate

@Override
public String translate(String text, String targetLanguage)
    throws TikaException, IOException {
  return this.translate(text, null, targetLanguage);
}

代码示例来源:origin: apache/tika

@Test
public void test3UNDEFINED_IT_EN_Translation() {
  String inputText = "Buona Sera!!!";
  String expectedText = "Good Evening!!!";
  try{
    String transText = translator.translate(inputText, "en");
    assertNotNull("Text not translated", transText);
    assumeTrue(expectedText.equals(transText));
}
catch(TikaException e){
    e.printStackTrace();
    fail(e.getMessage());
}
  catch(IOException e){
    e.printStackTrace();
    fail(e.getMessage());
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com