Exemplo n.º 1
0
        private void AssignRoleFor(CoordinatedPhraseBuilder phrase)
        {
            switch (phrase.PhraseCategory)
            {
            case phraseCategory.ADJECTIVE_PHRASE:
                AddModifier(phrase);
                break;

            default:
                AddUnassignedChild(phrase);
                break;
            }
        }
        /// <summary>Transform this PrepositionalPhraseBuilder into a CoordinatedPhraseBuilder and return that CoordinatedPhraseBuilder.</summary>
        /// <remarks>The prepositional phrase's Complements do not get incorporated into the CoordinatedPhraseElement.  Instead, each of those elements
        /// must be applied to one of the coordinated elements.  This will change the syntactic structure of the tree, but while doing that we want to preserve the original
        /// word order.  To accomplish that we first create a series of dictionaries that temporarily store the various elements of the original (non-coordinated) phrase,
        /// along with the original order of those elements. <para>Then we add those elements into the CoordinatedPhraseBuilder, using the dictionaries to preserve
        /// ordering.</para></remarks>
        private protected sealed override CoordinatedPhraseBuilder AsCoordinatedPhrase()
        {
            Dictionary <PartOfSpeechBuilder, int> partsOfSpeech = GetPartsOfSpeechAndIndices();
            Dictionary <IElementTreeNode, int>    heads         = GetHeadsAndIndices();
            Dictionary <IElementTreeNode, int>    complements   = GetComplementsAndIndices();
            CoordinatedPhraseBuilder result = base.AsCoordinatedPhrase();

            foreach (IElementTreeNode eachComplement in complements.Keys)
            {
                eachComplement.DetachFromParent();
                eachComplement
                .Complete(ElementWithIndexNearest(complements[eachComplement], heads))
                ?.SetChildOrdering(eachComplement, partsOfSpeech);
            }
            ;
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>Transform this AdjectivePhraseBuilder into a CoordinatedPhraseBuilder and return that CoordinatedPhraseBuilder.</summary>
        /// <remarks>The adjective phrase's Modifiers do not get incorporated into the CoordinatedPhraseElement.  Instead, each of those elements
        /// must be applied to one of the coordinated elements.  This will change the syntactic structure of the tree, but while doing that we want to preserve the original
        /// word order.  To accomplish that we first create a series of dictionaries that temporarily store the various elements of the original (non-coordinated) phrase,
        /// along with the original order of those elements. <para>Then we add those elements into the CoordinatedPhraseBuilder, using the dictionaries to preserve
        /// ordering.</para></remarks>
        private protected sealed override CoordinatedPhraseBuilder AsCoordinatedPhrase()
        {
            Dictionary <PartOfSpeechBuilder, int> partsOfSpeech = GetPartsOfSpeechAndIndices();
            Dictionary <IElementTreeNode, int>    heads         = GetHeadsAndIndices();
            Dictionary <IElementTreeNode, int>    modifiers     = GetModifiersAndIndices();
            CoordinatedPhraseBuilder result = base.AsCoordinatedPhrase();

            foreach (IElementTreeNode eachModifier in modifiers.Keys)
            {
                eachModifier.DetachFromParent();
                eachModifier
                .Modify(ElementWithIndexNearest(modifiers[eachModifier], heads))
                ?.SetChildOrdering(eachModifier, partsOfSpeech);
            }
            ;
            return(result);
        }
        private void AssignRoleFor(CoordinatedPhraseBuilder phrase)
        {
            switch (phrase.PhraseCategory)
            {
            case phraseCategory.PREPOSITIONAL_PHRASE:
                AddHead(phrase);
                break;

            case phraseCategory.NOUN_PHRASE:
                AddComplement(phrase);
                break;

            case phraseCategory.VERB_PHRASE:
                AddComplement(phrase);
                break;

            default:
                AddUnassignedChild(phrase);
                break;
            }
        }