Skip to content

Instantly share code, notes, and snippets.

@stfsy
Created January 9, 2021 21:22
Show Gist options
  • Save stfsy/9171233b115c346167f910073a931d42 to your computer and use it in GitHub Desktop.
Save stfsy/9171233b115c346167f910073a931d42 to your computer and use it in GitHub Desktop.
import pymongo
mongoClient = pymongo.MongoClient(
"mongodb://localhost:27017/", username="removed", password="removed")
mongoDatabase = mongoClient["twitter"]
mongoCollection = mongoDatabase["tweets"]
def fetch_next_tweet_without_classification():
result = list(mongoCollection.aggregate([
{
'$project': {
'id': True, 'text': True, 'classification': True, 'lang': True
}
},
{
'$match': {"classification": None}
},
{
'$match': {"lang": {
'$eq': 'en'
}}
},
{
'$limit': 1
}
]))
return result[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment