Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math::DomainError #5

Open
tskogberg opened this issue Nov 20, 2018 · 3 comments
Open

Math::DomainError #5

tskogberg opened this issue Nov 20, 2018 · 3 comments

Comments

@tskogberg
Copy link

In production we've seen this happen:

The string: "2 st 25 öre 1949,1950.\r\n3 st 1 kr 1943.\r\n4 st 1 kr 1944" will generate an Math::DomainError. It comes from the punkt-segmenter gem and it's a known issue.

A possible fix/workaround for this is to use the fork harrisj/punkt-segmenter and use a trained tokenizer. A code doodle on how that could look can be found here: here.

@tskogberg
Copy link
Author

Code line to reproduce: GoogleTranslateDiff.translate("2 st 25 öre 1949,1950.\r\n3 st 1 kr 1943.\r\n4 st 1 kr 1944", from: "sv", to: "en")

@tskogberg
Copy link
Author

Quick and dirty fix for whomever end up here trying to find solution:

def translate(text:, from:, to:)
  GoogleTranslateDiff.translate(text, from: from, to: to)
rescue Math::DomainError
  GoogleTranslateDiff.api.translate(text, from: from, to: to).text
end

@nepalez
Copy link
Contributor

nepalez commented Jan 18, 2019

@tskogberg Thank you! this is exactly what I looked for today)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants