Skip to content

Commit

Permalink
Basic testing script
Browse files Browse the repository at this point in the history
  • Loading branch information
chromakode committed Feb 6, 2009
1 parent 5f1db90 commit ca76702
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/redditron.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from couchdb.client import Server, Database, ResourceConflict

from markov import Chain
from utils import set_line

def build_chain(db):
c = Chain(N=20)

comment_count = len(db)
for index, comment_id in enumerate(db):
body = db[comment_id]['body']
c.train(body)
set_line('Loaded %s/%s comments...' % (index+1, comment_count))
set_line('')

return c

def main():
couch_uri = 'http://localhost:5984/'
db_name = 'redditron-comments'

server = Server(couch_uri)
db = server[db_name]

c = build_chain(db)
for i in range(0, 100):
print "---"
print c.generate_text()
print "---"

if __name__ == '__main__':
main()

0 comments on commit ca76702

Please sign in to comment.