'Return a model of links and comments in a given subreddit.'

def model_subreddit(self, subreddit_name):

    subreddit_path = '/r/{}'.format(subreddit_name)
    print '>>>', subreddit_path
    print '>>    Links'
    titles = TextGenerator(order=5)
    selfposts = TextGenerator(order=8)
    link_count = self_count = 0
    urls = set()
    for link in fetch_listing(subreddit_path, limit=500):
        self.usernames.add_sample(link['author'])
        titles.add_sample(unescape_htmlentities(link['title']))
        if link['is_self']:
            self_count += 1
            selfposts.add_sample(unescape_htmlentities(link['selftext']))
        else:
            urls.add(link['url'])
        link_count += 1
    self_frequency = (self_count / link_count)
    print '>>    Comments'
    comments = TextGenerator(order=8)
    for comment in fetch_listing((subreddit_path + '/comments')):
        self.usernames.add_sample(comment['author'])
        comments.add_sample(unescape_htmlentities(comment['body']))
    return SubredditModel(subreddit_name, titles, selfposts, urls, comments, self_frequency)
