embulk-filter-google_translate_api 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/build.gradle +1 -1
- data/classpath/embulk-filter-google_translate_api-0.2.0.jar +0 -0
- data/src/main/java/org/embulk/filter/google_translate_api/GoogleTranslateApiFilterPlugin.java +4 -0
- data/src/main/java/org/embulk/filter/google_translate_api/GoogleTranslateApiPageOutput.java +11 -1
- metadata +3 -3
- data/classpath/embulk-filter-google_translate_api-0.1.1.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1262edf05cdf86f48da5cf116d64f08b3aaebea5
|
4
|
+
data.tar.gz: 193cefceda03cb422b022b00a7f3de7d70547a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1cbeb0c236d8008dc725ac0fd12f8df8c4cd3e4541a41270dac43d8bc703b566ce412c234b5071e393c4683f02457f5a27dd16a6cecd9f34afb321dafe577fd
|
7
|
+
data.tar.gz: ca85d7abc4a200f715a23c346eaec0d7f642398b14458bde17b3c5930cf553aa31ed38daabdf8818abb83a4c87910b42071cfc763afca5887d308076a7c99489
|
data/README.md
CHANGED
@@ -14,6 +14,7 @@ see support language. [Google Language Codes \- tomihasa](https://sites.google.c
|
|
14
14
|
- **out_key_name_suffix**: translated target key names suffix (string, required)
|
15
15
|
- **source_lang**: source language (string, default: `null`)
|
16
16
|
- **target_lang**: target language (string, required)
|
17
|
+
- **model**: if premium edition can use. nmt(neural machine translation) or base. (string, default: `null`)
|
17
18
|
- **sleep**: delay per record, define milliseconds. (integer, default: 0)
|
18
19
|
- **google_api_key**: google_api_key. support environment variable. please `export GOOGLE_API_KEY`(string, default: `null`)
|
19
20
|
|
data/build.gradle
CHANGED
Binary file
|
data/src/main/java/org/embulk/filter/google_translate_api/GoogleTranslateApiFilterPlugin.java
CHANGED
@@ -33,6 +33,10 @@ public class GoogleTranslateApiFilterPlugin implements FilterPlugin
|
|
33
33
|
@Config("target_lang")
|
34
34
|
public String getTargetLang();
|
35
35
|
|
36
|
+
@Config("model")
|
37
|
+
@ConfigDefault("null")
|
38
|
+
public Optional<String> getModel();
|
39
|
+
|
36
40
|
@Config("google_api_key")
|
37
41
|
@ConfigDefault("null")
|
38
42
|
public Optional<String> getGoogleApiKey();
|
@@ -2,6 +2,7 @@ package org.embulk.filter.google_translate_api;
|
|
2
2
|
|
3
3
|
import java.util.List;
|
4
4
|
|
5
|
+
import org.apache.commons.lang3.ArrayUtils;
|
5
6
|
import org.embulk.config.TaskSource;
|
6
7
|
import org.embulk.filter.google_translate_api.GoogleTranslateApiFilterPlugin.PluginTask;
|
7
8
|
import org.embulk.spi.Column;
|
@@ -32,6 +33,7 @@ public class GoogleTranslateApiPageOutput implements PageOutput
|
|
32
33
|
private final PageBuilder builder;
|
33
34
|
private final Translate translate;
|
34
35
|
private final TranslateOption srcLang;
|
36
|
+
private final TranslateOption model;
|
35
37
|
|
36
38
|
private static final Logger logger = Exec.getLogger(GoogleTranslateApiFilterPlugin.class);
|
37
39
|
|
@@ -48,6 +50,7 @@ public class GoogleTranslateApiPageOutput implements PageOutput
|
|
48
50
|
this.translate = createTranslateService();
|
49
51
|
|
50
52
|
this.srcLang = task.getSourceLang().isPresent() ? TranslateOption.sourceLanguage(task.getSourceLang().get()) : null;
|
53
|
+
this.model = task.getModel().isPresent() ? TranslateOption.model(task.getModel().get()) : null;
|
51
54
|
}
|
52
55
|
|
53
56
|
@Override
|
@@ -90,7 +93,14 @@ public class GoogleTranslateApiPageOutput implements PageOutput
|
|
90
93
|
* @return
|
91
94
|
*/
|
92
95
|
private List<Translation> translate(List<String> texts) {
|
93
|
-
|
96
|
+
TranslateOption[] translateOptions = new TranslateOption[] {};
|
97
|
+
if (srcLang != null) {
|
98
|
+
translateOptions = ArrayUtils.add(translateOptions, srcLang);
|
99
|
+
}
|
100
|
+
if (model != null) {
|
101
|
+
translateOptions = ArrayUtils.add(translateOptions, model);
|
102
|
+
}
|
103
|
+
return (translateOptions.length == 0) ? translate.translate(texts) : translate.translate(texts, translateOptions);
|
94
104
|
}
|
95
105
|
|
96
106
|
/**
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-filter-google_translate_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toyama0919
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,7 +63,7 @@ files:
|
|
63
63
|
- classpath/auto-value-1.2.jar
|
64
64
|
- classpath/commons-codec-1.3.jar
|
65
65
|
- classpath/commons-logging-1.1.1.jar
|
66
|
-
- classpath/embulk-filter-google_translate_api-0.
|
66
|
+
- classpath/embulk-filter-google_translate_api-0.2.0.jar
|
67
67
|
- classpath/gax-0.0.25.jar
|
68
68
|
- classpath/google-api-client-1.21.0.jar
|
69
69
|
- classpath/google-api-client-appengine-1.21.0.jar
|
Binary file
|