Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
OVOS Number Parser is a tool for extracting, pronouncing, and detecting numbers from text across multiple languages. It supports functionalities like converting numbers to their spoken forms, extracting numbers from text, identifying fractional and ordinal numbers, and more.
✅ - supported ❌ - not supported 🚧 - imperfect placeholder, needs rewriting
Language Code | Pronounce Number | Pronounce Ordinal | Extract Number | numbers_to_digits |
---|---|---|---|---|
en (English) | ✅ | ❌ | ✅ | ✅ |
az (Azerbaijani) | ✅ | ❌ | ✅ | ✅ |
ca (Catalan) | ✅ | ❌ | ✅ | 🚧 |
cs (Czech) | ✅ | ❌ | ✅ | ✅ |
da (Danish) | ✅ | ✅ | ✅ | ❌ |
de (German) | ✅ | ✅ | ✅ | ✅ |
es (Spanish) | ✅ | ❌ | ✅ | 🚧 |
eu (Euskara / Basque) | ✅ | ❌ | ✅ | ❌ |
fa (Farsi / Persian) | ✅ | ❌ | ✅ | ❌ |
fr (French) | ✅ | ❌ | ✅ | ❌ |
hu (Hungarian) | ✅ | ✅ | ❌ | ❌ |
it (Italian) | ✅ | ❌ | ✅ | ❌ |
nl (Dutch) | ✅ | ✅ | ✅ | ✅ |
pl (Polish) | ✅ | ❌ | ✅ | ✅ |
pt (Portuguese) | ✅ | ❌ | ✅ | 🚧 |
ru (Russian) | ✅ | ❌ | ✅ | ✅ |
sv (Swedish) | ✅ | ✅ | ✅ | ❌ |
sl (Slovenian) | ✅ | ❌ | ❌ | ❌ |
uk (Ukrainian) | ✅ | ❌ | ✅ | ✅ |
To install OVOS Number Parser, use:
pip install ovos-number-parser
Convert a number to its spoken equivalent.
def pronounce_number(number: Union[int, float], lang: str, places: int = 2, short_scale: bool = True,
scientific: bool = False, ordinals: bool = False) -> str:
"""
Convert a number to its spoken equivalent.
Args:
number: The number to pronounce.
lang (str): A BCP-47 language code.
places (int): Number of decimal places to express. Default is 2.
short_scale (bool): Use short (True) or long scale (False) for large numbers.
scientific (bool): Pronounce in scientific notation if True.
ordinals (bool): Pronounce as an ordinal if True.
Returns:
str: The pronounced number.
"""
Example Usage:
from ovos_number_parser import pronounce_number
# Example
result = pronounce_number(123, "en")
print(result) # "one hundred and twenty-three"
Convert a number to its ordinal spoken equivalent.
def pronounce_ordinal(number: Union[int, float], lang: str, short_scale: bool = True) -> str:
"""
Convert an ordinal number to its spoken equivalent.
Args:
number: The number to pronounce.
lang (str): A BCP-47 language code.
short_scale (bool): Use short (True) or long scale (False) for large numbers.
Returns:
str: The pronounced ordinal number.
"""
Example Usage:
from ovos_number_parser import pronounce_ordinal
# Example
result = pronounce_ordinal(5, "en")
print(result) # "fifth"
Extract a number from a given text string.
def extract_number(text: str, lang: str, short_scale: bool = True, ordinals: bool = False) -> Union[int, float, bool]:
"""
Extract a number from text.
Args:
text (str): The string to extract a number from.
lang (str): A BCP-47 language code.
short_scale (bool): Use short scale if True, long scale if False.
ordinals (bool): Consider ordinal numbers.
Returns:
int, float, or False: The extracted number, or False if no number found.
"""
Example Usage:
from ovos_number_parser import extract_number
# Example
result = extract_number("I have twenty apples", "en")
print(result) # 20
Identify if the text contains a fractional number.
def is_fractional(input_str: str, lang: str, short_scale: bool = True) -> Union[bool, float]:
"""
Check if the text is a fraction.
Args:
input_str (str): The string to check if fractional.
lang (str): A BCP-47 language code.
short_scale (bool): Use short scale if True, long scale if False.
Returns:
bool or float: False if not a fraction, otherwise the fraction as a float.
"""
Example Usage:
from ovos_number_parser import is_fractional
# Example
result = is_fractional("half", "en")
print(result) # 0.5
Determine if the text contains an ordinal number.
def is_ordinal(input_str: str, lang: str) -> Union[bool, float]:
"""
Check if the text is an ordinal number.
Args:
input_str (str): The string to check if ordinal.
lang (str): A BCP-47 language code.
Returns:
bool or float: False if not an ordinal, otherwise the ordinal as a float.
"""
Example Usage:
from ovos_number_parser import is_ordinal
# Example
result = is_ordinal("third", "en")
print(result) # 3
This project is licensed under the Apache License 2.0.
FAQs
OpenVoiceOS's multilingual text parsing and formatting library
We found that ovos-number-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.