本文整理了Java中org.apache.tika.language.translate.YandexTranslator
类的一些代码示例,展示了YandexTranslator
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YandexTranslator
类的具体详情如下:
包路径:org.apache.tika.language.translate.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());
}
}
内容来源于网络,如有侵权,请联系作者删除!