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.

Comments:

Patch:
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


Test patch:
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)