-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38eee13
commit c86df31
Showing
9 changed files
with
94 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from unicode_rbnf import RbnfEngine | ||
|
||
|
||
def test_german(): | ||
engine = RbnfEngine.for_language("es") | ||
assert engine.format_number(5) == "cinco" | ||
assert engine.format_number(2) == "dos" | ||
assert engine.format_number(5.2) == "cinco coma dos" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
from pathlib import Path | ||
|
||
from .engine import RbnfEngine, RulesetName | ||
|
||
_DIR = Path(__file__).parent | ||
|
||
__version__ = (_DIR / "VERSION").read_text(encoding="utf-8").strip() | ||
|
||
__all__ = [ | ||
"__version__", | ||
"RbnfEngine", | ||
"RulesetName", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import argparse | ||
|
||
from unicode_rbnf import RbnfEngine, RulesetName | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--language", | ||
choices=RbnfEngine.get_supported_languages(), | ||
required=True, | ||
help="Language code", | ||
) | ||
parser.add_argument( | ||
"--rule", | ||
choices=[v.value for v in RulesetName], | ||
help="Ruleset name", | ||
) | ||
parser.add_argument("number", nargs="+", help="Number(s) to turn into words") | ||
args = parser.parse_args() | ||
|
||
engine = RbnfEngine.for_language(args.language) | ||
for number_str in args.number: | ||
words = engine.format_number(number_str, ruleset_name=args.rule) | ||
print(words) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters