@Test public void testShouldRecognizeNumbersWithDotOrCommaWithoutSuffixes() { { final List<Root> rootsForPartialInput = findRootsForPartialInput("3", "3,5"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("3,", "3,5"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("3,5", "3,5"); assertThat(rootsForPartialInput, hasSize(1)); assertThat(rootsForPartialInput.get(0), hasRootStr("3,5")); assertThat(rootsForPartialInput.get(0), hasCardinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("üç virgül beş")); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,1", "-99,101"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,10", "-99,101"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,101", "-99,101"); assertThat(rootsForPartialInput, hasSize(1)); assertThat(rootsForPartialInput.get(0), hasRootStr("-99,101")); assertThat(rootsForPartialInput.get(0), hasCardinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("eksi doksan dokuz virgül yüz bir")); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,1", "-99,101"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,10", "-99,101"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,101", "-99,101"); assertThat(rootsForPartialInput, hasSize(1)); assertThat(rootsForPartialInput.get(0), hasRootStr("-99,101")); assertThat(rootsForPartialInput.get(0), hasCardinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("eksi doksan dokuz virgül yüz bir")); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("+99.", "+99.000,12"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("+99.000,", "+99.000,12"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("+99.000,12", "+99.000,12"); assertThat(rootsForPartialInput, hasSize(1)); assertThat(rootsForPartialInput.get(0), hasRootStr("+99.000,12")); assertThat(rootsForPartialInput.get(0), hasCardinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("doksan dokuz bin virgül on iki")); } }
@Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String underlyingNumeralText = digitsToTextConverter.convert(partialInputUnderlyingString); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsCardinal, phoneticAttributes)); }
CardinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String underlyingNumeralText = digitsToTextConverter.convert(partialInputUnderlyingString); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsCardinal, phoneticAttributes)); } }
CardinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String underlyingNumeralText = digitsToTextConverter.convert(partialInputUnderlyingString); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsCardinal, phoneticAttributes)); } CardinalDigitsRootFinder(); }
CardinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String underlyingNumeralText = digitsToTextConverter.convert(partialInputUnderlyingString); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsCardinal, phoneticAttributes)); } CardinalDigitsRootFinder(); @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input); }
CardinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String underlyingNumeralText = digitsToTextConverter.convert(partialInputUnderlyingString); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsCardinal, phoneticAttributes)); } CardinalDigitsRootFinder(); @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input);  }