@Test public void shouldNotRecognizeProperNouns_whenInputDoesntStartWithUppercase() { { final List<? extends Root> roots = findRootsForPartialInput("a", "ali"); assertThat(roots, hasSize(0)); } { final List<? extends Root> roots = findRootsForPartialInput("al", "ali"); assertThat(roots, hasSize(0)); } { final List<? extends Root> roots = findRootsForPartialInput("ali", "ali"); assertThat(roots, hasSize(0)); } { final List<? extends Root> roots = findRootsForPartialInput("123A", "123A"); assertThat(roots, hasSize(0)); } }
@Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); if (partialInput.equals(input) && StringUtils.isAllUpperCase(partialInputUnderlyingString)) { final Lexeme abbreviationLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!partialInput.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } } else { final Lexeme properNounLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); final ImmutableRoot properNounRoot = new ImmutableRoot(partialInput, properNounLexeme, phoneticAttributes, null); return Arrays.asList(properNounRoot); } }
ProperNounWithoutApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); if (partialInput.equals(input) && StringUtils.isAllUpperCase(partialInputUnderlyingString)) { final Lexeme abbreviationLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!partialInput.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } } else { final Lexeme properNounLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); final ImmutableRoot properNounRoot = new ImmutableRoot(partialInput, properNounLexeme, phoneticAttributes, null); return Arrays.asList(properNounRoot); } } }
ProperNounWithoutApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); if (partialInput.equals(input) && StringUtils.isAllUpperCase(partialInputUnderlyingString)) { final Lexeme abbreviationLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!partialInput.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } } else { final Lexeme properNounLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); final ImmutableRoot properNounRoot = new ImmutableRoot(partialInput, properNounLexeme, phoneticAttributes, null); return Arrays.asList(properNounRoot); } }  }
ProperNounWithoutApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); if (partialInput.equals(input) && StringUtils.isAllUpperCase(partialInputUnderlyingString)) { final Lexeme abbreviationLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!partialInput.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } } else { final Lexeme properNounLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); final ImmutableRoot properNounRoot = new ImmutableRoot(partialInput, properNounLexeme, phoneticAttributes, null); return Arrays.asList(properNounRoot); } }  @Override boolean handles(TurkishSequence partialInput, TurkishSequence wholeSurface); @Override List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input); }
ProperNounWithoutApostropheRootFinder implements RootFinder { @Override public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) { final String partialInputUnderlyingString = partialInput.getUnderlyingString(); if (partialInput.equals(input) && StringUtils.isAllUpperCase(partialInputUnderlyingString)) { final Lexeme abbreviationLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null); if (!partialInput.getLastChar().getLetter().isVowel()) { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput.append(TURKISH_CHAR_E_UPPERCASE), null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } else { final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null)); } } else { final Lexeme properNounLexeme = new ImmutableLexeme(partialInputUnderlyingString, partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null); final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null)); final ImmutableRoot properNounRoot = new ImmutableRoot(partialInput, properNounLexeme, phoneticAttributes, null); return Arrays.asList(properNounRoot); } }  @Override boolean handles(TurkishSequence partialInput, TurkishSequence wholeSurface); @Override List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input);  }