Skip to content

Commit 8bffad5

Browse files
authored
Merge pull request #7 from OpenVoiceOS/release-0.0.1a2
Release 0.0.1a2
2 parents f3127e3 + f05eba2 commit 8bffad5

19 files changed

+900
-47
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip" # See documentation for possible values
9+
directory: "/requirements" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# auto add labels to PRs
2+
on:
3+
pull_request_target:
4+
types: [ opened, edited ]
5+
name: conventional-release-labels
6+
jobs:
7+
label:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: bcoe/conventional-release-labels@v1

.github/workflows/publish_stable.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Stable Release
2+
on:
3+
push:
4+
branches: [master]
5+
workflow_dispatch:
6+
7+
jobs:
8+
publish_stable:
9+
uses: TigreGotico/gh-automations/.github/workflows/publish-stable.yml@master
10+
secrets: inherit
11+
with:
12+
branch: 'master'
13+
version_file: 'ovos_number_parser/version.py'
14+
setup_py: 'setup.py'
15+
publish_release: true
16+
17+
publish_pypi:
18+
needs: publish_stable
19+
if: success() # Ensure this job only runs if the previous job succeeds
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
ref: dev
25+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
26+
- name: Setup Python
27+
uses: actions/setup-python@v1
28+
with:
29+
python-version: 3.8
30+
- name: Install Build Tools
31+
run: |
32+
python -m pip install build wheel
33+
- name: version
34+
run: echo "::set-output name=version::$(python setup.py --version)"
35+
id: version
36+
- name: Build Distribution Packages
37+
run: |
38+
python setup.py sdist bdist_wheel
39+
- name: Publish to PyPI
40+
uses: pypa/gh-action-pypi-publish@master
41+
with:
42+
password: ${{secrets.PYPI_TOKEN}}
43+
44+
45+
sync_dev:
46+
needs: publish_stable
47+
if: success() # Ensure this job only runs if the previous job succeeds
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v2
51+
with:
52+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
53+
ref: master
54+
- name: Push master -> dev
55+
uses: ad-m/github-push-action@master
56+
with:
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
58+
branch: dev
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Release Alpha and Propose Stable
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [dev]
7+
8+
jobs:
9+
publish_alpha:
10+
if: github.event.pull_request.merged == true
11+
uses: TigreGotico/gh-automations/.github/workflows/publish-alpha.yml@master
12+
secrets: inherit
13+
with:
14+
branch: 'dev'
15+
version_file: 'ovos_number_parser/version.py'
16+
setup_py: 'setup.py'
17+
update_changelog: true
18+
publish_prerelease: true
19+
changelog_max_issues: 100
20+
21+
notify:
22+
if: github.event.pull_request.merged == true
23+
needs: publish_alpha
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Send message to Matrix bots channel
28+
id: matrix-chat-message
29+
uses: fadenb/matrix-chat-message@v0.0.6
30+
with:
31+
homeserver: 'matrix.org'
32+
token: ${{ secrets.MATRIX_TOKEN }}
33+
channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org'
34+
message: |
35+
new ${{ github.event.repository.name }} PR merged! https://github.com/${{ github.repository }}/pull/${{ github.event.number }}
36+
37+
publish_pypi:
38+
needs: publish_alpha
39+
if: success() # Ensure this job only runs if the previous job succeeds
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v2
43+
with:
44+
ref: dev
45+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
46+
- name: Setup Python
47+
uses: actions/setup-python@v1
48+
with:
49+
python-version: 3.8
50+
- name: Install Build Tools
51+
run: |
52+
python -m pip install build wheel
53+
- name: version
54+
run: echo "::set-output name=version::$(python setup.py --version)"
55+
id: version
56+
- name: Build Distribution Packages
57+
run: |
58+
python setup.py sdist bdist_wheel
59+
- name: Publish to PyPI
60+
uses: pypa/gh-action-pypi-publish@master
61+
with:
62+
password: ${{secrets.PYPI_TOKEN}}
63+
64+
65+
propose_release:
66+
needs: publish_alpha
67+
if: success() # Ensure this job only runs if the previous job succeeds
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Checkout dev branch
71+
uses: actions/checkout@v3
72+
with:
73+
ref: dev
74+
75+
- name: Setup Python
76+
uses: actions/setup-python@v2
77+
with:
78+
python-version: '3.10'
79+
80+
- name: Get version from setup.py
81+
id: get_version
82+
run: |
83+
VERSION=$(python setup.py --version)
84+
echo "VERSION=$VERSION" >> $GITHUB_ENV
85+
86+
- name: Create and push new branch
87+
run: |
88+
git checkout -b release-${{ env.VERSION }}
89+
git push origin release-${{ env.VERSION }}
90+
91+
- name: Open Pull Request from dev to master
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
run: |
95+
# Variables
96+
BRANCH_NAME="release-${{ env.VERSION }}"
97+
BASE_BRANCH="master"
98+
HEAD_BRANCH="release-${{ env.VERSION }}"
99+
PR_TITLE="Release ${{ env.VERSION }}"
100+
PR_BODY="Human review requested!"
101+
102+
# Create a PR using GitHub API
103+
curl -X POST \
104+
-H "Accept: application/vnd.github+json" \
105+
-H "Authorization: token $GITHUB_TOKEN" \
106+
-d "{\"title\":\"$PR_TITLE\",\"body\":\"$PR_BODY\",\"head\":\"$HEAD_BRANCH\",\"base\":\"$BASE_BRANCH\"}" \
107+
https://api.github.com/repos/${{ github.repository }}/pulls
108+

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
## [0.0.1a2](https://github.com/OpenVoiceOS/ovos-number-parser/tree/0.0.1a2) (2024-11-07)
4+
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)
11+
12+
**Merged pull requests:**
13+
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))
16+
17+
18+
19+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*

