Пример #1
0
        public string GetCommentTreeString()
        {
            FullStory fs = this;
            Dictionary <string, int> topNWordsRoot = fs.GetTopNWordsDictionary(10);
            TagCloudNode             tgnRoot       = new TagCloudNode();

            tgnRoot.id    = fs.id;
            tgnRoot.key   = fs.id;
            tgnRoot.text  = fs.title;
            tgnRoot.title = fs.title;
            GetTagCloudFromDictionary(topNWordsRoot);
            tgnRoot.children = new List <TagCloudNode>();
            //sort like HN
            //fs.children =
            //    fs.children.OrderByDescending(x => (x.score - 1)/Math.Pow((DateTime.Now.Subtract(x.created_at).TotalHours+2),1.5))
            //        .ToList();
            fs.children = fs.children.OrderByDescending(x => x.created_at).ToList();
            foreach (children child in fs.children)
            {
                if (!string.IsNullOrWhiteSpace(child.SubtreeText))
                {
                    TagCloudNode tgnChild = GetCommentTreeString(child);
                    tgnRoot.children.Add(tgnChild);
                }
            }
            return(JsonConvert.SerializeObject(tgnRoot));
        }
Пример #2
0
        public async Task <object> GetStoryTopNWords(int storyid)
        {
            FullStory fs = FullStoryFactory.GetFullStory(storyid);
            Dictionary <string, int> topNWords = fs.GetTopNWordsDictionary(10);
            List <WordObj>           wordObjs  = topNWords.ToList().Select(x => new WordObj()
            {
                Word = x.Key, Count = x.Value
            }).ToList();

            return(wordObjs);
        }