@Test public void shouldNotRecognizeProperNounIfFirstCharIsNotUppercase() { assertThat(findRootsForPartialInput("aaa'", "aaa'e"), hasSize(0)); assertThat(findRootsForPartialInput("aAAAA'", "aAAAA'e"), hasSize(0)); assertThat(findRootsForPartialInput("1aa'", "1aa'e"), hasSize(0)); assertThat(findRootsForPartialInput("a111'", "a111'e"), hasSize(0)); assertThat(findRootsForPartialInput("şaa'", "şaa'e"), hasSize(0)); }
@Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final TurkishSequence properNounCandidate = partialInput.subsequence(0, partialInput.length() - 1); final String properNounCandidateUnderlyingString = properNounCandidate.getUnderlyingString(); if (StringUtils.isAllUpperCase(properNounCandidateUnderlyingString)) { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!properNounCandidate.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } } else { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } }
ProperNounFromApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final TurkishSequence properNounCandidate = partialInput.subsequence(0, partialInput.length() - 1); final String properNounCandidateUnderlyingString = properNounCandidate.getUnderlyingString(); if (StringUtils.isAllUpperCase(properNounCandidateUnderlyingString)) { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!properNounCandidate.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } } else { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } } }
ProperNounFromApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final TurkishSequence properNounCandidate = partialInput.subsequence(0, partialInput.length() - 1); final String properNounCandidateUnderlyingString = properNounCandidate.getUnderlyingString(); if (StringUtils.isAllUpperCase(properNounCandidateUnderlyingString)) { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!properNounCandidate.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } } else { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } }  }
ProperNounFromApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final TurkishSequence properNounCandidate = partialInput.subsequence(0, partialInput.length() - 1); final String properNounCandidateUnderlyingString = properNounCandidate.getUnderlyingString(); if (StringUtils.isAllUpperCase(properNounCandidateUnderlyingString)) { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!properNounCandidate.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } } else { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } }  @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input); }
ProperNounFromApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final TurkishSequence properNounCandidate = partialInput.subsequence(0, partialInput.length() - 1); final String properNounCandidateUnderlyingString = properNounCandidate.getUnderlyingString(); if (StringUtils.isAllUpperCase(properNounCandidateUnderlyingString)) { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!properNounCandidate.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } } else { final Lexeme lexeme = new ImmutableLexeme(properNounCandidateUnderlyingString, properNounCandidateUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(properNounCandidate, null)); return Arrays.asList(new ImmutableRoot(properNounCandidate, lexeme, phoneticAttributes, null)); } }  @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input);  }