protected void ReconstructWordformsMappings(string WordformsFileName) { if (File.Exists(WordformsFileName)) { StreamReader reader = new StreamReader(WordformsFileName); string Buffer; WordformsVariant.Clear(); WordformsValues.Clear(); while ((Buffer = reader.ReadLine()) != null) { int i_DelimiterIndex = Buffer.IndexOf(" - "); if (i_DelimiterIndex == -1) { // Wordforms index corrupted - no delimiter found continue; } string Lexeme = Buffer.Substring(0, i_DelimiterIndex); Buffer = Buffer.Substring(i_DelimiterIndex + 3); string[] Wordforms = Buffer.Split('|'); ArrayList FormsForLexeme = new ArrayList(); for (int i = 0; i < Wordforms.Length; i++) { // Forbid adding the same wordform twice - this can // happen e.g. as the result of corruption or other // internal bugs. string wordform = Wordforms[i]; if (FormsForLexeme.IndexOf(wordform) == -1) { FormsForLexeme.Add(wordform); WordformsVariant[wordform] = FormsForLexeme.Count; } } WordformsValues[Lexeme] = FormsForLexeme; } reader.Close(); } }
public int StoreMapping(string wordform, string lexeme) { Debug.Assert(!WordformsVariant.Contains(wordform)); int derivationVariant; ArrayList forms; HashMap.Entry e = WordformsValues.GetEntry(lexeme); if (e != null) { forms = (ArrayList)e.Value; } else { forms = new ArrayList(); WordformsValues[lexeme] = forms; } forms.Add(wordform); WordformsVariant[wordform] = derivationVariant = forms.Count; WordformsChanged = true; return(derivationVariant); }
public int GetWordformVariant(string token) { HashMap.Entry e = WordformsVariant.GetEntry(token); return((e != null) ? (int)e.Value : -1); }