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


C# SortedSet.Skip方法代码示例

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


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

示例1: NameAnalysis

        public void NameAnalysis()
        {
            Logger.Log("Analyzing names", Logger.TabChange.Increase);

            var nodeNames = NodeNameGrouper.NodeNames();

            Logger.Log("Longest name is " + nodeNames.Max(n => n.Key.Length) + " characters long");

            var alphabet = nodeNames.Keys.SelectMany(s => s.AsEnumerable()).Distinct().OrderBy(c => c);

            Logger.Log(alphabet.Count() + " characters in alphabet \"" + alphabet.Aggregate(string.Empty, (s, c) => s + c) + "\"");

            var reducedAlphabet = nodeNames.Keys.SelectMany(s => s.ToLower().Where(c => 'a' <= c && c <= 'z')).Distinct().OrderBy(c => c);

            Logger.Log(reducedAlphabet.Count() + " characters in alphabet \"" + reducedAlphabet.Aggregate(string.Empty, (s, c) => s + c) + "\"");

            var commonWords = EveryName
                    .SelectMany(n => n.Replace(",", "").Replace(".", "").Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(na => na.Trim().ToUpper()))
                    .GroupBy(n => n).OrderByDescending(g => g.Count()).Take(25).Select(g => g.Key + " " + g.Count()).ToArray();
            Logger.Log(commonWords.Length + " most common words: " + commonWords.Aggregate("", (c, s) => c + "," + s).Remove(0, 1));

            {
                var names = new SortedSet<string>[16];

                names[0] = new SortedSet<string>();
                foreach (var line in InputData.Paths.Select(l => l.Split('|')))
                {
                    foreach (var name in line)
                    {
                        names[0].Add(name.Trim());
                    }
                }

                foreach (int i in Enumerable.Range(0, InputData.TrainingSets.Length))
                {
                    names[i + 1] = new SortedSet<string>();

                    foreach (var line in InputData.TrainingSets[i].Select(l => l.Split('|')))
                    {
                        names[i + 1].Add(line[0].Trim());
                        names[i + 1].Add(line[1].Trim());
                    }
                }

                Logger.Log("The unique names in each set are: " + names.Skip(1).Aggregate("paths " + names[0].Count, (c, s) => c + ", " + s.Count));

                Logger.Log("Train 1 and 2 have " + names[1].Intersect(names[2]).Count() + " names in common");

                var trainingCommonNames = names.Skip(2).Aggregate(new SortedSet<string>(names[1]), (s, c) => { s.IntersectWith(c); return s; });

                Logger.Log("The training sets have " + trainingCommonNames.Count + " names in common");

                Logger.Log("The training and path sets have " + trainingCommonNames.Intersect(names[0]).Count() + " names in common");
            }

            Logger.Log("Names analyzed", Logger.TabChange.Decrease);
        }
开发者ID:charvey,项目名称:facebook-mti,代码行数:57,代码来源:Analyzer.cs


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