Repository: allo-media/text2num

Issue:
Issue when there is 'zéro' before other letters
Ex OK:
```
data_zero = 'zéro'
print(alpha2digit(data_zero, 'fr'))
0
```
Ex: NOK:
```
data1 = 'a a un trois sept trois trois sept cinq quatre zéro c c'
data2 = 'b b un trois sept trois trois sept cinq quatre zéro d d'
print(alpha2digit(data1, 'fr'))
print(alpha2digit(data2, 'fr'))
a a 1 3 7 3 3 7 5 4 zéro c c 
b b 1 3 7 3 3 7 5 4 zéro d d
```

We can see `zéro` is not transform to digit 0.

thanks in advance for your help
have a good day

Discussion:

Patch:
diff --git a/text_to_num/lang/base.py b/text_to_num/lang/base.py
index b2a8cc9..e349c1c 100644
--- a/text_to_num/lang/base.py
+++ b/text_to_num/lang/base.py
@@ -70,7 +70,7 @@ class Language:
         return NotImplemented
 
     def not_numeric_word(self, word: Optional[str]) -> bool:
-        return word is None or word != self.DECIMAL_SEP and word not in self.NUMBERS
+        return word is None or word != self.DECIMAL_SEP and word not in self.NUMBERS and word not in self.ZERO
 
     def split_number_word(self, word: str) -> str:  # maybe use: List[str]
         """In some languages numbers are written as one word, e.g. German
diff --git a/text_to_num/lang/english.py b/text_to_num/lang/english.py
index e155a2e..4286476 100644
--- a/text_to_num/lang/english.py
+++ b/text_to_num/lang/english.py
@@ -117,7 +117,7 @@ class English(Language):
 
     AND_NUMS: Set[str] = set()
     AND = "and"
-    NEVER_IF_ALONE = {"one"}
+    NEVER_IF_ALONE = {"one", "o"}
 
     # Relaxed composed numbers (two-words only)
     # start => (next, target)
diff --git a/text_to_num/parsers.py b/text_to_num/parsers.py
index d66d9ed..57df1e9 100644
--- a/text_to_num/parsers.py
+++ b/text_to_num/parsers.py
@@ -346,8 +346,6 @@ class WordStreamValueParserGerman(WordStreamValueParserInterface):
                 elif (ng[hundred_index - 1] in self.lang.UNITS) or (
                     ng[hundred_index - 1] in self.lang.STENS
                 ):
-                    if hundred_index - 2 >= 0 and ng[hundred_index - 2] not in self.lang.MULTIPLIERS:
-                        raise ValueError("invalid {} without multiplier: {}".format(STATIC_HUNDRED, repr(ng)))
                     multiplier = German.NUMBER_DICT_GER[ng[hundred_index - 1]]
                     equation += "(" + str(multiplier) + " * 100)"
                     equation_results.append(multiplier * 100)
@@ -558,7 +556,6 @@ class WordToDigitParser:
         relaxed: bool = False,
         signed: bool = True,
         ordinal_threshold: int = 3,
-        preceding_word: Optional[str] = None
     ) -> None:
         """Initialize the parser.
 
@@ -578,7 +575,7 @@ class WordToDigitParser:
         self.in_frac = False
         self.closed = False  # For deferred stop
         self.open = False  # For efficiency
-        self.last_word: Optional[str] = preceding_word  # For context
+        self.last_word: Optional[str] = None  # For context
         self.ordinal_threshold = ordinal_threshold
 
     @property
@@ -655,21 +652,21 @@ class WordToDigitParser:
         elif (
             word in self.lang.ZERO
             and self.at_start_of_seq()
-            and (
-                look_ahead is None
-                or look_ahead in self.lang.NUMBERS
-                or look_ahead in self.lang.ZERO
-                or look_ahead in self.lang.DECIMAL_SEP
-            )
+            and look_ahead is not None
+            and look_ahead in self.lang.DECIMAL_SEP
         ):
-            self._value.append("0")
+            pass
         elif (
             word in self.lang.ZERO
             and self.at_start_of_seq()
-            and look_ahead is not None
-            and look_ahead in self.lang.DECIMAL_SEP
+            # and (
+            #     look_ahead is None
+            #     or look_ahead in self.lang.NUMBERS
+            #     or look_ahead in self.lang.ZERO
+            #     or look_ahead in self.lang.DECIMAL_SEP
+            # )
         ):
