[ 
https://issues.apache.org/jira/browse/TIKA-3329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17319873#comment-17319873
 ] 

ASF GitHub Bot commented on TIKA-3329:
--------------------------------------

kieraCurtis commented on a change in pull request #419:
URL: https://github.com/apache/tika/pull/419#discussion_r612114393



##########
File path: 
tika-translate/src/main/java/org/apache/tika/language/translate/RTGTranslator.java
##########
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.tika.language.translate;
+
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.tika.exception.TikaException;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+
+/**
+ * <p>This translator is designed to work with a TCP-IP available
+ * RTG translation server, specifically the
+ * <a href="https://isi-nlp.github.io/rtg/#_rtg_serve";>
+ * REST-based RTG server</a>.</p>
+ * To get Docker image:
+ *   https://hub.docker.com/repository/docker/tgowda/rtg-model <br/>
+ * <pre>
+ * {code
+ * # without GPU
+ *   docker run --rm -i -p 6060:6060 tgowda/rtg-model:500toEng-v1
+ * # Or, with GPU device 0
+ *   docker run --rm -i -p 6060:6060 --gpus '"device=0"' 
tgowda/rtg-model:500toEng-v1
+ * }
+ * </pre>
+ *
+ * <p>If you were to interact with the server via curl a request
+ * would look as follows</p>
+ *
+ * <pre>
+ * {code
+ * curl --data "source=Comment allez-vous?" \
+ *      --data "source=Bonne journée" \
+ *      http://localhost:6060/translate
+ * }
+ * </pre>
+ *
+ * RTG requires input to be pre-formatted into sentences, one per line,
+ * so this translation implementation takes care of that.
+ */
+public class RTGTranslator extends AbstractTranslator {
+
+    public static final String RTG_TRANSLATE_URL_BASE = 
"http://localhost:6060";;
+    public static final String RTG_PROPS = "translator.rtg.properties";
+    private static final Logger LOG = 
LoggerFactory.getLogger(RTGTranslator.class);
+    private WebClient client;
+    private boolean isAvailable = false;
+
+    public RTGTranslator() {
+        String rtgBaseUrl = RTG_TRANSLATE_URL_BASE;
+        Properties config = new Properties();
+        try (InputStream stream = getClass().getResourceAsStream(RTG_PROPS)){

Review comment:
       thank you for your quick reply. Happy




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> RTG Translator with many-to-eng translation
> -------------------------------------------
>
>                 Key: TIKA-3329
>                 URL: https://issues.apache.org/jira/browse/TIKA-3329
>             Project: Tika
>          Issue Type: Improvement
>          Components: translation
>            Reporter: Thamme Gowda
>            Assignee: Thamme Gowda
>            Priority: Major
>
> The existing translation services in tika-translate are either 
> commercial/paid engines (e.g. Google, Microsoft  etc ) or not state of the 
> art (such as Joshua, Moses etc). 
> Reader Translator Generator () is a neural machine translation toolkit 
> [https://isi-nlp.github.io/rtg/]
>  and has the implementation of Transformer NMT model (current state of the 
> art). 
> It also has massively multilingual pretrained NMT model  ( many-to-English 
> translation direction)  
> [https://hub.docker.com/repository/docker/tgowda/rtg-model] 
> in which about 500 source languages are represented, with atleast ~300 source 
> languages have good enough quality (For a comparison Google translate has 
> ~106 languages, and Microsoft has about 80 languages). 
> This issue is for integrating RTG Translator into tika-translate
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to