private void _processColon(SentenceElement colon, List<SentenceElement> elementList)
 {
     var mainEnumerationWord = elementList.Find(x => x.Order == colon.Order - 1);
     if (mainEnumerationWord != null)
     {
         log.InfoFormat("Enumeration main word is {0}", mainEnumerationWord.Text);
         var fisrtChildWord = elementList.Find(x => x.SyntacticParentWordId == mainEnumerationWord.Id);
         if (fisrtChildWord != null)
         {
             log.InfoFormat("First child in enumeration is {0}", fisrtChildWord.Text);
             if (_isCommaReplacementNeeded(mainEnumerationWord, fisrtChildWord, elementList))
             {
                 log.Info("Replacing colon...");
                 colon.Text = COLON_REPLACEMENT;
             }
             else
             {
                 log.Info("Deleting colon...");
                 colon.Text = "";
             }
         }
         else
         {
             log.Info("Child enumeration word not found. No action.");
         }
     }
     else
     {
         log.Info("Main Enumeration word not found. Replacing colon...");
         colon.Text = COLON_REPLACEMENT;
     }
 }
        private bool _isCommaReplacementNeeded(SentenceElement mainEnumerationWord, SentenceElement firstChildWord, List<SentenceElement> elementList)
        {
            if (mainEnumerationWord.GrammarInfo.PartOfSpeech.Value == GrammarInfoPartOfSpeech.Noun.Value &&
                firstChildWord.GrammarInfo.PartOfSpeech.Value == GrammarInfoPartOfSpeech.Participle.Value)
            {
                log.Debug("APR2. Noun + Participle");
                return true;
            }
            else if (mainEnumerationWord.GrammarInfo.PartOfSpeech.Value == GrammarInfoPartOfSpeech.Verb.Value &&
                firstChildWord.GrammarInfo.PartOfSpeech.Value == GrammarInfoPartOfSpeech.Participle.Value)
            {
                log.Debug("APR2. Verb + D-Participle");
                return true;
            }
            else if (mainEnumerationWord.GrammarInfo.PartOfSpeech.Value == GrammarInfoPartOfSpeech.Noun.Value &&
                firstChildWord.GrammarInfo.PartOfSpeech.Value == GrammarInfoPartOfSpeech.Noun.Value)
            {
                if (mainEnumerationWord.GrammarInfo.Case == firstChildWord.GrammarInfo.Case &&
                    elementList.Find(x => (x.SyntacticParentWordId == firstChildWord.Id && x.GrammarInfo.PartOfSpeech.Value == GrammarInfoPartOfSpeech.Preposition.Value)) != null)
                {
                    log.Debug("APR2. Noun X + Noun X with Prep");
                    return true;
                }
            }

            return false;
        }
 private void _processPredicate(SentenceElement predicateElement, List<SentenceElement> elementList)
 {
     if (predicateElement.Lemma != "")
     {
         log.InfoFormat("Changing text for predicate {0} to {1}", predicateElement.Text, predicateElement.Lemma);
         predicateElement.Text = predicateElement.Lemma;
         log.InfoFormat("Adding word {0} before predicate", predicateElement.Text, predicateElement.Lemma);
         predicateElement.Text = ONE_CAN_WORD + " " + predicateElement.Text;
         log.InfoFormat("Final predicate text is '{0}'", predicateElement.Text);
     }
     else
         log.WarnFormat("Lemma not found for predicate {0}", predicateElement.Text);
 }
Example #4
0
 public void CopyFromSourceWord(SentenceElement sourceWord)
 {
     Id = sourceWord.Id;
     Position = sourceWord.Position;
     Order = sourceWord.Order;
     Text = sourceWord.Text;
     SyntacticRole = sourceWord.SyntacticRole;
     IsRestored = sourceWord.IsRestored;
     SyntacticParentWordId = sourceWord.SyntacticParentWordId;
     ChildWordsIds = sourceWord.ChildWordsIds.DeepCopy();
     ChainWordsIds = sourceWord.ChainWordsIds.DeepCopy();
     SemanticInfo = sourceWord.SemanticInfo;
     ControllerNodes = sourceWord.ControllerNodes;
     ConjuctedWithId = sourceWord.ConjuctedWithId;
     GrammarInfo = sourceWord.GrammarInfo;
 }