#numbers #german

bin+lib whoa-german-numbers

parse and interpret written german numbers

2 releases

0.0.2 Jul 18, 2022
0.0.1 Jul 18, 2022

#17 in #numbers

MIT license

294 lines

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


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.


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");


No runtime deps