Skip to content

Commit 98a97a5

Browse files
authored
Merge pull request #10 from OpenVoiceOS/release-0.0.2a1
Release 0.0.2a1
2 parents 721e381 + 448ead8 commit 98a97a5

File tree

8 files changed

+47
-18
lines changed

8 files changed

+47
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
# Changelog
22

3-
## [0.0.1a2](https://github.com/OpenVoiceOS/ovos-number-parser/tree/0.0.1a2) (2024-11-07)
3+
## [0.0.2a1](https://github.com/OpenVoiceOS/ovos-number-parser/tree/0.0.2a1) (2024-11-13)
44

5-
[Full Changelog](https://github.com/OpenVoiceOS/ovos-number-parser/compare/bc086aef8c1f18b03f6481e222a6c460f5b94962...0.0.1a2)
6-
7-
**Closed issues:**
8-
9-
- Enhance text normalization in [\#3](https://github.com/OpenVoiceOS/ovos-number-parser/issues/3)
10-
- Add support for missing languages [\#2](https://github.com/OpenVoiceOS/ovos-number-parser/issues/2)
5+
[Full Changelog](https://github.com/OpenVoiceOS/ovos-number-parser/compare/0.0.1...0.0.2a1)
116

127
**Merged pull requests:**
138

14-
- semver [\#6](https://github.com/OpenVoiceOS/ovos-number-parser/pull/6) ([JarbasAl](https://github.com/JarbasAl))
15-
- feat: numbers\_to\_digits [\#1](https://github.com/OpenVoiceOS/ovos-number-parser/pull/1) ([JarbasAl](https://github.com/JarbasAl))
9+
- fix: number\_to\_digits catalan placeholder [\#9](https://github.com/OpenVoiceOS/ovos-number-parser/pull/9) ([JarbasAl](https://github.com/JarbasAl))
1610

1711

1812

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,28 @@ fractional and ordinal numbers, and more.
1414

1515
## Supported Languages
1616

17+
✅ - supported
18+
❌ - not supported
19+
🚧 - imperfect placeholder, needs rewriting
20+
21+
1722
| Language Code | Pronounce Number | Pronounce Ordinal | Extract Number | numbers_to_digits |
1823
|-------------------------|------------------|-------------------|----------------|-------------------|
1924
| `en` (English) |||||
2025
| `az` (Azerbaijani) |||||
21-
| `ca` (Catalan) |||| |
26+
| `ca` (Catalan) |||| 🚧 |
2227
| `cs` (Czech) |||||
2328
| `da` (Danish) |||||
2429
| `de` (German) |||||
25-
| `es` (Spanish) |||| |
30+
| `es` (Spanish) |||| 🚧 |
2631
| `eu` (Euskara / Basque) |||||
2732
| `fa` (Farsi / Persian) |||||
2833
| `fr` (French) |||||
2934
| `hu` (Hungarian) |||||
3035
| `it` (Italian) |||||
3136
| `nl` (Dutch) |||||
3237
| `pl` (Polish) |||||
33-
| `pt` (Portuguese) |||| |
38+
| `pt` (Portuguese) |||| 🚧 |
3439
| `ru` (Russian) |||||
3540
| `sv` (Swedish) |||||
3641
| `sl` (Slovenian) |||||

ovos_number_parser/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Union
22

33
from ovos_number_parser.numbers_az import numbers_to_digits_az, extract_number_az, is_fractional_az, pronounce_number_az
4-
from ovos_number_parser.numbers_ca import pronounce_number_ca, is_fractional_ca, extract_number_ca
4+
from ovos_number_parser.numbers_ca import numbers_to_digits_ca, pronounce_number_ca, is_fractional_ca, extract_number_ca
55
from ovos_number_parser.numbers_cs import numbers_to_digits_cs, pronounce_number_cs, is_fractional_cs, extract_number_cs
66
from ovos_number_parser.numbers_da import is_fractional_da, is_ordinal_da, pronounce_number_da, \
77
pronounce_ordinal_da, extract_number_da
@@ -38,6 +38,8 @@ def numbers_to_digits(utterance: str, lang: str) -> str:
3838
"""
3939
if lang.startswith("az"):
4040
return numbers_to_digits_az(utterance)
41+
if lang.startswith("ca"):
42+
return numbers_to_digits_ca(utterance)
4143
if lang.startswith("cs"):
4244
return numbers_to_digits_cs(utterance)
4345
if lang.startswith("de"):

ovos_number_parser/numbers_ca.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ovos_number_parser.util import (convert_to_mixed_fraction, look_for_fractions,
2-
is_numeric)
2+
is_numeric, tokenize)
33

44
_NUMBERS_CA = {
55
"zero": 0,
@@ -466,3 +466,29 @@ def extract_number_ca(text, short_scale=True, ordinals=False):
466466
result = int(integer)
467467

468468
return result or False
469+
470+
471+
def numbers_to_digits_ca(utterance: str) -> str:
472+
"""
473+
Substitueix els números escrits en un text en català per les seves equivalents en xifres.
474+
475+
Args:
476+
utterance (str): Cadena d'entrada que possiblement conté números escrits.
477+
478+
Returns:
479+
str: Text amb els números escrits substituïts per xifres.
480+
"""
481+
# TODO - this is a quick and dirty placeholder and needs rewriting
482+
number_replacements = {
483+
"un": "1", "dos": "2", "tres": "3", "quatre": "4",
484+
"cinc": "5", "sis": "6", "set": "7", "vuit": "8", "nou": "9",
485+
"deu": "10", "onze": "11", "dotze": "12", "tretze": "13", "catorze": "14",
486+
"quinze": "15", "setze": "16", "disset": "17", "divuit": "18",
487+
"dinou": "19", "vint": "20"
488+
# Amplieu aquest diccionari per a números més alts si és necessari
489+
}
490+
words = tokenize(utterance)
491+
for idx, word in enumerate(words):
492+
if word in number_replacements:
493+
words[idx] = number_replacements[word]
494+
return " ".join(words)

ovos_number_parser/numbers_es.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ def pronounce_number_es(number, places=2):
668668
result += " " + _NUM_STRING_ES[int(char)]
669669
return result
670670

671+
671672
def numbers_to_digits_es(utterance: str) -> str:
672673
"""
673674
Replace written numbers in a Spanish text with their digit equivalents.
@@ -678,6 +679,7 @@ def numbers_to_digits_es(utterance: str) -> str:
678679
Returns:
679680
str: Text with written numbers replaced by digits.
680681
"""
682+
# TODO - this is a quick and dirty placeholder and needs rewriting
681683
number_replacements = {
682684
"uno": "1", "dos": "2", "tres": "3", "cuatro": "4",
683685
"cinco": "5", "seis": "6", "siete": "7", "ocho": "8", "nueve": "9",
@@ -690,4 +692,4 @@ def numbers_to_digits_es(utterance: str) -> str:
690692
for idx, word in enumerate(words):
691693
if word in number_replacements:
692694
words[idx] = number_replacements[word]
693-
return " ".join(words)
695+
return " ".join(words)

ovos_number_parser/numbers_pt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ def numbers_to_digits_pt(utterance: str) -> str:
389389
Returns:
390390
str: Text with written numbers replaced by digits.
391391
"""
392+
# TODO - this is a quick and dirty placeholder and needs rewriting
392393
number_replacements = {
393394
"catorze": "14",
394395
"cem": "100",

ovos_number_parser/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# START_VERSION_BLOCK
22
VERSION_MAJOR = 0
33
VERSION_MINOR = 0
4-
VERSION_BUILD = 1
5-
VERSION_ALPHA = 0
4+
VERSION_BUILD = 2
5+
VERSION_ALPHA = 1
66
# END_VERSION_BLOCK

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def get_version():
5757
version=get_version(),
5858
packages=['ovos_number_parser'],
5959
url='https://github.com/OpenVoiceOS/ovos-number-parser',
60-
obsoletes=['ovos_number_parser'],
6160
license='Apache2.0',
6261
package_data={'': extra_files},
6362
include_package_data=True,

0 commit comments

Comments
 (0)