Repository: bootphon/phonemizer (language: python)

Issue:
--preserve-punctuation doesn't preserve parentheses
**Describe the bug**
Comma and some punctuations are well-preserved, but not parentheses, brackets, and braces.

**Phonemizer version**
The output of `phonemize --version` from command line, very helpfull!
```
phonemizer-3.0.1
available backends: espeak-ng-1.50, espeak-mbrola, segments-2.2.0
uninstalled backends: festival

```
**System**
Ubuntu 21.10
Python 3.9.7

**To reproduce**
```
echo "I would like a (big) steack, in a [large] hamburger {yes}!" | phonemize -l en-gb --preserve-punctuation

aɪ wʊd laɪk ɐ bɪɡ stiːk, ɪn ɐ lɑːdʒ hambɜːɡə jɛs!
```
**Expected behavior**
parentheses, brackets, braces, and other kinds of punctuations should be provided in the output.


--preserve-punctuation doesn't preserve parentheses
**Describe the bug**
Comma and some punctuations are well-preserved, but not parentheses, brackets, and braces.

**Phonemizer version**
The output of `phonemize --version` from command line, very helpfull!
```
phonemizer-3.0.1
available backends: espeak-ng-1.50, espeak-mbrola, segments-2.2.0
uninstalled backends: festival

```
**System**
Ubuntu 21.10
Python 3.9.7

**To reproduce**
```
echo "I would like a (big) steack, in a [large] hamburger {yes}!" | phonemize -l en-gb --preserve-punctuation

aɪ wʊd laɪk ɐ bɪɡ stiːk, ɪn ɐ lɑːdʒ hambɜːɡə jɛs!
```
**Expected behavior**
parentheses, brackets, braces, and other kinds of punctuations should be provided in the output.




Discussion / hints:
@mmmaat & @jncasey do you think that we should add these punctuation (`(){}`) marks to the `_DEFAULT_MARKS` constant?
Before the feature to define punctuation with regex, I was typically using `;:,.!?¡¿—…"“”-()‘’*[]`, so It'd make sense to me to add `(){}[]` to the defaults.
Sure I agree, why not!
@mmmaat & @jncasey do you think that we should add these punctuation (`(){}`) marks to the `_DEFAULT_MARKS` constant?
Before the feature to define punctuation with regex, I was typically using `;:,.!?¡¿—…"“”-()‘’*[]`, so It'd make sense to me to add `(){}[]` to the defaults.
Sure I agree, why not!

Fix patch:
diff --git a/phonemizer/punctuation.py b/phonemizer/punctuation.py
index 6894ace..4d157ec 100644
--- a/phonemizer/punctuation.py
+++ b/phonemizer/punctuation.py
@@ -22,7 +22,7 @@
 from phonemizer.separator import Separator
 
 # The punctuation marks considered by default.
-_DEFAULT_MARKS = ';:,.!?¡¿—…"«»“”'
+_DEFAULT_MARKS = ';:,.!?¡¿—…"«»“”(){}[]'
 
 _MarkIndex = collections.namedtuple(
     '_mark_index', ['index', 'mark', 'position'])
@@ -67,14 +67,14 @@ def marks(self, value: Union[str, Pattern]):
             # catch the pattern surrounded by zero or more spaces on either side
             self._marks_re = re.compile(r'((' + value.pattern + r')|\s)+')
             self._marks = None
-        else:
-            if not isinstance(value, str):
-                raise ValueError('punctuation marks must be defined as a string or re.Pattern')
+        elif isinstance(value, str):
             self._marks = ''.join(set(value))
 
             # catching all the marks in one regular expression: zero or more spaces
             # + one or more marks + zero or more spaces.
             self._marks_re = re.compile(fr'(\s*[{re.escape(self._marks)}]+\s*)+')
+        else:
+            raise ValueError('punctuation marks must be defined as a string or re.Pattern')
 
     def remove(self, text: Union[str, List[str]]) -> Union[str, List[str]]:
         """Returns the `text` with all punctuation marks replaced by spaces


Test patch:
diff --git a/test/test_punctuation.py b/test/test_punctuation.py
index 2b9bf82..8e5ff25 100644
--- a/test/test_punctuation.py
+++ b/test/test_punctuation.py
@@ -56,7 +56,11 @@ def test_remove(inp, out):
         ['Truly replied, "Yes".'],
         ['hi; ho,"'],
         ["!?"],
-        ["!'"]])
+        ["!'"],
+        ["It is ! (I think so)"],
+        ["This {is} right"],
+        ["[He] is right"],
+    ])
 def test_preserve(inp):
     punct = Punctuation()
     text, marks = punct.preserve(inp)