本文整理汇总了C#中Sentence.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# Sentence.SelectMany方法的具体用法?C# Sentence.SelectMany怎么用?C# Sentence.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentence
的用法示例。
在下文中一共展示了Sentence.SelectMany方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Split
public void Split(string name, double minAccuracy, Sentence[] train, Sentence[] test)
{
Assert.Greater(train.Length, 0);
Assert.Greater(test.Length, 0);
Assert.Greater(train.Length, test.Length);
LuMiiTagger tagger = new LuMiiTagger();
Stopwatch trainTimer = new Stopwatch();
trainTimer.Start();
tagger.Train(train);
trainTimer.Stop();
Stopwatch tagTimer = new Stopwatch();
tagTimer.Start();
tagger.Tag(test);
tagTimer.Stop();
Token[] tokens = test.SelectMany(t => t).ToArray();
double accuracyTag = (double)tokens.Count(t => t.IsTagCorrect) / tokens.Count();
double accuracyMsd = (double)tokens.Count(t => t.IsMsdCorrect) / tokens.Count();
double accuracyMsdLemma = (double)tokens.Count(t => t.IsMsdCorrect && t.IsLemmaCorrect) / tokens.Count();
double accuracyLemma = (double)tokens.Count(t => t.IsLemmaCorrect) / tokens.Count();
Token[] lemmaIncorrect = tokens.Where(t => t.IsMsdCorrect && !t.IsLemmaCorrect).ToArray();
Debug.WriteLine("Split validation for " + name);
Debug.WriteLine("Train: {0} sentences, {1} tokens", train.Length, train.SelectMany(t => t).Count());
Debug.WriteLine("Test: {0} sentences, {1} tokens", test.Length, test.SelectMany(t => t).Count());
Debug.WriteLine("Accuracy tag: {0:0.00}%", accuracyTag * 100);
Debug.WriteLine("Accuracy msd: {0:0.00}%", accuracyMsd * 100);
Debug.WriteLine("Accuracy msd + lemma: {0:0.00}%", accuracyMsdLemma * 100);
Debug.WriteLine("Accuracy lemma: {0:0.00}%", accuracyLemma * 100);
Debug.WriteLine("Train duration: {0} or {1:0} ms", trainTimer.Elapsed, trainTimer.ElapsedMilliseconds);
Debug.WriteLine("Tag duration: {0} or {1:0} ms", tagTimer.Elapsed, tagTimer.ElapsedMilliseconds);
Debug.WriteLine("Tag speed: {0:0.00} tokens/s", tokens.Length / tagTimer.Elapsed.TotalSeconds);
Assert.Greater(accuracyMsdLemma, minAccuracy);
Assert.Less(accuracyMsdLemma, 0.97);
}