Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

utils.py 577 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  1. from googletrans import Translator
  2. def remove_duplicate_tweets(db):
  3. tweets = db.tweets.find()
  4. for tweet in tweets:
  5. duplicate = list(db.tweets.find({'id':tweet['id']}))
  6. if len(duplicate)>1:
  7. for duplicate in duplicate[1:]:
  8. db.tweets.delete_one(duplicate)
  9. print("{} has been deleted".format(duplicate['id']))
  10. def translate(input):
  11. try:
  12. translater = Translator()
  13. res = translater.translate(input, src='fr', dest='en')
  14. return res.text
  15. except:
  16. return None
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...