whoa-german-numbers

Crates.iowhoa-german-numbers
lib.rswhoa-german-numbers
version0.0.2
sourcesrc
created_at2022-07-18 17:42:45.2392
updated_at2022-07-18 17:54:55.765861
descriptionparse and interpret written german numbers
homepage
repositoryhttps://github.com/spencermountain/whoa-german-numbers
max_upload_size
id627851
size24,191
spencer kelly (spencermountain)

documentation

README

Note it's my first crate, plz go easy on me!

whoa-german-numbers

parse textual german number formats in rust

Current Version Documentation License: MIT

Notably, numbers are not segmented by spaces or dashes in german - meaning they can be quite unruly sometimes.

Usage

extern crate whoa_german_numbers;
use whoa_german_numbers::{number_to_text, text_to_number};

let num = text_to_number("zwölf");
assert_eq!(num.unwrap(), 12);

let str = number_to_text(121);
assert_eq!(str, "einhunderteinundzwanzig");

*/

text_to_number - "fünf" -> 5

Convert written german numbers like "dreitausend" to integers (like 3000).

use whoa-german-numbers::text_to_number;

assert_eq!(text_to_number("fünf").unwrap(), 5);
assert_eq!(text_to_number("fünfte").unwrap(), 5); //ordinal support
assert_eq!(text_to_number("zweihundertzehn").unwrap(), 210);

number_to_text - 5 -> "fünf"

Convert an integer (like 81), into a german text number, like "einundachtzig".

use whoa-german-numbers::number_to_text;

assert_eq!(number_to_text(81), "einundachtzig");
assert_eq!(number_to_text(5), "fünf");
assert_eq!(number_to_text(131), "einhunderteinunddreißig");

MIT

Commit count: 13

cargo fmt