LoginSignup
0
0

More than 1 year has passed since last update.

DeepLの翻訳がおかしかったので原因を調査してみた

Posted at

できごと

数字の雑学を取得できるAPIを利用し、そのレスポンス値(英文)をDeepl APIを利用して日本語に翻訳をする、という機能を開発していたところ、おかしな日本語に翻訳されてしまった。

参考:数字の雑学が取得できるAPI
https://rapidapi.com/divad12/api/numbers-1/

参考:DeepL API
https://www.deepl.com/ja/pro-api?cta=header-pro-api/

どんな日本語になったのか?

  • the number of players on a soccer team on the field at a time as well as in a cricket team
    ⇒「頭数」("11"に関する数字の雑学)

  • the sapphire wedding anniversary in years of marriage
    ⇒「こんきゅうさいねんさい」("45"に関する数字の雑学)

訳がわからないことになっている

ちなみに以下のDeepL翻訳ツールでも同様の結果になるため、API自体が問題ではないことがわかる。
https://www.deepl.com/translator

ちなみにGoogle翻訳ではおおよそ期待通りの翻訳結果を取得できた。
the number of players on a soccer team on the field at a time as well as in a cricket team
⇒「一度にフィールドにいるサッカーチームとクリケットチームの選手の数」 (Google翻訳)

原因と解消方法

文末にピリオドを打つことによって期待した結果を得られることが分かった。
正しく文章を認識することができていなかったことが原因のようだった。

<ピリオドをつけた場合の翻訳例>

  • the number of players on a soccer team on the field at a time as well as in a cricket team.
    ⇒「サッカーチームやクリケットチームのように、フィールドに一度にいる選手の数。」

  • the sapphire wedding anniversary in years of marriage.
    ⇒「サファイアの結婚記念日を結婚年数で表したもの。」
    (結婚45周年のことをサファイア婚式と言うのですね)

プログラムとしては、取得した英文の最後に「.」をつけてDeepL APIを呼び出すことで期待した値を取得することができるようになった。

おわりに

DeepLは翻訳の精度が非常に高いことで有名だが、
英語翻訳を行う際には、文末にピリオドがついていることを確認をしておいた方が良さそうだ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0