Example #1
0
 /**
  * creates a duplicate WordElement from an existing WordElement
  *
  * @param currentWord
  *            - An existing WordElement
  */
 public WordElement(WordElement currentWord) : base()
 {
     baseForm    = currentWord.BaseForm;
     Category    = currentWord.Category;
     id          = currentWord.Id;
     inflVars    = currentWord.InflectionalVariants;
     defaultInfl = currentWord.getDefaultInflectionalVariant();
     Features    = currentWord;
 }
Example #2
0
        /**
         * Constructs a new inflected word from a WordElement
         *
         * @param word
         *            underlying wordelement
         */
        public InflectedWordElement(WordElement word) : base()
        {
            setFeature(InternalFeature.BASE_WORD, word);
            // AG: changed to use the default spelling variant
            // setFeature(LexicalFeature.BASE_FORM, word.getBaseForm());
            string defaultSpelling = word.DefaultSpellingVariant;

            setFeature(LexicalFeature.BASE_FORM, defaultSpelling);
            Category = word.Category;
        }
Example #3
0
        /**
         * Check if this WordElement is equal to an object.
         *
         * @param o
         *            the object
         * @return <code>true</code> iff the object is a word element with the same
         *         id and the same baseform and the same features.
         *
         */
        public override bool Equals(object o)
        {
            if (o is WordElement)
            {
                WordElement we = (WordElement)o;

                return((ReferenceEquals(baseForm, we.baseForm) || baseForm.Equals(we.baseForm)) && (ReferenceEquals(id, we.id) || id.Equals(we.id)) && we.features.Equals(features));
            }

            return(false);
        }
Example #4
0
        /**
         * A helper method to look up the lexicon for the given word.
         *
         * @param category
         *            the <code>LexicalCategory</code> of the word.
         * @param word
         *            the base form of the word.
         * @param wordElement
         *            the created element representing the word.
         */
        private void doLexiconLookUp(LexicalCategory category, string word, NLGElement wordElement)
        {
            WordElement baseWord = null;

            if (category.GetLexicalCategory() == LexicalCategory.LexicalCategoryEnum.NOUN && lexicon.hasWord(word, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN)))
            {
                baseWord = lexicon.lookupWord(word, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN));

                if (baseWord != null)
                {
                    wordElement.setFeature(InternalFeature.BASE_WORD, baseWord);
                    wordElement.Category = new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN);
                    if (!PRONOUNS.Contains(word))
                    {
                        wordElement.setFeature(InternalFeature.NON_MORPH, true);
                    }
                }
            }
            else
            {
                baseWord = lexicon.lookupWord(word, category);
                wordElement.setFeature(InternalFeature.BASE_WORD, baseWord);
            }
        }
Example #5
0
 internal InflectionSet(WordElement outerInstance, Inflection infl)
 {
     this.outerInstance = outerInstance;
     this.infl          = infl;
     forms = new Dictionary <string, string>();
 }