/** * 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); }
/** * make a WordElement from a lexical record. Currently just specifies basic * params and inflections Should do more in the future! * * @param record * @return */ private WordElement makeWord(LexRecord record) { // get basic data string baseForm = record.GetBase(); ILexicalCategory category = getSimplenlgCategory(record); string id = record.GetEui(); // create word class var wordElement = new WordElement(baseForm, (LexicalCategory)category, id); // now add type information switch (category.lexType) { case LexicalCategoryEnum.ADJECTIVE: addAdjectiveInfo(wordElement, record.GetCatEntry().GetAdjEntry()); break; case LexicalCategoryEnum.ADVERB: addAdverbInfo(wordElement, record.GetCatEntry().GetAdvEntry()); break; case LexicalCategoryEnum.NOUN: addNounInfo(wordElement, record.GetCatEntry().GetNounEntry()); break; case LexicalCategoryEnum.VERB: addVerbInfo(wordElement, record.GetCatEntry().GetVerbEntry()); break; // ignore closed class words } var defaultInfl = (Inflection)wordElement .getDefaultInflectionalVariant(); // now add inflected forms // if (keepStandardInflections || !standardInflections(record, // category)) { foreach (InflVar inflection in record.GetInflVarsAndAgreements() .GetInflValues()) { string simplenlgInflection = getSimplenlgInflection(inflection .GetInflection()); if (simplenlgInflection != null) { string inflectedForm = inflection.GetVar(); Inflection inflType = Inflection.getInflCode(inflection .GetType()); // store all inflectional variants, except for regular ones // unless explicitly set if (inflType != null && !(Inflection.REGULAR.Equals(inflType) && !this.keepStandardInflections)) { wordElement.addInflectionalVariant(inflType, simplenlgInflection, inflectedForm); } // if the infl variant is the default, also set this feature on // the word if (defaultInfl == null || (defaultInfl.Equals(inflType) && !(Inflection.REGULAR .Equals(inflType) && !this.keepStandardInflections))) { wordElement.setFeature(simplenlgInflection, inflectedForm); } // wordElement // .setFeature(simplenlgInflection, inflection.GetVar()); } } // } // add acronym info addAcronymInfo(wordElement, record); // now add spelling variants addSpellingVariants(wordElement, record); return(wordElement); }