JapaneseNumberNormalizer { public String normalizeNumber(String numberNotTrimmed) { String number = numberNotTrimmed.replaceAll("\\s+", ""); try { String fraction = getFraction(numberNotTrimmed); if (fraction != null) { return fraction; } NumberBuffer numberBuffer = new NumberBuffer(number); BigDecimal normalizedNumber = parseNumber(numberBuffer); if (normalizedNumber == null) { return numberNotTrimmed; } String formattedNumber = normalizedNumber.stripTrailingZeros().toPlainString(); if (numberNotTrimmed.contains("、")) { NumberFormat formatter = NumberFormat.getInstance(new Locale("en_US")); formattedNumber = formatter.format(normalizedNumber.longValue()); } return numberBuffer.prefix + formattedNumber + numberBuffer.suffix; } catch (NumberFormatException | ArithmeticException e) { return number; } }  String normalizeNumber(String numberNotTrimmed); BigDecimal parseLargeKanjiNumeral(NumberBuffer buffer); BigDecimal parseMediumKanjiNumeral(NumberBuffer buffer); boolean isArabicNumeral(char c);  }
@Test public void number() { for (String number : values.keySet()) { Assert.assertEquals(values.get(number), japaneseNumberFilter.normalizeNumber(number)); } }
@Test public void testMinusNumber() { for (String number : minusValues.keySet()) { Assert.assertEquals(minusValues.get(number), japaneseNumberFilter.normalizeNumber(number)); } }
@Test public void testFractionalNumber() { for (String number : fractionalValues.keySet()) { Assert.assertEquals(fractionalValues.get(number), japaneseNumberFilter.normalizeNumber(number)); } }