Repository: allo-media/text2num

Issue:
Billions followed by millions (e.g. 1,025,000,000) not converted for English, French
When the next multiplier is a million, following billions, it is not handled correctly. It is not detected as an expected valid multiplier. There is a "TODO" comment in the related code, I suspect it is about this issue.

It doesn't happen with Spanish because in Spanish billion is basically "thousand millions". 

If the next multiplier following billions is a thousand, it works fine, because 1000x1000=1,000,000 < 1 billion.

For now, I add the following check to the end of `is_coef_appliable()` method, before returning False, it works fine for me now:

```
        if coef > self.grp_val and coef * self.grp_val < self.n000_val:
            return True

```
It seems reasonable to me, but I may not be able to consider all possible cases, and for different languages. Just a suggestion for the time being.

Discussion:

Patch:
diff --git a/text_to_num/lang/german.py b/text_to_num/lang/german.py
index 87966b1..4c79874 100644
--- a/text_to_num/lang/german.py
+++ b/text_to_num/lang/german.py
@@ -211,7 +211,7 @@ class German(Language):
             if not found:
                 # is (large) ordinal ending?
                 ord_match = None
-                if not invalid_word and len(result) > 3 and text.startswith("ste"):
+                if len(result) > 3 and text.startswith("ste"):
                     ord_match = re.search(self.LARGE_ORDINAL_SUFFIXES_GER, text)
 
                 if ord_match:
diff --git a/text_to_num/parsers.py b/text_to_num/parsers.py
index 5573375..d90ebb7 100644
--- a/text_to_num/parsers.py
+++ b/text_to_num/parsers.py
@@ -124,13 +124,14 @@ class WordStreamValueParser(WordStreamValueParserInterface):
             # a multiplier can be applied to anything lesser than itself,
             # as long as it not zero (special case for 1000 which then implies 1)
             return True
-        if coef * coef <= self.n000_val:
+        if coef * 1000 <= self.n000_val:
             # a multiplier can not be applied to a value bigger than itself,
             # so it must be applied to the current group only.
             # ex. for "mille": "deux millions cent cinquante mille"
             # ex. for "millions": "trois milliard deux cent millions"
             # But not twice: "dix mille cinq mille" is invalid for example. Therefore,
-            # we test the square of ``coef``.
+            # we test the 1000 × ``coef`` (as the multipliers above 100,
+            # are a geometric progression of ratio 1000)
             return (
                 self.grp_val > 0 or coef == 1000
             )  # "mille" without unit      is additive
diff --git a/text_to_num/transforms.py b/text_to_num/transforms.py
index de1743e..714fd9d 100644
--- a/text_to_num/transforms.py
+++ b/text_to_num/transforms.py
@@ -258,13 +258,6 @@ def _alpha2digit_agg(
                         # finish LAST group but keep token_index
                         token_to_add = str(combined_num_result)
                         token_to_add_is_num = True
-                elif tmp_token_ordinal_org is not None:
-                    # revert ordinal
-                    sentence[len(sentence) - 1] = str(tmp_token_ordinal_org)
-                    token_index += 1
-                    token_to_add = " ".join(sentence)
-                    token_to_add_is_num = False
-                    current_token_ordinal_org = None
                 else:
                     # previous text was not a valid number
                     # prep. for next group


Test patch:
diff --git a/tests/test_text_to_num_de.py b/tests/test_text_to_num_de.py
index ba7b7d8..d91aedf 100644
--- a/tests/test_text_to_num_de.py
+++ b/tests/test_text_to_num_de.py
@@ -297,12 +297,3 @@ class TestTextToNumDE(TestCase):
         source = "FÜNFZEHN EINS ZEHN EINS"
         expected = "15 1 10 1"
         self.assertEqual(alpha2digit(source, "de"), expected)
-
-    def test_ordinals_false_positives(self):
-        source = "In zehnten Jahrzehnten. Und einmal mit den Vereinten."
-        expected = "In 10. Jahrzehnten. Und einmal mit den Vereinten."
-        self.assertEqual(alpha2digit(source, "de"), expected)
-
-        source = "Dies ist eine Liste oder die Einkaufsliste."
-        expected = source
-        self.assertEqual(alpha2digit(source, "de"), expected)
diff --git a/tests/test_text_to_num_en.py b/tests/test_text_to_num_en.py
index 86344c6..6d21928 100644
--- a/tests/test_text_to_num_en.py
+++ b/tests/test_text_to_num_en.py
@@ -49,6 +49,7 @@ class TestTextToNumEN(TestCase):
         self.assertEqual(text2num("one hundred fifteen", "en"), 115)
         self.assertEqual(text2num("seventy-five thousands", "en"), 75000)
         self.assertEqual(text2num("thousand nine hundred twenty", "en"), 1920)
+        self.assertEqual(text2num("one billion twenty-five millions", "en"), 1_025_000_000)
 
     def test_text2num_centuries(self):
         self.assertEqual(text2num("nineteen hundred seventy-three", "en"), 1973)
diff --git a/tests/test_text_to_num_fr.py b/tests/test_text_to_num_fr.py
index e212881..956153f 100644
--- a/tests/test_text_to_num_fr.py
+++ b/tests/test_text_to_num_fr.py
@@ -46,6 +46,7 @@ class TestTextToNumFR(TestCase):
 
         self.assertEqual(text2num("quinze", "fr"), 15)
         self.assertEqual(text2num("soixante quinze mille", "fr"), 75000)
+        self.assertEqual(text2num("un milliard vingt-cinq millions", "fr"), 1_025_000_000)
 
     def test_text2num_variants(self):
         self.assertEqual(text2num("quatre-vingt dix-huit", "fr"), 98)