You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

find_gromots.py 950B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from datetime import datetime
  2. from million.analyze.wordFinder import findWords
  3. from million.parse.fb_exports import FacebookExportParser
  4. DATA_PATH = './data/'
  5. parser = FacebookExportParser()
  6. export = parser.parse(DATA_PATH)
  7. gros_mots = [
  8. '.*merde.*',
  9. 'sexe',
  10. 'pute',
  11. 'pé?dé?',
  12. 'putain',
  13. 'bite',
  14. 'encul.*',
  15. 'cul',
  16. 'nichon',
  17. 'con(ne)?',
  18. 'bais.*'
  19. ]
  20. msg_gros_mots = findWords(export.messages, gros_mots)
  21. msg_gros_mots_grp = {}
  22. for msg in msg_gros_mots:
  23. if msg.sender_name not in msg_gros_mots_grp: msg_gros_mots_grp[msg.sender_name] = []
  24. msg_gros_mots_grp[msg.sender_name].append(msg)
  25. for name in sorted(msg_gros_mots_grp, key = lambda k: len(msg_gros_mots_grp[k])):
  26. print(name)
  27. for msg in msg_gros_mots_grp[name]:
  28. time = datetime.fromtimestamp(msg.timestamp_ms / 1000)
  29. time_str = time.strftime("%d/%m/%Y %H:%M:%S")
  30. print(f"\t{time_str} : {msg.content}")