コード例 #1
0
        internal IEnumerable <IWordCloud> GetPlayerWordCloud(string playerId)
        {
            HtmlNode wordCloudNode = mainController.HtmlDocumentController.GetYaspWordCloudRoot(playerId);

            var result = Regex.Split(wordCloudNode.InnerHtml, "\r\n|\r|\n").ToList();

            string wordCountString = result.SingleOrDefault(r => r.Contains("var my_counts"));

            wordCountString = wordCountString.Remove(0, 16);
            wordCountString = wordCountString.Remove(wordCountString.Length - 1, 1);

            JsonController jsonController = new JsonController();
            dynamic        wordCount      = jsonController.ReadFromString(wordCountString);

            Dictionary <string, object> wordCountDictionary = wordCount.ToObject <Dictionary <string, object> >();

            List <IWordCloud> wordCountList = new List <IWordCloud>();

            foreach (string key in wordCountDictionary.Keys)
            {
                wordCountList.Add(new WordCloud()
                {
                    Word = key, Count = int.Parse(wordCountDictionary[key].ToString())
                });
            }

            return(wordCountList.OrderByDescending(w => w.Count).ThenBy(w => w.Word));
        }
コード例 #2
0
        internal DotabuffMappingController(JsonPaths jsonPaths)
        {
            JsonController jsonReader = new JsonController();
            GistClient     gistClient = new GistClient();


            var gistFiles = gistClient.GetGist("ebaba232180a83083cd1d9a2d7db65da");

            //dotabuffXPaths = jsonReader.ReadFromFile(jsonPaths.XPathsUri);
            dotabuffXPaths = jsonReader.ReadFromString(gistFiles["XPaths"].Content);


            //dotabuffQueryStrings = jsonReader.ReadFromFile(jsonPaths.QueryStringsUri);
            dotabuffQueryStrings = jsonReader.ReadFromString(gistFiles["QueryStrings"].Content);

            //dotabuffEnums = jsonReader.ReadFromFile(jsonPaths.EnumsUri);
            dotabuffEnums = jsonReader.ReadFromString(gistFiles["Enums"].Content);

            //dotabuffSelectors = jsonReader.ReadFromFile(jsonPaths.SelectorsUri);
            dotabuffSelectors = jsonReader.ReadFromString(gistFiles["Selectors"].Content);

            //dotabuffHtmlAttributes = jsonReader.ReadFromFile(jsonPaths.HtmlAttributesUri);
            dotabuffHtmlAttributes = jsonReader.ReadFromString(gistFiles["HtmlAttributes"].Content);

            //dotabuffUrls = jsonReader.ReadFromFile(jsonPaths.UrlsUri);
            dotabuffUrls = jsonReader.ReadFromString(gistFiles["Urls"].Content);
        }
コード例 #3
0
        internal IEnumerable<IWordCloud> GetPlayerWordCloud(string playerId)
        {
            HtmlNode wordCloudNode = mainController.HtmlDocumentController.GetYaspWordCloudRoot(playerId);

            var result = Regex.Split(wordCloudNode.InnerHtml, "\r\n|\r|\n").ToList();

            string wordCountString = result.SingleOrDefault(r => r.Contains("var my_counts"));
            wordCountString = wordCountString.Remove(0, 16);
            wordCountString = wordCountString.Remove(wordCountString.Length - 1, 1);

            JsonController jsonController = new JsonController();
            dynamic wordCount = jsonController.ReadFromString(wordCountString);

            Dictionary<string, object> wordCountDictionary = wordCount.ToObject<Dictionary<string, object>>();

            List<IWordCloud> wordCountList = new List<IWordCloud>();
            foreach (string key in wordCountDictionary.Keys)
            {
                wordCountList.Add(new WordCloud() { Word = key, Count = int.Parse(wordCountDictionary[key].ToString()) });
            }

            return wordCountList.OrderByDescending(w => w.Count).ThenBy(w => w.Word);
        }