本文整理汇总了C#中Tuple.Take方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.Take方法的具体用法?C# Tuple.Take怎么用?C# Tuple.Take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple.Take方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LearnAndApply
public void LearnAndApply(
ICollection<string> seedPaths, Tuple<string, string>[] learningSets,
LearningExperiment[] experiments) {
var projectPaths =
learningSets.Take(ProjectCount).Select(
t => {
var url = t.Item1;
var path = Fixture.GetGitRepositoryPath(url);
Git.Clone(path, url);
Git.Checkout(path, t.Item2);
return path;
}).ToList();
var failedCount = 0;
foreach (var exp in experiments) {
var learningResult = LearnWithoutClearing(
seedPaths, exp, projectPaths.Take(ProjectCountToLearn).ToList());
var w = CreateWriter(exp.GetType().Name + "_classifier_" +
ProjectCountToLearn + "_" + ProjectCount + ".txt");
w.WriteLine(learningResult.Classifier.GetClassifierSummary());
w.Flush();
var writer = CreateWriter(exp.GetType().Name + "_apply_" +
ProjectCountToLearn + "_" + ProjectCount + ".csv");
foreach (var projectPath in projectPaths.Skip(ProjectCountToLearn)) {
var codePaths = Directory.GetFiles(projectPath, SearchPattern,
SearchOption.AllDirectories);
writer.Write(DateTime.Now);
writer.Write(",");
writer.Write(projectPath);
writer.Write(",");
var classificationResult = exp.Apply(codePaths, SearchPattern,
learningResult.FeatureEncoder,
learningResult.Classifier, writer);
var features =
learningResult.Classifier.GetAllAcceptingFeatureStrings(
learningResult.FeatureEncoder);
writer.Write(classificationResult.WrongElementCount);
writer.Write(",");
writer.Write(classificationResult.WrongVectorCount);
writer.Write(",");
writer.WriteLine();
writer.Flush();
if (classificationResult.WrongElementCount > 0) {
failedCount++;
PrintWrongResults(classificationResult, learningResult);
}
Console.WriteLine(exp.GetType().Name);
Assert.That(failedCount, Is.EqualTo(0));
}
}
}
示例2: Match
public static double Match(List<Minutia> minutiae1, List<Minutia> minutiae2)
{
var tasks =
new Tuple<Minutia, Minutia, Minutia, Minutia>[6000];
var sw = new Stopwatch();
sw.Start();
double max = 0;
int count = -1;
Parallel.ForEach(minutiae1, new ParallelOptions() {MaxDegreeOfParallelism = 4},
core1 =>
{
foreach (var to1 in minutiae1)
{
if (core1 == to1) continue;
var angle1 = DetermineAngle(core1, to1);
var length1 = DetermineDistance(core1, to1);
foreach (var core2 in minutiae2)
{
var others2 = minutiae2.Except(new List<Minutia>() {core2});
foreach (var to2 in others2)
{
if (core2 == to2) continue;
var angle2 = DetermineAngle(core2, to2);
if (Math.Abs(angle1 - angle2) > AngleToleranceBox)
continue;
var length2 = DetermineDistance(core2, to2);
if (Math.Abs(length1 - length2) > DistanceToleranceBox) continue;
int localCount = Interlocked.Increment(ref count);
tasks[localCount] = Tuple.Create(core1, to1, core2, to2);
}
}
}
});
object _lock = new object();
Parallel.ForEach(tasks.Take(count), new ParallelOptions() {MaxDegreeOfParallelism = 4},
x =>
{
var angle1 = DetermineAngle(x.Item1, x.Item2);
var angle2 = DetermineAngle(x.Item3, x.Item4);
var score = TranslateAndMatch(minutiae1, x.Item1, minutiae2, x.Item3, angle2 - angle1);
lock(_lock)
{
if (score > max) max = score;
}
});
sw.Stop();
return max;
}