embulk-filter-google_translate_api 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a7226d317141e558edc1c87560d2bb04beef7de
4
- data.tar.gz: c30c74eb6838a2dff7142d552dfe80d38029ed0c
3
+ metadata.gz: 1262edf05cdf86f48da5cf116d64f08b3aaebea5
4
+ data.tar.gz: 193cefceda03cb422b022b00a7f3de7d70547a7f
5
5
  SHA512:
6
- metadata.gz: f050d824b14b0e8892e23f2de4f4bfd9e11765589508abd177b78aa1dad64d95c7ea6b2bc28969aefd5169154466788d83a49b2467c7a634c41b52b4c2cc26d6
7
- data.tar.gz: 468b418d545d133147f6f7f22822eae9596e92ed4095d4350ea31a2532a8f75f13c7ecc5d02e8ce86e4891f06137cfe0cbb4e7711b9f92d8ea8dda4e31f2637f
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
@@ -14,7 +14,7 @@ configurations {
14
14
  provided
15
15
  }
16
16
 
17
- version = "0.1.1"
17
+ version = "0.2.0"
18
18
 
19
19
  sourceCompatibility = 1.7
20
20
  targetCompatibility = 1.7
@@ -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
- return (srcLang == null) ? translate.translate(texts) : translate.translate(texts, srcLang);
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.1.1
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-16 00:00:00.000000000 Z
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.1.1.jar
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