public TagCloudNode GetCommentTreeString(children children)
        {
            Dictionary <string, int> topNWordsRoot = children.GetTopNWordsDictionary(10);
            TagCloudNode             tgnRoot       = new TagCloudNode();

            tgnRoot.id   = children.id;
            tgnRoot.key  = children.key;
            tgnRoot.text = children.text;
            bool   isOP     = author == children.author;
            string citePre  = isOP ? "<cite class='op'>" : "<cite>";
            string citePost = ":</cite>";

            tgnRoot.title = citePre + children.author + citePost + children.text;
            GetTagCloudFromDictionary(topNWordsRoot);
            tgnRoot.children  = new List <TagCloudNode>();
            children.Children = children.Children.OrderByDescending(x => x.created_at).ToList();
            foreach (children child in children.Children)
            {
                if (!string.IsNullOrWhiteSpace(child.SubtreeText))
                {
                    TagCloudNode tgnChild = GetCommentTreeString(child);
                    tgnRoot.children.Add(tgnChild);
                }
            }
            return(tgnRoot);
        }
        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));
        }
Exemple #3
0
        public async Task <object> GetCommentTreeForId(string idTuple)
        {
            string       sStoryId = idTuple.Split(':')[1];
            string       sNodeId  = idTuple.Split(':')[0];
            int          storyid  = Convert.ToInt32(sStoryId);
            int          nodeid   = Convert.ToInt32(sNodeId);
            FullStory    fs       = FullStoryFactory.GetFullStory(storyid);
            children     child    = fs.GetNodeById(nodeid);
            TagCloudNode tgn      = fs.GetCommentTreeString(child);

            return(JsonConvert.SerializeObject(tgn));
        }
        public TagCloudNode GetTagCloudTreeString(children children)
        {
            Dictionary <string, int> topNWordsRoot = children.GetTopNWordsDictionary(10);
            string       topNWords = GetTagCloudFromDictionary(topNWordsRoot);
            TagCloudNode tgnRoot   = new TagCloudNode();

            tgnRoot.id    = children.id;
            tgnRoot.key   = children.key;
            tgnRoot.text  = topNWords;
            tgnRoot.title = topNWords;

            tgnRoot.children  = new List <TagCloudNode>();
            children.Children = children.Children.OrderByDescending(x => x.created_at).ToList();
            foreach (children child in children.Children)
            {
                if (!string.IsNullOrWhiteSpace(child.SubtreeText))
                {
                    TagCloudNode tgnChild = GetTagCloudTreeString(child);
                    tgnRoot.children.Add(tgnChild);
                }
            }
            return(tgnRoot);
        }
        public string GetTagCloudTreeString()
        {
            FullStory fs = this;
            Dictionary<string, int> topNWordsRoot = fs.GetTopNWordsDictionary(10);
            TagCloudNode tgnRoot = new TagCloudNode();
            string topNWords = GetTagCloudFromDictionary(topNWordsRoot);
            tgnRoot.id = fs.id;
            tgnRoot.key = fs.id;
            tgnRoot.text = topNWords;
            tgnRoot.title = topNWords;

            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 = GetTagCloudTreeString(child);
                    tgnRoot.children.Add(tgnChild);
                }
            }
            return JsonConvert.SerializeObject(tgnRoot);
        }
        public TagCloudNode GetTagCloudTreeString(children children)
        {
            Dictionary<string, int> topNWordsRoot = children.GetTopNWordsDictionary(10);
            string topNWords = GetTagCloudFromDictionary(topNWordsRoot);
            TagCloudNode tgnRoot = new TagCloudNode();
            tgnRoot.id = children.id;
            tgnRoot.key = children.key;
            tgnRoot.text = topNWords;
            tgnRoot.title = topNWords;

            tgnRoot.children = new List<TagCloudNode>();
            children.Children = children.Children.OrderByDescending(x => x.created_at).ToList();
            foreach (children child in children.Children)
            {
                if (!string.IsNullOrWhiteSpace(child.SubtreeText))
                {
                    TagCloudNode tgnChild = GetTagCloudTreeString(child);
                    tgnRoot.children.Add(tgnChild);
                }
            }
            return tgnRoot;
        }
 public TagCloudNode GetCommentTreeString(children children)
 {
     Dictionary<string, int> topNWordsRoot = children.GetTopNWordsDictionary(10);
     TagCloudNode tgnRoot = new TagCloudNode();
     tgnRoot.id = children.id;
     tgnRoot.key = children.key;
     tgnRoot.text = children.text;
     bool isOP = author == children.author;
     string citePre = isOP ? "<cite class='op'>" : "<cite>";
     string citePost = ":</cite>";
     tgnRoot.title = citePre+children.author+ citePost+children.text;
     GetTagCloudFromDictionary(topNWordsRoot);
     tgnRoot.children = new List<TagCloudNode>();
     children.Children = children.Children.OrderByDescending(x => x.created_at).ToList();
     foreach (children child in children.Children)
     {
         if (!string.IsNullOrWhiteSpace(child.SubtreeText))
         {
             TagCloudNode tgnChild = GetCommentTreeString(child);
             tgnRoot.children.Add(tgnChild);
         }
     }
     return tgnRoot;
 }