README.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,27 @@ fractional and ordinal numbers, and more.
1414

1515
## Supported Languages
1616

17-
| Language Code | Pronounce Number | Pronounce Ordinal | Extract Number | Is Fractional | Is Ordinal |
18-
|-------------------------|------------------|-------------------|----------------|---------------|------------|
19-
| `en` (English) ||||||
20-
| `az` (Azerbaijani) ||||||
21-
| `ca` (Catalan) ||||||
22-
| `cs` (Czech) ||||||
23-
| `da` (Danish) ||||||
24-
| `de` (German) ||||||
25-
| `es` (Spanish) ||||||
26-
| `eu` (Euskara / Basque) ||||||
27-
| `fa` (Farsi / Persian) ||||||
28-
| `fr` (French) ||||||
29-
| `hu` (Hungarian) ||||||
30-
| `it` (Italian) ||||||
31-
| `nl` (Dutch) ||||||
32-
| `pl` (Polish) ||||||
33-
| `pt` (Portuguese) ||||||
34-
| `ru` (Russian) ||||||
35-
| `sv` (Swedish) ||||||
36-
| `uk` (Ukrainian) ||||||
17+
| Language Code | Pronounce Number | Pronounce Ordinal | Extract Number | numbers_to_digits |
18+
|-------------------------|------------------|-------------------|----------------|-------------------|
19+
| `en` (English) |||||
20+
| `az` (Azerbaijani) |||||
21+
| `ca` (Catalan) |||||
22+
| `cs` (Czech) |||||
23+
| `da` (Danish) |||||
24+
| `de` (German) |||||
25+
| `es` (Spanish) |||||
26+
| `eu` (Euskara / Basque) |||||
27+
| `fa` (Farsi / Persian) |||||
28+
| `fr` (French) |||||
29+
| `hu` (Hungarian) |||||
30+
| `it` (Italian) |||||
31+
| `nl` (Dutch) |||||
32+
| `pl` (Polish) |||||
33+
| `pt` (Portuguese) |||||
34+
| `ru` (Russian) |||||
35+
| `sv` (Swedish) |||||
36+
| `sl` (Slovenian) |||||
37+
| `uk` (Ukrainian) |||||
3738

