Download INTEGRATION_GUIDE.txt from manancode/opus-mt-ja-he-ctranslate2-android: direct link, hf CLI and curl.
- Browser
- Download file 982 Bytes
-
https://huggingface.co/manancode/opus-mt-ja-he-ctranslate2-android/resolve/de848e89ab6ddcdd89c4d2d7b058749fcd01c564/INTEGRATION_GUIDE.txt
- Command line
-
hf download hf://manancode/opus-mt-ja-he-ctranslate2-android@de848e89ab6ddcdd89c4d2d7b058749fcd01c564/INTEGRATION_GUIDE.txt
-
curl -L -o INTEGRATION_GUIDE.txt https://huggingface.co/manancode/opus-mt-ja-he-ctranslate2-android/resolve/de848e89ab6ddcdd89c4d2d7b058749fcd01c564/INTEGRATION_GUIDE.txt
982 Bytes
| // Android Integration for CTranslate2 Helsinki-NLP/opus-mt-ja-he | |
| // Requires: CTranslate2 Java bindings + SentencePiece JNI | |
| public class CTranslate2Translator { | |
| private Translator translator; | |
| private SentencePieceProcessor sourceProcessor; | |
| private SentencePieceProcessor targetProcessor; | |
| public CTranslate2Translator(String modelPath, String sourceSpm, String targetSpm) { | |
| translator = new Translator(modelPath); | |
| sourceProcessor = new SentencePieceProcessor(); | |
| targetProcessor = new SentencePieceProcessor(); | |
| sourceProcessor.load(sourceSpm); | |
| targetProcessor.load(targetSpm); | |
| } | |
| public String translate(String text) { | |
| String[] srcTokens = sourceProcessor.encode(text); | |
| TranslationResult result = translator.translateBatch(Arrays.asList(srcTokens)).get(0); | |
| return targetProcessor.decode(result.getHypotheses().get(0)); | |
| } | |
| } | |
| // Model: Helsinki-NLP/opus-mt-ja-he | |
| // Language pair: JA -> HE | |