@Test public void should_create_roots_with_consontant_insertion_s() { { final List<DynamicRoot> roots = findRootsForPartialInput("suborusu", "suborusuna"); assertThat(roots, hasSize(2)); assertThat(roots.get(0).getSequence().getUnderlyingString(), equalTo("suborus")); assertThat(roots.get(0).getLexeme().getLemmaRoot(), equalTo("suborusu")); assertThat(roots.get(0).getLexeme().getLemma(), equalTo("suborusu")); assertThat(roots.get(0).getLexeme().getPrimaryPos(), equalTo(PrimaryPos.Noun)); assertThat(roots.get(0).getLexeme().getAttributes(), equalTo((Set<LexemeAttribute>) ImmutableSet.of(LexemeAttribute.CompoundP3sg))); assertThat(roots.get(1).getSequence().getUnderlyingString(), equalTo("suboru")); assertThat(roots.get(1).getLexeme().getLemmaRoot(), equalTo("suborusu")); assertThat(roots.get(1).getLexeme().getLemma(), equalTo("suborusu")); assertThat(roots.get(1).getLexeme().getPrimaryPos(), equalTo(PrimaryPos.Noun)); assertThat(roots.get(1).getLexeme().getAttributes(), equalTo((Set<LexemeAttribute>) ImmutableSet.of(LexemeAttribute.CompoundP3sg))); } }
@Override public Collection<DynamicRoot> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence wholeSurface) { final TurkishChar previousChar = partialInput.charAt(partialInput.length() - 2); final List<DynamicRoot> compoundResults = new ArrayList<DynamicRoot>(); final Collection<DynamicRoot> resultsWithPartialInputOneCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 1), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputOneCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.setSequence(new TurkishSequence(cloneResult.getLexeme().getLemmaRoot())); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } final TurkicLetter previousLetter = previousChar.getLetter(); if (previousLetter.equals(TurkishAlphabet.L_s)) { final Collection<DynamicRoot> resultsWithPartialInputTwoCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 2), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputTwoCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } } for (DynamicRoot compoundResult : compoundResults) { compoundResult.getLexeme().getAttributes().add(LexemeAttribute.CompoundP3sg); } return compoundResults; }
BruteForceCompoundNounRootFinder implements RootFinder { @Override public Collection<DynamicRoot> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence wholeSurface) { final TurkishChar previousChar = partialInput.charAt(partialInput.length() - 2); final List<DynamicRoot> compoundResults = new ArrayList<DynamicRoot>(); final Collection<DynamicRoot> resultsWithPartialInputOneCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 1), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputOneCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.setSequence(new TurkishSequence(cloneResult.getLexeme().getLemmaRoot())); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } final TurkicLetter previousLetter = previousChar.getLetter(); if (previousLetter.equals(TurkishAlphabet.L_s)) { final Collection<DynamicRoot> resultsWithPartialInputTwoCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 2), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputTwoCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } } for (DynamicRoot compoundResult : compoundResults) { compoundResult.getLexeme().getAttributes().add(LexemeAttribute.CompoundP3sg); } return compoundResults; } }
BruteForceCompoundNounRootFinder implements RootFinder { @Override public Collection<DynamicRoot> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence wholeSurface) { final TurkishChar previousChar = partialInput.charAt(partialInput.length() - 2); final List<DynamicRoot> compoundResults = new ArrayList<DynamicRoot>(); final Collection<DynamicRoot> resultsWithPartialInputOneCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 1), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputOneCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.setSequence(new TurkishSequence(cloneResult.getLexeme().getLemmaRoot())); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } final TurkicLetter previousLetter = previousChar.getLetter(); if (previousLetter.equals(TurkishAlphabet.L_s)) { final Collection<DynamicRoot> resultsWithPartialInputTwoCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 2), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputTwoCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } } for (DynamicRoot compoundResult : compoundResults) { compoundResult.getLexeme().getAttributes().add(LexemeAttribute.CompoundP3sg); } return compoundResults; }  }
BruteForceCompoundNounRootFinder implements RootFinder { @Override public Collection<DynamicRoot> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence wholeSurface) { final TurkishChar previousChar = partialInput.charAt(partialInput.length() - 2); final List<DynamicRoot> compoundResults = new ArrayList<DynamicRoot>(); final Collection<DynamicRoot> resultsWithPartialInputOneCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 1), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputOneCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.setSequence(new TurkishSequence(cloneResult.getLexeme().getLemmaRoot())); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } final TurkicLetter previousLetter = previousChar.getLetter(); if (previousLetter.equals(TurkishAlphabet.L_s)) { final Collection<DynamicRoot> resultsWithPartialInputTwoCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 2), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputTwoCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } } for (DynamicRoot compoundResult : compoundResults) { compoundResult.getLexeme().getAttributes().add(LexemeAttribute.CompoundP3sg); } return compoundResults; }  @Override boolean handles(TurkishSequence partialInput, TurkishSequence wholeSurface); @Override Collection<DynamicRoot> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence wholeSurface); }
BruteForceCompoundNounRootFinder implements RootFinder { @Override public Collection<DynamicRoot> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence wholeSurface) { final TurkishChar previousChar = partialInput.charAt(partialInput.length() - 2); final List<DynamicRoot> compoundResults = new ArrayList<DynamicRoot>(); final Collection<DynamicRoot> resultsWithPartialInputOneCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 1), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputOneCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.setSequence(new TurkishSequence(cloneResult.getLexeme().getLemmaRoot())); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } final TurkicLetter previousLetter = previousChar.getLetter(); if (previousLetter.equals(TurkishAlphabet.L_s)) { final Collection<DynamicRoot> resultsWithPartialInputTwoCharMissing = this.bruteForceNounRootFinder.findRootsForPartialInput(partialInput.subsequence(0, partialInput.length() - 2), wholeSurface); for (DynamicRoot normalNounResult : resultsWithPartialInputTwoCharMissing) { final DynamicRoot cloneResult = new DynamicRoot(normalNounResult); cloneResult.getLexeme().setLemmaRoot(partialInput.getUnderlyingString()); cloneResult.getLexeme().setLemma(partialInput.getUnderlyingString()); compoundResults.add(cloneResult); } } for (DynamicRoot compoundResult : compoundResults) { compoundResult.getLexeme().getAttributes().add(LexemeAttribute.CompoundP3sg); } return compoundResults; }  @Override boolean handles(TurkishSequence partialInput, TurkishSequence wholeSurface); @Override Collection<DynamicRoot> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence wholeSurface);  }