コード例 #1
0
        /**
         * Return those features related to a word's inflection, depending on its
         * category, that is, the constants for
         * <code>PAST, PAST_PARTICIPLE, PLURAl, PRESENT_PARTICIPLE, PRESENT3S, COMPARATIVE</code>
         * or <code>SUPERLATIVE</code>.
         *
         * @param cat
         *            the category
         * @return the inflectional feature names
         */

        public static string[] getInflectionalFeatures(IElementCategory cat)
        {
            if (cat is IPhraseCategory)
            {
                if (cat.enumType == (int)PhraseCategoryEnum.NOUN_PHRASE)
                {
                    return new string[] { PLURAL }
                }
                ;

                if (cat.enumType == (int)PhraseCategoryEnum.VERB_PHRASE)
                {
                    return new string[]
                           {
                               PAST, PAST_PARTICIPLE, PRESENT_PARTICIPLE,
                               PRESENT3S
                           }
                }
                ;

                if (cat.enumType == (int)PhraseCategoryEnum.ADJECTIVE_PHRASE)
                {
                    return new string[]
                           {
                               COMPARATIVE, SUPERLATIVE
                           }
                }
                ;
            }
            else if (cat is ILexicalCategory)
            {
                if (cat.enumType == (int)LexicalCategoryEnum.NOUN)
                {
                    return new string[] { PLURAL }
                }
                ;

                if (cat.enumType == (int)LexicalCategoryEnum.VERB)
                {
                    return new string[]
                           {
                               PAST, PAST_PARTICIPLE, PRESENT_PARTICIPLE,
                               PRESENT3S
                           }
                }
                ;

                if (cat.enumType == (int)LexicalCategoryEnum.ADJECTIVE)
                {
                    return new string[]
                           {
                               COMPARATIVE, SUPERLATIVE
                           }
                }
                ;
            }
            return(null);
        }
    }
}
コード例 #2
0
        /**
         * <p>
         * Adds a collection of <code>NLGElements</code> to the list of child
         * components. If there are no existing child components, then a new list is
         * created.
         * </p>
         * <p>
         * As with <code>addComponents(...)</code> only legitimate child types are
         * added to the list.
         * </p>
         *
         * @param textComponents
         *            the <code>List</code> of <code>NLGElement</code>s to be added.
         *            If this is <code>NULL</code> the method does nothing.
         */

        public void addComponents(List <INLGElement> textComponents)
        {
            if (textComponents != null)
            {
                var thisCategory          = this.getCategory();
                var elementsToAdd         = new List <INLGElement>();
                IElementCategory category = null;

                foreach (var eachElement in textComponents)
                {
                    category = ((INLGElement)eachElement).getCategory();
                    if (category != null && thisCategory is IDocumentCategory)
                    {
                        if (((IDocumentCategory)thisCategory).hasSubPart(category))
                        {
                            elementsToAdd.add((INLGElement)eachElement);
                            ((INLGElement)eachElement).setParent(this);
                        }
                    }
                }
                if (elementsToAdd.Count > 0)
                {
                    var components = getComponents();
                    if (components == null)
                    {
                        components = new List <INLGElement>();
                    }
                    components.AddRange(elementsToAdd);
                    this.setFeature(FEATURE_COMPONENTS, components);
                }
            }
        }
コード例 #3
0
 public FunctionalSet(DiscourseFunction _func, IElementCategory _category,
                      Periphery _periphery, List <INLGElement> _components)
 {
     function   = _func;
     category   = _category;
     periphery  = _periphery;
     components = _components;
 }
コード例 #4
0
        public static FunctionalSet newInstance(DiscourseFunction func,
                                                IElementCategory category,
                                                Periphery periphery,
                                                List <INLGElement> components)
        {
            FunctionalSet pair = null;

            if (components.Count >= 2)
            {
                pair = new FunctionalSet(func, category, periphery, components);
            }

            return(pair);
        }
コード例 #5
0
        public static bool hasSubPart(this IElementCategory sourceElementCategory, IElementCategory elementCategory)
        {
            var subPart = false;

            if (elementCategory != null)
            {
                if (elementCategory is IDocumentCategory)
                {
                    switch (sourceElementCategory.enumType)
                    {
                    case (int)DocumentCategoryEnum.DOCUMENT:
                        subPart = !(elementCategory.enumType == (int)DocumentCategoryEnum.DOCUMENT &&
                                    elementCategory.enumType == (int)DocumentCategoryEnum.LIST_ITEM);
                        break;

                    case (int)DocumentCategoryEnum.SECTION:
                        subPart = elementCategory.enumType == (int)DocumentCategoryEnum.PARAGRAPH ||
                                  elementCategory.enumType == (int)DocumentCategoryEnum.SECTION;
                        break;

                    case (int)DocumentCategoryEnum.PARAGRAPH:
                        subPart = elementCategory.enumType == (int)DocumentCategoryEnum.SENTENCE ||
                                  elementCategory.enumType == (int)DocumentCategoryEnum.LIST;
                        break;

                    case (int)DocumentCategoryEnum.LIST:
                        subPart = elementCategory.enumType == (int)DocumentCategoryEnum.LIST_ITEM;
                        break;

                    case (int)DocumentCategoryEnum.ENUMERATED_LIST:
                        subPart = elementCategory.enumType == (int)DocumentCategoryEnum.LIST_ITEM;
                        break;
                    }
                }
                else
                {
                    subPart = elementCategory.enumType == (int)DocumentCategoryEnum.SENTENCE ||
                              elementCategory.enumType == (int)DocumentCategoryEnum.LIST_ITEM;
                }
            }
            return(subPart);
        }
コード例 #6
0
        /**
         * Constructs a new inflected word using the giving word as the base form.
         * Constructing the word also requires a lexical category (such as noun,
         * verb).
         *
         * @param word
         *            the base form for this inflected word.
         * @param category
         *            the lexical category for the word.
         */

        public InflectedWordElement(string word, IElementCategory category)
        {
            setFeature(LexicalFeature.BASE_FORM, word);
            setCategory(category);
        }
コード例 #7
0
 /**
  * Sets the category of this element.
  *
  * @param newCategory
  *            the new <code>ElementCategory</code> for this element.
  */
 public virtual void setCategory(IElementCategory newCategory)
 {
     category = newCategory;
 }