@Test public void shouldGenerateConvertingCircumflexes() { { Lexeme lexeme = new ImmutableLexeme("rüzgâr", "rüzgâr", PrimaryPos.Noun, null, null); HashSet<ImmutableRoot> generatedRoots = generator.generate(lexeme); assertThat(generatedRoots, hasSize(2)); assertThat(generatedRoots, hasItem(new ImmutableRoot("rüzgar", lexeme, ImmutableSet.of(FLC, LVB, LLC, LLNotVless, LVU), null))); assertThat(generatedRoots, hasItem(new ImmutableRoot("rüzgâr", lexeme, ImmutableSet.of(FLC, LVB, LLC, LLNotVless, LVU), null))); } { Lexeme lexeme = new ImmutableLexeme("alenî", "alenî", PrimaryPos.Adjective, null, null); HashSet<ImmutableRoot> generatedRoots = generator.generate(lexeme); assertThat(generatedRoots, hasSize(2)); assertThat(generatedRoots, hasItem(new ImmutableRoot("aleni", lexeme, ImmutableSet.of(FLV, LVF, LLV, LLNotVless, LVU), null))); assertThat(generatedRoots, hasItem(new ImmutableRoot("alenî", lexeme, ImmutableSet.of(FLV, LVF, LLV, LLNotVless, LVU), null))); } { Lexeme lexeme = new ImmutableLexeme("cülûs", "cülûs", PrimaryPos.Noun, null, null); HashSet<ImmutableRoot> generatedRoots = generator.generate(lexeme); assertThat(generatedRoots, hasSize(2)); assertThat(generatedRoots, hasItem(new ImmutableRoot("cülus", lexeme, ImmutableSet.of(FLC, LVF, LLC, LLVless, LVR), null))); assertThat(generatedRoots, hasItem(new ImmutableRoot("cülûs", lexeme, ImmutableSet.of(FLC, LVF, LLC, LLVless, LVR), null))); } }
@Override public HashSet<ImmutableRoot> generate(Lexeme lexeme) { final HashSet<ImmutableRoot> rootsWithCircumflexes = super.generate(lexeme); final char[] lemmaRootChars = lexeme.getLemmaRoot().toCharArray(); LinkedList<Integer> circumflexed_A_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_I_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_U_indices = new LinkedList<Integer>(); boolean hasCircumflex = false; for (int i = 0; i < lemmaRootChars.length; i++) { char lemmaRootChar = lemmaRootChars[i]; if (lemmaRootChar == CIRCUMFLEX_A) { circumflexed_A_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_I) { circumflexed_I_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_U) { circumflexed_U_indices.add(i); hasCircumflex = true; } } if (!hasCircumflex) { return rootsWithCircumflexes; } else { final HashSet<ImmutableRoot> roots = new HashSet<ImmutableRoot>(); roots.addAll(rootsWithCircumflexes); for (ImmutableRoot rootWithCircumflexes : rootsWithCircumflexes) { final TurkishChar[] underlyingRootChars = rootWithCircumflexes.getSequence().getChars(); for (Integer circumflexed_A_index : circumflexed_A_indices) { underlyingRootChars[circumflexed_A_index] = new TurkishChar(PLAIN_A, TurkishAlphabet.L_a); } for (Integer circumflexed_I_index : circumflexed_I_indices) { underlyingRootChars[circumflexed_I_index] = new TurkishChar(PLAIN_I, TurkishAlphabet.L_i); } for (Integer circumflexed_U_index : circumflexed_U_indices) { underlyingRootChars[circumflexed_U_index] = new TurkishChar(PLAIN_U, TurkishAlphabet.L_u); } final ImmutableRoot rootWithoutCircumflexes = new ImmutableRoot(new TurkishSequence(underlyingRootChars), lexeme, rootWithCircumflexes.getPhoneticAttributes(), rootWithCircumflexes.getPhoneticExpectations()); roots.add(rootWithoutCircumflexes); } return roots; } }
CircumflexConvertingRootGenerator extends ImmutableRootGenerator { @Override public HashSet<ImmutableRoot> generate(Lexeme lexeme) { final HashSet<ImmutableRoot> rootsWithCircumflexes = super.generate(lexeme); final char[] lemmaRootChars = lexeme.getLemmaRoot().toCharArray(); LinkedList<Integer> circumflexed_A_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_I_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_U_indices = new LinkedList<Integer>(); boolean hasCircumflex = false; for (int i = 0; i < lemmaRootChars.length; i++) { char lemmaRootChar = lemmaRootChars[i]; if (lemmaRootChar == CIRCUMFLEX_A) { circumflexed_A_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_I) { circumflexed_I_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_U) { circumflexed_U_indices.add(i); hasCircumflex = true; } } if (!hasCircumflex) { return rootsWithCircumflexes; } else { final HashSet<ImmutableRoot> roots = new HashSet<ImmutableRoot>(); roots.addAll(rootsWithCircumflexes); for (ImmutableRoot rootWithCircumflexes : rootsWithCircumflexes) { final TurkishChar[] underlyingRootChars = rootWithCircumflexes.getSequence().getChars(); for (Integer circumflexed_A_index : circumflexed_A_indices) { underlyingRootChars[circumflexed_A_index] = new TurkishChar(PLAIN_A, TurkishAlphabet.L_a); } for (Integer circumflexed_I_index : circumflexed_I_indices) { underlyingRootChars[circumflexed_I_index] = new TurkishChar(PLAIN_I, TurkishAlphabet.L_i); } for (Integer circumflexed_U_index : circumflexed_U_indices) { underlyingRootChars[circumflexed_U_index] = new TurkishChar(PLAIN_U, TurkishAlphabet.L_u); } final ImmutableRoot rootWithoutCircumflexes = new ImmutableRoot(new TurkishSequence(underlyingRootChars), lexeme, rootWithCircumflexes.getPhoneticAttributes(), rootWithCircumflexes.getPhoneticExpectations()); roots.add(rootWithoutCircumflexes); } return roots; } } }
CircumflexConvertingRootGenerator extends ImmutableRootGenerator { @Override public HashSet<ImmutableRoot> generate(Lexeme lexeme) { final HashSet<ImmutableRoot> rootsWithCircumflexes = super.generate(lexeme); final char[] lemmaRootChars = lexeme.getLemmaRoot().toCharArray(); LinkedList<Integer> circumflexed_A_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_I_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_U_indices = new LinkedList<Integer>(); boolean hasCircumflex = false; for (int i = 0; i < lemmaRootChars.length; i++) { char lemmaRootChar = lemmaRootChars[i]; if (lemmaRootChar == CIRCUMFLEX_A) { circumflexed_A_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_I) { circumflexed_I_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_U) { circumflexed_U_indices.add(i); hasCircumflex = true; } } if (!hasCircumflex) { return rootsWithCircumflexes; } else { final HashSet<ImmutableRoot> roots = new HashSet<ImmutableRoot>(); roots.addAll(rootsWithCircumflexes); for (ImmutableRoot rootWithCircumflexes : rootsWithCircumflexes) { final TurkishChar[] underlyingRootChars = rootWithCircumflexes.getSequence().getChars(); for (Integer circumflexed_A_index : circumflexed_A_indices) { underlyingRootChars[circumflexed_A_index] = new TurkishChar(PLAIN_A, TurkishAlphabet.L_a); } for (Integer circumflexed_I_index : circumflexed_I_indices) { underlyingRootChars[circumflexed_I_index] = new TurkishChar(PLAIN_I, TurkishAlphabet.L_i); } for (Integer circumflexed_U_index : circumflexed_U_indices) { underlyingRootChars[circumflexed_U_index] = new TurkishChar(PLAIN_U, TurkishAlphabet.L_u); } final ImmutableRoot rootWithoutCircumflexes = new ImmutableRoot(new TurkishSequence(underlyingRootChars), lexeme, rootWithCircumflexes.getPhoneticAttributes(), rootWithCircumflexes.getPhoneticExpectations()); roots.add(rootWithoutCircumflexes); } return roots; } }  }
CircumflexConvertingRootGenerator extends ImmutableRootGenerator { @Override public HashSet<ImmutableRoot> generate(Lexeme lexeme) { final HashSet<ImmutableRoot> rootsWithCircumflexes = super.generate(lexeme); final char[] lemmaRootChars = lexeme.getLemmaRoot().toCharArray(); LinkedList<Integer> circumflexed_A_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_I_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_U_indices = new LinkedList<Integer>(); boolean hasCircumflex = false; for (int i = 0; i < lemmaRootChars.length; i++) { char lemmaRootChar = lemmaRootChars[i]; if (lemmaRootChar == CIRCUMFLEX_A) { circumflexed_A_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_I) { circumflexed_I_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_U) { circumflexed_U_indices.add(i); hasCircumflex = true; } } if (!hasCircumflex) { return rootsWithCircumflexes; } else { final HashSet<ImmutableRoot> roots = new HashSet<ImmutableRoot>(); roots.addAll(rootsWithCircumflexes); for (ImmutableRoot rootWithCircumflexes : rootsWithCircumflexes) { final TurkishChar[] underlyingRootChars = rootWithCircumflexes.getSequence().getChars(); for (Integer circumflexed_A_index : circumflexed_A_indices) { underlyingRootChars[circumflexed_A_index] = new TurkishChar(PLAIN_A, TurkishAlphabet.L_a); } for (Integer circumflexed_I_index : circumflexed_I_indices) { underlyingRootChars[circumflexed_I_index] = new TurkishChar(PLAIN_I, TurkishAlphabet.L_i); } for (Integer circumflexed_U_index : circumflexed_U_indices) { underlyingRootChars[circumflexed_U_index] = new TurkishChar(PLAIN_U, TurkishAlphabet.L_u); } final ImmutableRoot rootWithoutCircumflexes = new ImmutableRoot(new TurkishSequence(underlyingRootChars), lexeme, rootWithCircumflexes.getPhoneticAttributes(), rootWithCircumflexes.getPhoneticExpectations()); roots.add(rootWithoutCircumflexes); } return roots; } }  @Override HashSet<ImmutableRoot> generate(Lexeme lexeme); }
CircumflexConvertingRootGenerator extends ImmutableRootGenerator { @Override public HashSet<ImmutableRoot> generate(Lexeme lexeme) { final HashSet<ImmutableRoot> rootsWithCircumflexes = super.generate(lexeme); final char[] lemmaRootChars = lexeme.getLemmaRoot().toCharArray(); LinkedList<Integer> circumflexed_A_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_I_indices = new LinkedList<Integer>(); LinkedList<Integer> circumflexed_U_indices = new LinkedList<Integer>(); boolean hasCircumflex = false; for (int i = 0; i < lemmaRootChars.length; i++) { char lemmaRootChar = lemmaRootChars[i]; if (lemmaRootChar == CIRCUMFLEX_A) { circumflexed_A_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_I) { circumflexed_I_indices.add(i); hasCircumflex = true; } else if (lemmaRootChar == CIRCUMFLEX_U) { circumflexed_U_indices.add(i); hasCircumflex = true; } } if (!hasCircumflex) { return rootsWithCircumflexes; } else { final HashSet<ImmutableRoot> roots = new HashSet<ImmutableRoot>(); roots.addAll(rootsWithCircumflexes); for (ImmutableRoot rootWithCircumflexes : rootsWithCircumflexes) { final TurkishChar[] underlyingRootChars = rootWithCircumflexes.getSequence().getChars(); for (Integer circumflexed_A_index : circumflexed_A_indices) { underlyingRootChars[circumflexed_A_index] = new TurkishChar(PLAIN_A, TurkishAlphabet.L_a); } for (Integer circumflexed_I_index : circumflexed_I_indices) { underlyingRootChars[circumflexed_I_index] = new TurkishChar(PLAIN_I, TurkishAlphabet.L_i); } for (Integer circumflexed_U_index : circumflexed_U_indices) { underlyingRootChars[circumflexed_U_index] = new TurkishChar(PLAIN_U, TurkishAlphabet.L_u); } final ImmutableRoot rootWithoutCircumflexes = new ImmutableRoot(new TurkishSequence(underlyingRootChars), lexeme, rootWithCircumflexes.getPhoneticAttributes(), rootWithCircumflexes.getPhoneticExpectations()); roots.add(rootWithoutCircumflexes); } return roots; } }  @Override HashSet<ImmutableRoot> generate(Lexeme lexeme);  }