@Test public void testShouldRecognizeOrdinals() { { final List<Root> rootsForPartialInput = findRootsForPartialInput("3.", "3.5"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("3.", "3.a"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("12.22.", "12.22."); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("1.123.", "1.123.456."); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-1,10.", "-1,10."); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,101.", "-99,101."); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("-99,1.", "-99,1.01"); 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), hasOrdinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("eksi doksan dokuz bin yüz birinci")); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("+99.", "+99.'ya"); assertThat(rootsForPartialInput, hasSize(1)); assertThat(rootsForPartialInput.get(0), hasRootStr("+99.")); assertThat(rootsForPartialInput.get(0), hasOrdinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("doksan dokuzuncu")); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("+99.000,", "+99.000,12"); assertThat(rootsForPartialInput, hasSize(0)); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("444.", "444.'ün"); assertThat(rootsForPartialInput, hasSize(1)); assertThat(rootsForPartialInput.get(0), hasRootStr("444.")); assertThat(rootsForPartialInput.get(0), hasOrdinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("dört yüz kırk dördüncü")); } { final List<Root> rootsForPartialInput = findRootsForPartialInput("1113.", "1113."); assertThat(rootsForPartialInput, hasSize(1)); assertThat(rootsForPartialInput.get(0), hasRootStr("1113.")); assertThat(rootsForPartialInput.get(0), hasOrdinalDigitLexeme()); assertThat(rootsForPartialInput.get(0), hasUnderlyingNumeralText("bin yüz on üçüncü")); } }
@Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String strNumeralWithoutOrdinalChar = partialInputUnderlyingString.substring(0, partialInputUnderlyingString.length() - 1); final String underlyingNumeralTextWithoutOrdinal = digitsToTextConverter.convert(strNumeralWithoutOrdinalChar); final boolean voicingAllowed = voicingAllowed(strNumeralWithoutOrdinalChar); final String underlyingNumeralText = this.applyOrdinalText(underlyingNumeralTextWithoutOrdinal, voicingAllowed); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsOrdinal, phoneticAttributes)); }
OrdinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String strNumeralWithoutOrdinalChar = partialInputUnderlyingString.substring(0, partialInputUnderlyingString.length() - 1); final String underlyingNumeralTextWithoutOrdinal = digitsToTextConverter.convert(strNumeralWithoutOrdinalChar); final boolean voicingAllowed = voicingAllowed(strNumeralWithoutOrdinalChar); final String underlyingNumeralText = this.applyOrdinalText(underlyingNumeralTextWithoutOrdinal, voicingAllowed); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsOrdinal, phoneticAttributes)); } }
OrdinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String strNumeralWithoutOrdinalChar = partialInputUnderlyingString.substring(0, partialInputUnderlyingString.length() - 1); final String underlyingNumeralTextWithoutOrdinal = digitsToTextConverter.convert(strNumeralWithoutOrdinalChar); final boolean voicingAllowed = voicingAllowed(strNumeralWithoutOrdinalChar); final String underlyingNumeralText = this.applyOrdinalText(underlyingNumeralTextWithoutOrdinal, voicingAllowed); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsOrdinal, phoneticAttributes)); } OrdinalDigitsRootFinder(); }
OrdinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String strNumeralWithoutOrdinalChar = partialInputUnderlyingString.substring(0, partialInputUnderlyingString.length() - 1); final String underlyingNumeralTextWithoutOrdinal = digitsToTextConverter.convert(strNumeralWithoutOrdinalChar); final boolean voicingAllowed = voicingAllowed(strNumeralWithoutOrdinalChar); final String underlyingNumeralText = this.applyOrdinalText(underlyingNumeralTextWithoutOrdinal, voicingAllowed); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsOrdinal, phoneticAttributes)); } OrdinalDigitsRootFinder(); @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input); }
OrdinalDigitsRootFinder implements RootFinder { @Override public List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); final String strNumeralWithoutOrdinalChar = partialInputUnderlyingString.substring(0, partialInputUnderlyingString.length() - 1); final String underlyingNumeralTextWithoutOrdinal = digitsToTextConverter.convert(strNumeralWithoutOrdinalChar); final boolean voicingAllowed = voicingAllowed(strNumeralWithoutOrdinalChar); final String underlyingNumeralText = this.applyOrdinalText(underlyingNumeralTextWithoutOrdinal, voicingAllowed); final ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.copyOf(this.phoneticsAnalyzer.calculatePhoneticAttributes(underlyingNumeralText, null)); return Arrays.asList((Root) new NumeralRoot(partialInput, underlyingNumeralText, SecondaryPos.DigitsOrdinal, phoneticAttributes)); } OrdinalDigitsRootFinder(); @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override List<Root> findRootsForPartialInput(final TurkishSequence partialInput, final TurkishSequence input);  }