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


C# Article.getSentence方法代码示例

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


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

示例1: generateNewArticle

        private static Article generateNewArticle(Article currentArticle, string verbDicPath)
        {
            Article newArticle = new Article();

            Sentence currentSentence = null;
            Sentence newSentence = null;
            String[] currentLexemes = null;
            String[] currentPOSTags = null;
            String[] currentLemmas = null;
            MorphoSyntacticFeatures[] currentFeatures = null;

            //generating new Sentence
            for(int sentence_index = 0; sentence_index < currentArticle.getSentences().Length; sentence_index++) //for each sentence in this article.
            {
                //initialize the new sentence
                newSentence = new Sentence();

                //load the current sentence
                currentSentence = currentArticle.getSentence(sentence_index);

                //load info about that sentence
                currentLexemes = currentSentence.getLexemes();
                currentPOSTags = currentSentence.getPOSTags();
                currentLemmas = currentSentence.getLemmas();
                currentFeatures = currentSentence.getFeatures();

                VerbBasedSentence currentSentenceVBS = SentenceAnalyzer.MakeVerbBasedSentence(currentLexemes, currentPOSTags, currentLemmas, currentFeatures, verbDicPath);
                List<DependencyBasedToken> list = currentSentenceVBS.SentenceTokens;
                Random randomNumberGenerator = new Random();
                Dictionary<VerbInSentence, BaseStructure> pickedBasedStructures = new Dictionary<VerbInSentence,BaseStructure>();

                //for each verb in sentence
                foreach(var currentVerbInSentence in currentSentenceVBS.VerbsInSentence)
                {
                    bool noSatisfiedBaseStructureExists = false;

                    List<BaseStructure> satisfiedBaseStructuresOfCurrentVerb = new List<BaseStructure>();
                    //special string representation of the verb
                    String currentVerbString = ValencyDicManager.GetVerbString(ref currentSentenceVBS, currentVerbInSentence);
                    if (ValencyDicManager.BaseStrucDic.ContainsKey(currentVerbString))
                    {
                        List<BaseStructure> baseStructuresForTheCurrentVerb = ValencyDicManager.BaseStrucDic[currentVerbString];
                        foreach (var currentBaseStructure in baseStructuresForTheCurrentVerb)
                        {
                            if(currentBaseStructure.Satisfy(currentSentenceVBS, currentVerbInSentence))
                            {
                                satisfiedBaseStructuresOfCurrentVerb.Add(currentBaseStructure);
                            }
                        }
                    }

                    if(satisfiedBaseStructuresOfCurrentVerb.Count == 0) noSatisfiedBaseStructureExists = true;

                    List<BaseStructure> candidateBaseStructuresOfCurrentVerb;

                    #region select one base structure of this verb

                    bool finishedChoosingPickedBaseStructure = false;

                    //no need to choose because nothing is there
                    if (noSatisfiedBaseStructureExists) finishedChoosingPickedBaseStructure = true;
                    #region HasPrepositionalObject2
                    candidateBaseStructuresOfCurrentVerb = new List<BaseStructure>();

                    if(!finishedChoosingPickedBaseStructure)
                    {
                        foreach (var currentSatisfiedBaseStructure in satisfiedBaseStructuresOfCurrentVerb)
                        {
                            if(currentSatisfiedBaseStructure.HasPrepositionalObject2)
                                candidateBaseStructuresOfCurrentVerb.Add(currentSatisfiedBaseStructure);
                        }
                        if(candidateBaseStructuresOfCurrentVerb.Count > 1)
                        {
                            int randomIndex = randomNumberGenerator.Next(0, candidateBaseStructuresOfCurrentVerb.Count);
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[randomIndex]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if(candidateBaseStructuresOfCurrentVerb.Count == 1)
                        {
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[0]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if(candidateBaseStructuresOfCurrentVerb.Count == 0)
                        {
                            finishedChoosingPickedBaseStructure = false;
                        }
                        else
                        {
                            throw new Exception("Error in picking BaseStructures for Verbs");
                        }
                    }
                    #endregion

                    #region HasPrepositionalObject1
                    candidateBaseStructuresOfCurrentVerb = new List<BaseStructure>();

                    if (!finishedChoosingPickedBaseStructure)
                    {
                        foreach (var currentSatisfiedBaseStructure in satisfiedBaseStructuresOfCurrentVerb)
                        {
//.........这里部分代码省略.........
开发者ID:yassersouri,项目名称:Corpus-Builder,代码行数:101,代码来源:Program.cs


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