Class NumberToWordsConverter
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.util.NumberToWordsConverter
Converts number to words like 1 to one and 3 to three.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefault constructor which only replaces numbers between 0 and 9 (both inclusive).NumberToWordsConverter
(int to) Specify a range in which numbers should be converted toNumberToWordsConverter
(int from, int to) Specify a range in which numbers should be converted to -
Method Summary
Modifier and TypeMethodDescriptionstatic String
convert
(int number) static String
private static String
convertLessThanOneThousand
(int number) static String
Replaces all number in text with corresponding words.replaceNumbersInText
(String text) Replace numbers in arbirary text like "hello 42 nice2have".replaceNumberToken
(String number) Returns the number (like "1" or "42") as words ("one" or "fourty two").
-
Field Details
-
numberPattern
-
replacementMap
-
specialNames
-
tensNames
-
numNames
-
-
Constructor Details
-
NumberToWordsConverter
public NumberToWordsConverter(int from, int to) Specify a range in which numbers should be converted to- Parameters:
from
- from value (inclusive)to
- to value (inclusive)
-
NumberToWordsConverter
public NumberToWordsConverter(int to) Specify a range in which numbers should be converted to- Parameters:
to
- to value (inclusive)
-
NumberToWordsConverter
public NumberToWordsConverter()Default constructor which only replaces numbers between 0 and 9 (both inclusive). Thus "11" is not converted to words.
-
-
Method Details
-
replaceNumbersInText
Replace numbers in arbirary text like "hello 42 nice2have". It will return "hello fourty two nicetwohave" (only in case the numbers are in the specified range).- Parameters:
text
- any text containing numbers- Returns:
- text with numbers replaced as words.
-
replaceNumberToken
Returns the number (like "1" or "42") as words ("one" or "fourty two"). The parameter should only contain the number as single token and nothing more. If you want to replace numbers in text usereplaceNumbersInText(java.lang.String)
.- Parameters:
number
- a string containing only a number like "1" or "42"- Returns:
- the number as words
-
getReplacementMap
-
replaceAllNumbersInText
Replaces all number in text with corresponding words. "hello 42 nice2have" will be converted to "hello fourty two nicetwohave".- Parameters:
text
- any text containing numbers- Returns:
- text with numbers replaced as words.
-
convert
-
convert
-
convertLessThanOneThousand
-