-            pass
+            self._value.append("0")
         elif self._push(self.lang.ord2card(word) or "", look_ahead):
             self._value.append(
                 self.lang.num_ord(
diff --git a/text_to_num/transforms.py b/text_to_num/transforms.py
index 287e90b..93817a1 100644
--- a/text_to_num/transforms.py
+++ b/text_to_num/transforms.py
@@ -137,7 +137,6 @@ def alpha2digit(
                 signed=signed,
                 ordinal_threshold=ordinal_threshold,
             )
-            last_word = None
             in_number = False
             out_tokens: List[str] = []
             for word, ahead in look_ahead(tokens):
@@ -150,12 +149,10 @@ def alpha2digit(
                         relaxed=relaxed,
                         signed=signed,
                         ordinal_threshold=ordinal_threshold,
-                        preceding_word=last_word
                     )
                     in_number = num_builder.push(word.lower(), ahead and ahead.lower())
                 if not in_number:
                     out_tokens.append(word)
-                last_word = word.lower()
             # End of segment
             num_builder.close()
             if num_builder.value:


Test patch:
diff --git a/tests/test_text_to_num_de.py b/tests/test_text_to_num_de.py
index 596d73d..ba7b7d8 100644
--- a/tests/test_text_to_num_de.py
+++ b/tests/test_text_to_num_de.py
@@ -84,11 +84,6 @@ class TestTextToNumDE(TestCase):
         self.assertRaises(ValueError, text2num, "fünfzignullzwei", "de")
         self.assertRaises(ValueError, text2num, "fünfzigdreinull", "de")
 
-    def test_text2num_hundred_addition(self):
-        self.assertRaises(ValueError, text2num, "achtundachtzig dreihundert", "de")
-        self.assertRaises(ValueError, text2num, "zwanzig dreihundert", "de")
-        self.assertRaises(ValueError, text2num, "zwei zwölfhundert", "de")
-
     def test_alpha2digit_integers(self):
         source = "fünfundzwanzig Kühe, zwölf Hühner und einhundertfünfundzwanzig kg Kartoffeln."
         expected = "25 Kühe, 12 Hühner und 125 kg Kartoffeln."
@@ -311,12 +306,3 @@ class TestTextToNumDE(TestCase):
         source = "Dies ist eine Liste oder die Einkaufsliste."
         expected = source
         self.assertEqual(alpha2digit(source, "de"), expected)
-
-    def test_hundred_addition(self):
-        source = "Zahlen wie vierzig fünfhundert Tausend zweiundzwanzig hundert sind gut."
-        expected = "Zahlen wie 40 500022 100 sind gut."
-        self.assertEqual(alpha2digit(source, "de"), expected)
-
-        source = "achtundachtzig sieben hundert, acht und achtzig siebenhundert, achtundachtzig sieben hundert, acht und achtzig sieben hundert"
-        expected = "88 700, 88 700, 88 700, 88 700"
-        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 b6a71ad..881e040 100644
--- a/tests/test_text_to_num_en.py
+++ b/tests/test_text_to_num_en.py
@@ -126,6 +126,7 @@ class TestTextToNumEN(TestCase):
         self.assertEqual(alpha2digit(source, "en"), expected)
 
         self.assertEqual(alpha2digit("zero", "en"), "0")
+        self.assertEqual(alpha2digit("zero love", "en"), "0 love")
 
     def test_alpha2digit_ordinals(self):
         source = (
@@ -175,10 +176,6 @@ class TestTextToNumEN(TestCase):
         self.assertEqual(alpha2digit(source, "en"), source)
         source = "one cannot know"
         self.assertEqual(alpha2digit(source, "en"), source)
-        # Following an ordinal
-        source = "the sixth one"
-        expected = "the 6th one"
-        self.assertEqual(alpha2digit(source, "en"), expected)
         # End of segment
         source = "No one. Another one. One one. Twenty one"
         expected = "No one. Another one. 1 1. 21"
diff --git a/tests/test_text_to_num_fr.py b/tests/test_text_to_num_fr.py
index accd0ef..c9ba038 100644
--- a/tests/test_text_to_num_fr.py
+++ b/tests/test_text_to_num_fr.py
@@ -143,6 +143,8 @@ class TestTextToNumFR(TestCase):
         # self.assertEqual(alpha2digit(source, "fr"), source)
 
         self.assertEqual(alpha2digit("zéro", "fr"), "0")
+        self.assertEqual(alpha2digit("a a un trois sept trois trois sept cinq quatre zéro c c", "fr"), "a a 1 3 7 3 3 7 5 4 0 c c")
+        self.assertEqual(alpha2digit("sept un zéro", "fr"), "7 1 0")
 
     def test_alpha2digit_ordinals(self):
         source = (