Exemplo n.º 1
0
import sys
import pymongo

from models import Poem

chunk_index = int(sys.argv[1])
n_chunks = int(sys.argv[2])

limit, skip = utils.get_limit_and_skip(chunk_index, n_chunks)

db = pymongo.MongoClient().poetry

for index, document in enumerate(db.poems.find().limit(limit).skip(skip)):
    
    print 'process %i of %i, document %i of %i (_id: %s)' % \
        (chunk_index + 1, n_chunks, index, limit, document['_id'])

    poem = Poem(document, db)
    poem.set_rhymes()


    
Exemplo n.º 2
0
import sys
import pymongo
from models import Poem
import pprint
import utils
import pronouncing

print(pronouncing.rhymes('a'))
print(pronouncing.rhymes('the'))
raise 'STOp'

db = pymongo.MongoClient().poetry

document = db.poems.find_one({'_id': '10'})
poem = Poem(document, db)

pprint.pprint(poem.get_rhymes())
poem.set_rhymes()
Exemplo n.º 3
0
def do_batch(id_list):
    collection = pymongo.MongoClient().poetry.poems
    for _id in id_list:
        document = collection.find_one({'_id': _id})
        poem = Poem(document, collection)
        poem.set_rhymes()