Speech-Rule-Engine / speech-rule-engine

Generating speech descriptions for XML structures
https://zorkow.github.io/speech-rule-engine/
Apache License 2.0
75 stars 39 forks source link

1/2 fraction throws error in "nn" locale (Ordinal Error?) #617

Closed adamc-texthelp closed 2 years ago

adamc-texthelp commented 2 years ago

This is in the l10n_no branch for Norwegian. Let me know if you prefer these issues logged elsewhere.

If the locale is set to nn the following math throws an error in the hundredsToWords_(num, ordinal) function. https://github.com/zorkow/speech-rule-engine/blob/21d9e198a94507abce5c653a520586d5603b5970/ts/l10n/numbers/numbers_nn.ts#L40

Uncaught TypeError: Cannot read properties of undefined (reading '2')

Numbers.special is an empty object for that locale.

Latex: \frac{1}{2}

MathML:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mfrac>
    <mn>1</mn>
    <mn>2</mn>
  </mfrac>
</math>
zorkow commented 2 years ago

@adamc-texthelp I am finally circling back to this. I've just merged l10n_no into develop and I can't reproduce the problem. I am getting ein andre for nn and en andre for nb.

Is it possible that you have been running with an old version of the json files? Can you check again on the develop branch?

adamc-texthelp commented 2 years ago

Looks like we were indeed using an old version of the json files from whenever we cloned that l10n_no branch, develop seems to work fine.

When I was checking the file differences I did notice the locale_nb.ts is now pulling in the numbers_nn file. Just wanted to check is that intentional?

https://github.com/zorkow/speech-rule-engine/blob/6130590fedbef327904060cc7857b173e063a529/ts/l10n/locales/locale_nb.ts#L27

zorkow commented 2 years ago

When I was checking the file differences I did notice the locale_nb.ts is now pulling in the numbers_nn file. Just wanted to check is that intentional?

It is, but temporary and I thought nobody would notice... These filenames are actually misnomers. Both nn and nb have two types of number systems: the traditional Germanic one and one similar to the English system (which is actually from Romance languages). Think one-and-twenty vs twenty-one. _nb implements the former for both locales, and _nn the latter, which according to Bente is more commonly used today. But we can generate both variants. This is similar to say French, where we can construct numbers for Belgium and Swiss French as well.

Once I've merged PR #602, which contains some code to expose "sub-locales", I will probably merge the files into a numbers_no file.

adamc-texthelp commented 2 years ago

Fair enough, I think we can close off this topic then. Also do you have any time estimate when a non beta release will be ready?

zorkow commented 2 years ago

I am aiming to get 4.0 out before I will break for Christmas.

I am trying to get one more beta out today, to test the promise based locale loading (got bogged down by a couple of issues that I had promised @pkra to fix...). If you find the time to test that, that would be great.