本文整理汇总了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)
{
//.........这里部分代码省略.........