@Test public void shouldMatchApplication() { assertThat(engine.applicationMatches(new TurkishSequence("elma"), "elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("elmalar"), "elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("elmalar"), "elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("keklerim"), "kekler", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("armudunu"), "armut", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("armudunu"), "armudu", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("armudunu"), "armudunu", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("yapacağım"), "yap", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("yapacağım"), "yapacak", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("yapacağım"), "yapacağım", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("yapacağım"), "yap", false), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("armut"), "armut", false), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("Elma"), "Elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("Elmalar"), "Elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("Elmalar"), "Elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("elma"), "Elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("Elmalar"), "elma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("elmalar"), "eLma", true), equalTo(true)); assertThat(engine.applicationMatches(new TurkishSequence("ELMALAR"), "eLma", true), equalTo(true)); }
public boolean applicationMatches(final TurkishSequence input, final String appliedStr, final boolean voicingAllowed) { if (StringUtils.isBlank(appliedStr) || appliedStr.length() > input.length()) return false; final String inputUnderlyingString = input.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE); final String appliedStringToCheck = appliedStr.toLowerCase(Constants.TURKISH_LOCALE); if (inputUnderlyingString.equals(appliedStringToCheck) || inputUnderlyingString.startsWith(appliedStringToCheck)) return true; else if (voicingAllowed && inputUnderlyingString.startsWith(appliedStringToCheck.substring(0, appliedStringToCheck.length() - 1))) { final TurkicLetter lastLetterOfApplication = TurkishAlphabet.getLetter(appliedStringToCheck.charAt(appliedStringToCheck.length() - 1)); final TurkishChar lastLetterOfInputPart = input.charAt(appliedStringToCheck.length() - 1); return lastLetterOfInputPart.getLetter().equals(TurkishAlphabet.voice(lastLetterOfApplication)); } return false; }
PhoneticsEngine { public boolean applicationMatches(final TurkishSequence input, final String appliedStr, final boolean voicingAllowed) { if (StringUtils.isBlank(appliedStr) || appliedStr.length() > input.length()) return false; final String inputUnderlyingString = input.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE); final String appliedStringToCheck = appliedStr.toLowerCase(Constants.TURKISH_LOCALE); if (inputUnderlyingString.equals(appliedStringToCheck) || inputUnderlyingString.startsWith(appliedStringToCheck)) return true; else if (voicingAllowed && inputUnderlyingString.startsWith(appliedStringToCheck.substring(0, appliedStringToCheck.length() - 1))) { final TurkicLetter lastLetterOfApplication = TurkishAlphabet.getLetter(appliedStringToCheck.charAt(appliedStringToCheck.length() - 1)); final TurkishChar lastLetterOfInputPart = input.charAt(appliedStringToCheck.length() - 1); return lastLetterOfInputPart.getLetter().equals(TurkishAlphabet.voice(lastLetterOfApplication)); } return false; } }
PhoneticsEngine { public boolean applicationMatches(final TurkishSequence input, final String appliedStr, final boolean voicingAllowed) { if (StringUtils.isBlank(appliedStr) || appliedStr.length() > input.length()) return false; final String inputUnderlyingString = input.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE); final String appliedStringToCheck = appliedStr.toLowerCase(Constants.TURKISH_LOCALE); if (inputUnderlyingString.equals(appliedStringToCheck) || inputUnderlyingString.startsWith(appliedStringToCheck)) return true; else if (voicingAllowed && inputUnderlyingString.startsWith(appliedStringToCheck.substring(0, appliedStringToCheck.length() - 1))) { final TurkicLetter lastLetterOfApplication = TurkishAlphabet.getLetter(appliedStringToCheck.charAt(appliedStringToCheck.length() - 1)); final TurkishChar lastLetterOfInputPart = input.charAt(appliedStringToCheck.length() - 1); return lastLetterOfInputPart.getLetter().equals(TurkishAlphabet.voice(lastLetterOfApplication)); } return false; } PhoneticsEngine(SuffixFormSequenceApplier suffixFormSequenceApplier); }
PhoneticsEngine { public boolean applicationMatches(final TurkishSequence input, final String appliedStr, final boolean voicingAllowed) { if (StringUtils.isBlank(appliedStr) || appliedStr.length() > input.length()) return false; final String inputUnderlyingString = input.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE); final String appliedStringToCheck = appliedStr.toLowerCase(Constants.TURKISH_LOCALE); if (inputUnderlyingString.equals(appliedStringToCheck) || inputUnderlyingString.startsWith(appliedStringToCheck)) return true; else if (voicingAllowed && inputUnderlyingString.startsWith(appliedStringToCheck.substring(0, appliedStringToCheck.length() - 1))) { final TurkicLetter lastLetterOfApplication = TurkishAlphabet.getLetter(appliedStringToCheck.charAt(appliedStringToCheck.length() - 1)); final TurkishChar lastLetterOfInputPart = input.charAt(appliedStringToCheck.length() - 1); return lastLetterOfInputPart.getLetter().equals(TurkishAlphabet.voice(lastLetterOfApplication)); } return false; } PhoneticsEngine(SuffixFormSequenceApplier suffixFormSequenceApplier); boolean isSuffixFormApplicable(final Set<PhoneticAttribute> phoneticAttributes, final SuffixFormSequence suffixFormSequence); Pair<TurkishSequence, String> apply(TurkishSequence surface, SuffixFormSequence form, Collection<LexemeAttribute> lexemeAttributes); Pair<TurkishSequence, String> apply(final TurkishSequence surface, final Set<PhoneticAttribute> _phoneticAttributes, final SuffixFormSequence suffixFormSequence, final Collection<LexemeAttribute> _lexemeAttributes); boolean expectationsSatisfied(final Collection<PhoneticExpectation> phoneticExpectations, final SuffixFormSequence _form); boolean applicationMatches(final TurkishSequence input, final String appliedStr, final boolean voicingAllowed); }
PhoneticsEngine { public boolean applicationMatches(final TurkishSequence input, final String appliedStr, final boolean voicingAllowed) { if (StringUtils.isBlank(appliedStr) || appliedStr.length() > input.length()) return false; final String inputUnderlyingString = input.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE); final String appliedStringToCheck = appliedStr.toLowerCase(Constants.TURKISH_LOCALE); if (inputUnderlyingString.equals(appliedStringToCheck) || inputUnderlyingString.startsWith(appliedStringToCheck)) return true; else if (voicingAllowed && inputUnderlyingString.startsWith(appliedStringToCheck.substring(0, appliedStringToCheck.length() - 1))) { final TurkicLetter lastLetterOfApplication = TurkishAlphabet.getLetter(appliedStringToCheck.charAt(appliedStringToCheck.length() - 1)); final TurkishChar lastLetterOfInputPart = input.charAt(appliedStringToCheck.length() - 1); return lastLetterOfInputPart.getLetter().equals(TurkishAlphabet.voice(lastLetterOfApplication)); } return false; } PhoneticsEngine(SuffixFormSequenceApplier suffixFormSequenceApplier); boolean isSuffixFormApplicable(final Set<PhoneticAttribute> phoneticAttributes, final SuffixFormSequence suffixFormSequence); Pair<TurkishSequence, String> apply(TurkishSequence surface, SuffixFormSequence form, Collection<LexemeAttribute> lexemeAttributes); Pair<TurkishSequence, String> apply(final TurkishSequence surface, final Set<PhoneticAttribute> _phoneticAttributes, final SuffixFormSequence suffixFormSequence, final Collection<LexemeAttribute> _lexemeAttributes); boolean expectationsSatisfied(final Collection<PhoneticExpectation> phoneticExpectations, final SuffixFormSequence _form); boolean applicationMatches(final TurkishSequence input, final String appliedStr, final boolean voicingAllowed);  }