Skip to content

Commit

Permalink
Add netty dependency in pom.xml and number of retry for converter in …
Browse files Browse the repository at this point in the history
…backend
  • Loading branch information
kohei-s committed Nov 7, 2023
1 parent 133415f commit 7431ec6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<artifactId>icu4j</artifactId>
<version>73.2</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns</artifactId>
<version>4.1.100.Final</version>
</dependency>
</dependencies>
<build>
<finalName>kotokoapp</finalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public String convertKanjiToKana(GooRequest gooRequest) {
.bodyValue(gooRequest)
.retrieve()
.toEntity(GooResponse.class)
.retry(3)
.block();

assert responseEntity != null;
Expand All @@ -51,15 +52,19 @@ public String convertKanaToAlphabet(String kana) {

public Conversion convertTranslationToConversion(Translation translation) {
String translated = translation.getJapanese();
if (translated.matches("^[\\u4E00-\\u9FFF]+$")) {
String kana = convertKanjiToKana(getGooRequest(translated, "hiragana"));
String alphabet = convertKanaToAlphabet(kana);
return new Conversion(translated, kana, alphabet);
} else if ((translated.matches("^[\\u3040-\\u309F]+$")) || (translation.getJapanese().matches("^[\\u30A0-\\u30FF]+$"))) {
String alphabet = convertKanaToAlphabet(translated);
return new Conversion("", translated, alphabet);
if (translated != null) {
if (translated.matches("^[\\u4E00-\\u9FFF]+$")) {
String kana = convertKanjiToKana(getGooRequest(translated, "hiragana"));
String alphabet = convertKanaToAlphabet(kana);
return new Conversion(translated, kana, alphabet);
} else if ((translated.matches("^[\\u3040-\\u309F]+$")) || (translation.getJapanese().matches("^[\\u30A0-\\u30FF]+$"))) {
String alphabet = convertKanaToAlphabet(translated);
return new Conversion("", translated, alphabet);
} else {
return new Conversion("", "", "");
}
} else {
return new Conversion("", "", "");
return new Conversion("could not be translated", "", "");
}
}

Expand Down

0 comments on commit 7431ec6

Please sign in to comment.