@Test public void shouldCreateLexemesFromLines() { String lines = "a [P:Interj]\n" + "aba [P:Adj]\n" + "abadî\n" + "abat [P:Adj; A:NoVoicing]\n" + "abdest [A:NoVoicing]\n" + "abes [P:Adj]\n" + "abes [P:Adv]\n" + "ablak [P:Adj; A:NoVoicing]\n" + "abuk [P:Adj, Dup;A:NoVoicing, NoSuffix]\n" + "acemborusu [A:CompoundP3sg; R:acemboru]\n" + "acembuselik\n" + "aciz [A:LastVowelDrop]\n" + "âciz [P:Adj]\n" + "açık [P:Adj]\n" + "# comment \n" + " \n" + "ad\n" + "ad [P:Noun; A:Doubling, InverseHarmony]\n" + "addetmek [A:Voicing, Aorist_A]\n" + "addolmak [A:Causative_dIr]\n" + "ahlat [A:NoVoicing, Plural]\n" + "akşam [P:Noun, Time]\n" + "atamak [A:Causative_It]\n" + "sürtmek\n" + "yemek [P:Noun]\n" + "yemek [A:Causative_dIr]\n" + "ürkmek [A:Causative_It]"; final int lineCount = 25; final Set<Lexeme> lexemes = loader.createLexemesFromLines(Splitter.on(CharMatcher.anyOf("\n\r")).split(lines)); assertThat(lexemes, hasSize(lineCount)); assertThat(lexemes, hasItem(new ImmutableLexeme("a", "a", PrimaryPos.Interjection, null, null))); assertThat(lexemes, hasItem(new ImmutableLexeme("aba", "aba", PrimaryPos.Adjective, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("abadî", "abadî", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("abat", "abat", PrimaryPos.Adjective, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("abdest", "abdest", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("abes", "abes", PrimaryPos.Adjective, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("abes", "abes", PrimaryPos.Adverb, null, null))); assertThat(lexemes, hasItem(new ImmutableLexeme("ablak", "ablak", PrimaryPos.Adjective, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("abuk", "abuk", PrimaryPos.Adjective, SecondaryPos.Duplicator, ImmutableSet.of(LexemeAttribute.NoSuffix, LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("acemborusu", "acemboru", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.CompoundP3sg, LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("acembuselik", "acembuselik", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.Voicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("aciz", "aciz", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.LastVowelDrop, LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("âciz", "âciz", PrimaryPos.Adjective, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("açık", "açık", PrimaryPos.Adjective, null, ImmutableSet.of(LexemeAttribute.Voicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("ad", "ad", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("ad", "ad", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.Doubling, LexemeAttribute.InverseHarmony, LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("addetmek", "addet", PrimaryPos.Verb, null, ImmutableSet.of(LexemeAttribute.Aorist_A, LexemeAttribute.Causative_dIr, LexemeAttribute.Voicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("addolmak", "addol", PrimaryPos.Verb, null, ImmutableSet.of(LexemeAttribute.Aorist_I, LexemeAttribute.Causative_dIr, LexemeAttribute.NoVoicing, LexemeAttribute.Passive_In)))); assertThat(lexemes, hasItem(new ImmutableLexeme("ahlat", "ahlat", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.NoVoicing, LexemeAttribute.Plural)))); assertThat(lexemes, hasItem(new ImmutableLexeme("akşam", "akşam", PrimaryPos.Noun, SecondaryPos.Time, ImmutableSet.of(LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("atamak", "ata", PrimaryPos.Verb, null, ImmutableSet.of(LexemeAttribute.Aorist_I, LexemeAttribute.Causative_It, LexemeAttribute.NoVoicing, LexemeAttribute.Passive_In, LexemeAttribute.ProgressiveVowelDrop)))); assertThat(lexemes, hasItem(new ImmutableLexeme("sürtmek", "sürt", PrimaryPos.Verb, null, ImmutableSet.of(LexemeAttribute.Aorist_A, LexemeAttribute.Causative_Ir, LexemeAttribute.NoVoicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("yemek", "yemek", PrimaryPos.Noun, null, ImmutableSet.of(LexemeAttribute.Voicing)))); assertThat(lexemes, hasItem(new ImmutableLexeme("yemek", "ye", PrimaryPos.Verb, null, ImmutableSet.of(LexemeAttribute.Aorist_A, LexemeAttribute.Causative_dIr, LexemeAttribute.NoVoicing, LexemeAttribute.Passive_In, LexemeAttribute.ProgressiveVowelDrop)))); assertThat(lexemes, hasItem(new ImmutableLexeme("ürkmek", "ürk", PrimaryPos.Verb, null, ImmutableSet.of(LexemeAttribute.Aorist_A, LexemeAttribute.Causative_It, LexemeAttribute.NoVoicing)))); }
HashSet<Lexeme> createLexemesFromLines(Iterable<String> lines) { final LexemeCreator loader = new LexemeCreator(); final Iterable<Lexeme> lexemes = Iterables.transform(lines, new Function<String, Lexeme>() { @Override public Lexeme apply(String input) { if (StringUtils.isBlank(input)) return null; input = input.trim(); if (input.startsWith(COMMENT_SYMBOL)) return null; return loader.createLexemeFromLine(input); } }); return Sets.newHashSet(Iterables.filter(lexemes, Predicates.notNull())); }
DictionaryLoader { HashSet<Lexeme> createLexemesFromLines(Iterable<String> lines) { final LexemeCreator loader = new LexemeCreator(); final Iterable<Lexeme> lexemes = Iterables.transform(lines, new Function<String, Lexeme>() { @Override public Lexeme apply(String input) { if (StringUtils.isBlank(input)) return null; input = input.trim(); if (input.startsWith(COMMENT_SYMBOL)) return null; return loader.createLexemeFromLine(input); } }); return Sets.newHashSet(Iterables.filter(lexemes, Predicates.notNull())); } }
DictionaryLoader { HashSet<Lexeme> createLexemesFromLines(Iterable<String> lines) { final LexemeCreator loader = new LexemeCreator(); final Iterable<Lexeme> lexemes = Iterables.transform(lines, new Function<String, Lexeme>() { @Override public Lexeme apply(String input) { if (StringUtils.isBlank(input)) return null; input = input.trim(); if (input.startsWith(COMMENT_SYMBOL)) return null; return loader.createLexemeFromLine(input); } }); return Sets.newHashSet(Iterables.filter(lexemes, Predicates.notNull())); }  }
DictionaryLoader { HashSet<Lexeme> createLexemesFromLines(Iterable<String> lines) { final LexemeCreator loader = new LexemeCreator(); final Iterable<Lexeme> lexemes = Iterables.transform(lines, new Function<String, Lexeme>() { @Override public Lexeme apply(String input) { if (StringUtils.isBlank(input)) return null; input = input.trim(); if (input.startsWith(COMMENT_SYMBOL)) return null; return loader.createLexemeFromLine(input); } }); return Sets.newHashSet(Iterables.filter(lexemes, Predicates.notNull())); }  static HashSet<Lexeme> loadDefaultMasterDictionary(); static HashSet<Lexeme> loadDefaultNumeralMasterDictionary(); HashSet<Lexeme> load(CharSource charSource); }
DictionaryLoader { HashSet<Lexeme> createLexemesFromLines(Iterable<String> lines) { final LexemeCreator loader = new LexemeCreator(); final Iterable<Lexeme> lexemes = Iterables.transform(lines, new Function<String, Lexeme>() { @Override public Lexeme apply(String input) { if (StringUtils.isBlank(input)) return null; input = input.trim(); if (input.startsWith(COMMENT_SYMBOL)) return null; return loader.createLexemeFromLine(input); } }); return Sets.newHashSet(Iterables.filter(lexemes, Predicates.notNull())); }  static HashSet<Lexeme> loadDefaultMasterDictionary(); static HashSet<Lexeme> loadDefaultNumeralMasterDictionary(); HashSet<Lexeme> load(CharSource charSource);  }