/** * add word to internal indices * * @param word */ private void IndexWord(WordElement word) { // first index by base form var basef = word.getBaseForm(); // shouldn't really need is, as all words have base forms if (basef != null) { updateIndex(word, basef, indexByBase); } // now index by ID, which should be unique (if present) var id = word.getId(); if (id != null) { if (indexByID.ContainsKey(id)) { Console.WriteLine($"Lexicon error: ID {id} occurs more than once"); } indexByID.Add(id, word); } // now index by variant foreach (var variant in getVariants(word)) { updateIndex(word, variant, indexByVariant); } // done }
/** * creates a duplicate WordElement from an existing WordElement * * @param currentWord * - An existing WordElement */ public WordElement(WordElement currentWord) { baseForm = currentWord.getBaseForm(); setCategory(currentWord.getCategory()); id = currentWord.getId(); inflVars = currentWord.getInflectionalVariants(); defaultInfl = (Inflection)currentWord.getDefaultInflectionalVariant(); setFeatures(currentWord); }