Lurker News

Comments (163) 64 threads

Show all comments

Showing thread 39 of 64

Kinnard1 reply#
I'm confused. What is this?
detaro2 replies#
An automated parody of HN, OP explains above: https://news.ycombinator.com/item?id=10248803

> I've pulled every comment and story from HN through the API and make a bunch of Markov chains to produce story titles and comments.

Kinnard5 replies#
I see. Cool. I'm building an HN clone now. Hierarchical comments are a fun challenge. Any tips?

Continue this thread — 1 reply

Kenji1 reply#
Yeah. If you store them in a relational database you will grow a couple of grey hairs because you're essentially forcing a tree structure into a table structure. The concepts clash and it's kind of a pain, but possible since every post has 1 unique parent, so you can make upwards references and rebuild a tree from that.
martin-adams5 replies#
A great technique I've used for many years to store hierarchical data is by using a Nested Set Model (https://en.wikipedia.org/wiki/Nested_set_model)

It works a treat as you can query the whole tree in one SQL statement but preserve the nesting for formatting.

Continue this thread — 5 replies

Kinnard#
Hmmm, toooo many options. How do I decide between them. Sort of a DB noob.
krapp#
A simple method (a modified adjacency list) I've used just stores the root id, parent id and id of each post together. You can get the entire tree from any root post easily (everything shares the same root id) but getting the whole subtree beyond immediate children takes recursion.

I find that you don't even have to worry about treating the data as a tree in most cases until the very end. What you want to actually deal with is a flat array with the ids (root,parent,id) arranged in rendering order, and to have the tree built in the HTML. The data set from the DB doesn't even have to represent the tree structure directly, as long as you can sort it elsewhere.
You can even have two arrays - one (say, an associative array) with the data, and another basic array with the ids. Sort just the array with the ids, then use those as keys to iterate the data array when building the html, so you can avoid ever having to sort the larger array (which as luck has it just happens to be optimized for non-linear access anyway.)
I should probably mention, I thought this was terribly clever when I did it in PHP, before I was aware that all arrays in PHP are basically the same, so it was mostly pointless overoptimization.
Building something like an unordered list in HTML from that array then becomes a matter of adding or removing

    elements based on the relative change in depth for each subsequent id. Depth is easy to find by checking if an item's parent is (or isn't) the same as the id of the previous element. The actual tree never exists in code until the unordered list is rendered in the browser.

    Also here's a good reference on Stack Overflow of different methods to do the same thing: https://stackoverflow.com/questions/2175882/how-to-represent...
    If you actually know what you're doing beforehand, probably ignore everything I just said and go with nested sets. My method is, admittedly, naive and better programmers are probably chuckling at it over the beverage of their choice, but it does work and it seems to be decently fast.

tajen4 replies#
Does that mean that there is no deep learning here, only statistics and randomization?
minimaxir#
Nothing wrong with statistics and randomization. :)
6502nerdface#
Markov chains do learn in the sense that they model distributions of strings, can be trained on observed strings and used to generate strings, assign probabilities to strings, classify strings, etc. They have well developed treatments in multiple frameworks of computational learning theory, including Gold learnability and PAC learnability.

Is "deep learning" more than statistics and randomization?

jacques_chester1 reply#
> Does that mean that there is no deep learning here, only statistics and randomization?

Correct. It is a perfect simulation of HN.

Continue this thread — 1 reply

gwern4 replies#
There isn't, but I don't think it should be difficult to feed this into 'char-rnn' if you wanted to do it with RNNs rather than Markov chains. The interface, such as it is, to char-rnn is very simple; you dump everything into a text file 'input.txt'.

Continue this thread — 4 replies