浏览代码

formatage plus sympa

pull/3/head
Figg 10 个月前
父节点
当前提交
42062e1dcf
共有 1 个文件被更改,包括 14 次插入4 次删除
  1. 14
    4
      scripts/find_gromots.py

+ 14
- 4
scripts/find_gromots.py 查看文件

@@ -1,4 +1,4 @@
1
-
1
+from datetime import datetime
2 2
 from million.analyze.wordFinder import findWords
3 3
 from million.parse.fb_exports import FacebookExportParser
4 4
 
@@ -10,8 +10,18 @@ parser = FacebookExportParser()
10 10
 export = parser.parse(DATA_PATH)
11 11
 
12 12
 gros_mots = ['merde', 'sexe', 'pute', 'putain', 'bite', 'nichon', 'con(ne)?', 'baiser?']
13
+msg_gros_mots = findWords(export.messages, gros_mots)
14
+
15
+msg_gros_mots_grp = {}
16
+
17
+for msg in msg_gros_mots:
18
+    if msg.sender_name not in msg_gros_mots_grp: msg_gros_mots_grp[msg.sender_name] = []
19
+    msg_gros_mots_grp[msg.sender_name].append(msg)
13 20
 
14
-msg_gromots = findWords(export.messages, gros_mots)
21
+for name in msg_gros_mots_grp:
22
+    print(name)
15 23
 
16
-for gromot in msg_gromots:
17
-    print(f"{gromot.sender_name} : {gromot.content}")
24
+    for msg in msg_gros_mots_grp[name]:
25
+        time = datetime.fromtimestamp(msg.timestamp_ms / 1000)
26
+        time_str = time.strftime("%d/%m/%Y %H:%M:%S")
27
+        print(f"\t{time_str} : {msg.content}")

正在加载...
取消
保存