private void btnCheck_Click(object sender, EventArgs e) { if (m_lemmatizer == null || !m_lemmatizer.IsInitialized || !(m_lemmatizer is StreamLemmatizer)) { m_lemmatizer = new HebMorph.StreamLemmatizer(new System.IO.StringReader(txbCheck.Text)); string hspellPath = SelectHSpellFolderPath(); if (hspellPath == null) return; m_lemmatizer.InitFromHSpellFolder(hspellPath, true, false); } else { (m_lemmatizer as StreamLemmatizer).SetStream(new System.IO.StringReader(txbCheck.Text)); } string word = string.Empty; List<Token> tokens = new List<Token>(); while ((m_lemmatizer as StreamLemmatizer).LemmatizeNextToken(out word, tokens) > 0) { if (tokens.Count == 0) { LoggerWriteLine("{0}: Unrecognized word{1}{2}", word, Environment.NewLine, "------"); continue; } if (tokens.Count == 1 && !(tokens[0] is HebrewToken)) { LoggerWriteLine("{0}: Not a Hebrew word; detected as {1}{2}{3}", word, tokens[0].IsNumeric ? "Numeric" : "NonHebrew", Environment.NewLine, "------"); continue; } int curPrefix = -1; string curWord = string.Empty; foreach (Token r in tokens) { HebrewToken ht = r as HebrewToken; if (ht == null) continue; if (curPrefix != ht.PrefixLength || !curWord.Equals(ht.Text)) { curPrefix = ht.PrefixLength; curWord = ht.Text; if (curPrefix == 0) LoggerWriteLine("Legal word: {0} (score: {1})", ht.Text, ht.Score); else { LoggerWriteLine("Legal combination: {0}+{1} (score: {2})", ht.Text.Substring(0, curPrefix), ht.Text.Substring(curPrefix), ht.Score); } } LoggerWriteLine(ht.ToString()); } LoggerWriteLine("------"); } }