@Test public void ordinalTest() { Assert.assertEquals("sıfırıncı", TurkishNumbers.convertOrdinalNumberString("0.")); }
public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); String lastNumber = words[words.length - 1]; if (ordinalMap.containsKey(lastNumber)) { lastNumber = ordinalMap.get(lastNumber); } else { throw new RuntimeException("Cannot find ordinal reading for:" + lastNumber); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < words.length - 1; i++) { sb.append(words[i]).append(" "); } sb.append(lastNumber); return sb.toString(); }
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); String lastNumber = words[words.length - 1]; if (ordinalMap.containsKey(lastNumber)) { lastNumber = ordinalMap.get(lastNumber); } else { throw new RuntimeException("Cannot find ordinal reading for:" + lastNumber); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < words.length - 1; i++) { sb.append(words[i]).append(" "); } sb.append(lastNumber); return sb.toString(); } }
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); String lastNumber = words[words.length - 1]; if (ordinalMap.containsKey(lastNumber)) { lastNumber = ordinalMap.get(lastNumber); } else { throw new RuntimeException("Cannot find ordinal reading for:" + lastNumber); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < words.length - 1; i++) { sb.append(words[i]).append(" "); } sb.append(lastNumber); return sb.toString(); }  }
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); String lastNumber = words[words.length - 1]; if (ordinalMap.containsKey(lastNumber)) { lastNumber = ordinalMap.get(lastNumber); } else { throw new RuntimeException("Cannot find ordinal reading for:" + lastNumber); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < words.length - 1; i++) { sb.append(words[i]).append(" "); } sb.append(lastNumber); return sb.toString(); }  static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static List<String> replaceNumberStrings(List<String> inputSequence); static List<String> seperateConnectedNumbers(List<String> inputSequence); static List<String> seperateConnectedNumbers(String input); static long convertToNumber(String... words); static long convertToNumber(String text); static String convertOrdinalNumberString(String input); static List<String> separateNumbers(String s); static String getOrdinal(String input); static boolean hasNumber(String s); static boolean hasOnlyNumber(String s); static int romanToDecimal(String s); }
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); String lastNumber = words[words.length - 1]; if (ordinalMap.containsKey(lastNumber)) { lastNumber = ordinalMap.get(lastNumber); } else { throw new RuntimeException("Cannot find ordinal reading for:" + lastNumber); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < words.length - 1; i++) { sb.append(words[i]).append(" "); } sb.append(lastNumber); return sb.toString(); }  static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static List<String> replaceNumberStrings(List<String> inputSequence); static List<String> seperateConnectedNumbers(List<String> inputSequence); static List<String> seperateConnectedNumbers(String input); static long convertToNumber(String... words); static long convertToNumber(String text); static String convertOrdinalNumberString(String input); static List<String> separateNumbers(String s); static String getOrdinal(String input); static boolean hasNumber(String s); static boolean hasOnlyNumber(String s); static int romanToDecimal(String s); static final long MAX_NUMBER; static final long MIN_NUMBER; }