当前位置: 首页>>代码示例>>C#>>正文


C# Sentence.addWord方法代码示例

本文整理汇总了C#中Sentence.addWord方法的典型用法代码示例。如果您正苦于以下问题:C# Sentence.addWord方法的具体用法?C# Sentence.addWord怎么用?C# Sentence.addWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentence的用法示例。


在下文中一共展示了Sentence.addWord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: addWordsToSentence

 private static void addWordsToSentence(string sentenceString, Sentence sentence)
 {
     Word current;
     string word = null;
     string[] words = sentenceString.Split('\n');
     for (int i = 0; i < words.Length; i++)
     {
         if (words[i] == "")
         {
             break;
         }
         else
         {
             word = words[i];
             current = getWord(word);
             sentence.addWord(current);
         }
     }
 }
开发者ID:yassersouri,项目名称:Corpus-Builder,代码行数:19,代码来源:ArticleUtils.cs

示例2: generateNewArticle


//.........这里部分代码省略.........
                        VerbInSentence lastVerbInTheSentence = currentSentenceVBS.VerbsInSentence.Last();
                        BaseStructure emptyBaseStructure = new BaseStructure();
                        SelectedKVP = new KeyValuePair<VerbInSentence,BaseStructure>(lastVerbInTheSentence, emptyBaseStructure);
                        nothingPicked = false;
                    }
                }

                if(!nothingPicked)
                    SelectedKVP.Value.FitIntoBaseStructure(ref currentSentenceVBS, SelectedKVP.Key);

                //word index pointer in the current sentence
                int wordIndexInCurrentSentence = 0;

                Word currentWord = null;
                Word newWord = null;
                DependencyBasedToken currentDBT;

                #region upgrading the current sentence to a new sentence.
                for(int word_index = 0; word_index < list.Count() ; word_index++)
                {
                    currentDBT = list[word_index];

                    newWord = new Word();

                    newWord.num = currentDBT.Position;
                    newWord.lexeme = currentDBT.WordForm;
                    if(currentDBT.Lemma != "_")
                    {
                        //if lemma is changed
                        newWord.lemma = currentDBT.Lemma;
                        newWord.cpos = currentDBT.CPOSTag;
                        newWord.fpos = currentDBT.FPOSTag;

                        if(currentDBT.MorphoSyntacticFeats.Person != ShakhsType.Shakhs_NONE)
                            newWord.person = currentDBT.MorphoSyntacticFeats.Person.ToString();
                        else
                            newWord.person = "_";

                        if(currentDBT.MorphoSyntacticFeats.Number != NumberType.INVALID)
                            newWord.number = currentDBT.MorphoSyntacticFeats.Number.ToString();
                        else
                            newWord.number = "_";

                        if(currentDBT.MorphoSyntacticFeats.TenseMoodAspect != TenseFormationType.TenseFormationType_NONE)
                            newWord.tma = currentDBT.MorphoSyntacticFeats.TenseMoodAspect.ToString();
                        else
                            newWord.tma = "_";
                    }
                    else{
                        //lemma is unchanged
                        currentWord = currentSentence.getWord(wordIndexInCurrentSentence);

                        newWord.lemma = currentWord.lemma;
                        newWord.cpos = currentWord.cpos;
                        newWord.fpos = currentWord.fpos;
                        newWord.person = currentWord.person;
                        newWord.number = currentWord.number;
                        newWord.tma = "_";
                    }

                    //are changed any way
                    newWord.parentId = currentDBT.HeadNumber;
                    newWord.parentRelation = currentDBT.DependencyRelation;

                    newSentence.addWord(newWord);
                    wordIndexInCurrentSentence += currentDBT.TokenCount;
                }
                //sentence is now upgraded and more filled with information
                #endregion

                //adding the fitted base structure to the database as the main verb
                //add the selectedKVP's Verb to database
                //mongoSaveMainVerb();

                ////////////////////////
                //// Counting the Verbs
                ////    -----------

                List<VerbInSentence> verbsInSentence = currentSentenceVBS.VerbsInSentence;
                for(int verb_index = 0; verb_index < verbsInSentence.Count ; verb_index++)
                {
                    string verbStringRepresentation = getVerbStringRepresentation(verbsInSentence[verb_index], newSentence);
                    long article = currentArticle.getArticleNumber();
                    //sentence_index is already set
                    //verb_index is already set

                    if (verbStringRepresentation.Equals("شوند~_~_"))
                    {
                        mongoCountVerb(verbStringRepresentation, article, sentence_index, verb_index);
                    }
                    mongoCountVerb(verbStringRepresentation, article, sentence_index, verb_index);
                }

                ////
                ////////////////////////
                newArticle.addSentence(newSentence);
            }

            return newArticle;
        }
开发者ID:yassersouri,项目名称:Corpus-Builder,代码行数:101,代码来源:Program.cs


注:本文中的Sentence.addWord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。