3839
## Installation
3940

@@ -82,7 +83,6 @@ print(result) # "one hundred and twenty-three"
8283

8384
Convert a number to its ordinal spoken equivalent.
8485

85-
8686
```python
8787
def pronounce_ordinal(number: Union[int, float], lang: str, short_scale: bool = True) -> str:
8888
"""
@@ -112,7 +112,6 @@ print(result) # "fifth"
112112

113113
Extract a number from a given text string.
114114

115-
116115
```python
117116
def extract_number(text: str, lang: str, short_scale: bool = True, ordinals: bool = False) -> Union[int, float, bool]:
118117
"""
@@ -143,7 +142,6 @@ print(result) # 20
143142

144143
Identify if the text contains a fractional number.
145144

146-
147145
```python
148146
def is_fractional(input_str: str, lang: str, short_scale: bool = True) -> Union[bool, float]:
149147
"""
@@ -173,7 +171,6 @@ print(result) # 0.5
173171

174172
Determine if the text contains an ordinal number.
175173

176-
177174
```python
178175
def is_ordinal(input_str: str, lang: str) -> Union[bool, float]:
179176
"""
@@ -198,6 +195,12 @@ result = is_ordinal("third", "en")
198195
print(result) # 3
199196
```
200197

198+
## Related Projects
199+
200+
- [ovos-date-parser](https://github.com/OpenVoiceOS/ovos-date-parser) - for handling dates and times
201+
- [ovos-lang-parser](https://github.com/OVOSHatchery/ovos-lang-parser) - for handling languages
202+
- [ovos-color-parser](https://github.com/OVOSHatchery/ovos-color-parser) - for handling colors
203+
201204
## License
202205

203206
This project is licensed under the Apache License 2.0.

ovos_number_parser/__init__.py

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,62 @@
11
from typing import Union
22

3-
from ovos_number_parser.numbers_az import extract_number_az, is_fractional_az, pronounce_number_az
3+
from ovos_number_parser.numbers_az import numbers_to_digits_az, extract_number_az, is_fractional_az, pronounce_number_az
44
from ovos_number_parser.numbers_ca import pronounce_number_ca, is_fractional_ca, extract_number_ca
5-
from ovos_number_parser.numbers_cs import pronounce_number_cs, is_fractional_cs, extract_number_cs
5+
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
8-
from ovos_number_parser.numbers_de import pronounce_number_de, pronounce_ordinal_de, is_ordinal_de, \
9-
is_fractional_de, extract_number_de
10-
from ovos_number_parser.numbers_en import is_ordinal_en, pronounce_number_en, extract_number_en, \
8+
from ovos_number_parser.numbers_de import numbers_to_digits_de, pronounce_number_de, pronounce_ordinal_de, \
9+
is_ordinal_de, is_fractional_de, extract_number_de
10+
from ovos_number_parser.numbers_en import numbers_to_digits_en, is_ordinal_en, pronounce_number_en, extract_number_en, \
1111
is_fractional_en
12-
from ovos_number_parser.numbers_es import pronounce_number_es, extract_number_es, is_fractional_es
12+
from ovos_number_parser.numbers_es import numbers_to_digits_es, pronounce_number_es, extract_number_es, is_fractional_es
1313
from ovos_number_parser.numbers_eu import pronounce_number_eu, extract_number_eu, is_fractional_eu
1414
from ovos_number_parser.numbers_fa import pronounce_number_fa, extract_number_fa
1515
from ovos_number_parser.numbers_fr import (pronounce_number_fr, extract_number_fr, is_fractional_fr)
1616
from ovos_number_parser.numbers_hu import pronounce_number_hu, pronounce_ordinal_hu
1717
from ovos_number_parser.numbers_it import (extract_number_it, pronounce_number_it, is_fractional_it)
18-
from ovos_number_parser.numbers_nl import pronounce_number_nl, pronounce_ordinal_nl, extract_number_nl, \
19-
is_fractional_nl
20-
from ovos_number_parser.numbers_pl import pronounce_number_pl, extract_number_pl, is_fractional_pl
21-
from ovos_number_parser.numbers_pt import pronounce_number_pt, is_fractional_pt, extract_number_pt
22-
from ovos_number_parser.numbers_ru import pronounce_number_ru, extract_number_ru, is_fractional_ru
18+
from ovos_number_parser.numbers_nl import numbers_to_digits_nl, pronounce_number_nl, pronounce_ordinal_nl, \
19+
extract_number_nl, is_fractional_nl
20+
from ovos_number_parser.numbers_pl import numbers_to_digits_pl, pronounce_number_pl, extract_number_pl, is_fractional_pl
21+
from ovos_number_parser.numbers_pt import numbers_to_digits_pt, pronounce_number_pt, is_fractional_pt, extract_number_pt
22+
from ovos_number_parser.numbers_ru import numbers_to_digits_ru, pronounce_number_ru, extract_number_ru, is_fractional_ru
2323
from ovos_number_parser.numbers_sv import pronounce_number_sv, pronounce_ordinal_sv, extract_number_sv, \
2424
is_fractional_sv
25-
from ovos_number_parser.numbers_uk import pronounce_number_uk, extract_number_uk, is_fractional_uk
25+
from ovos_number_parser.numbers_uk import numbers_to_digits_uk, pronounce_number_uk, extract_number_uk, is_fractional_uk
26+
from ovos_number_parser.numbers_sl import nice_number_sl, pronounce_number_sl
27+
28+
29+
def numbers_to_digits(utterance: str, lang: str) -> str:
30+
"""
31+
Replace written numbers in text with their digit equivalents.
32+
33+
Args:
34+
utterance (str): Input string possibly containing written numbers.
35+
36+
Returns:
37+
str: Text with written numbers replaced by digits.
38+
"""
39+
if lang.startswith("az"):
40+
return numbers_to_digits_az(utterance)
41+
if lang.startswith("cs"):
42+
return numbers_to_digits_cs(utterance)
43+
if lang.startswith("de"):
44+
return numbers_to_digits_de(utterance)
45+
if lang.startswith("en"):
46+
return numbers_to_digits_en(utterance)
47+
if lang.startswith("es"):
48+
return numbers_to_digits_es(utterance)
49+
if lang.startswith("nl"):
50+
return numbers_to_digits_nl(utterance)
51+
if lang.startswith("pl"):
52+
return numbers_to_digits_pl(utterance)
53+
if lang.startswith("pt"):
54+
return numbers_to_digits_pt(utterance)
55+
if lang.startswith("ru"):
56+
return numbers_to_digits_ru(utterance)
57+
if lang.startswith("uk"):
58+
return numbers_to_digits_uk(utterance)
59+
raise NotImplementedError(f"Unsupported language: '{lang}'")
2660

2761

2862
def pronounce_number(number: Union[int, float], lang: str, places: int = 2, short_scale: bool = True,
@@ -76,6 +110,8 @@ def pronounce_number(number: Union[int, float], lang: str, places: int = 2, shor
76110
return pronounce_number_pt(number, places)
77111
if lang.startswith("ru"):
78112
return pronounce_number_ru(number, places, short_scale, scientific, ordinals)
113+
if lang.startswith("sl"):
114+
return pronounce_number_sl(number, places, short_scale, scientific, ordinals)
79115
if lang.startswith("sv"):
80116
return pronounce_number_sv(number, places, short_scale, scientific, ordinals)
81117
if lang.startswith("uk"):

ovos_number_parser/numbers_az.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def _long_scale(n):
545545
return result
546546

547547

548-
def _convert_words_to_numbers_az(text, short_scale=True, ordinals=False):
548+
def numbers_to_digits_az(text, short_scale=True, ordinals=False):
549549
"""
550550
Convert words in a string into their equivalent numbers.
551551
Args:

0 commit comments

Comments
 (0)