Kaynağa Gözat

Algo alternatif pour trouver les oublis

Squelette de l'algo
feature/findHolesV2
Figg 8 ay önce
ebeveyn
işleme
6e6e958a73
2 değiştirilmiş dosya ile 46 ekleme ve 0 silme
  1. 30
    0
      million/analyze/find_holes.py
  2. 16
    0
      scripts/find_holesV2.py

+ 30
- 0
million/analyze/find_holes.py Dosyayı Görüntüle

@@ -71,3 +71,33 @@ def find_holes(messages: List[Message], accepted_max: int = 1_000_000) -> List[H
71 71
                 end_message=sequence.start_message
72 72
             ))
73 73
     return holes
74
+
75
+def find_holesV2(messages: List[Message]) -> List[Hole]:
76
+    current = 1
77
+    msg_idx = 0
78
+    threshold = 1000
79
+
80
+    result = []
81
+
82
+    while True:
83
+        msgCurrent = next((m for m in messages if m.get_counted_value() == current), None)
84
+        if msgCurrent:
85
+            if len(result) > 0 and result[-1].end < 1:
86
+                result[-1].end = current-1
87
+                result[-1].end_message = msgCurrent
88
+
89
+            messages.remove(msgCurrent)
90
+            current += 1
91
+        else:
92
+            if len(result) == 0 or result[-1].end > 0:
93
+                hole = Hole(
94
+                    start = current,
95
+                    end = 0,
96
+                    start_message = Message(sender_name='',timestamp_ms=0),
97
+                    end_message = Message(sender_name='',timestamp_ms=0)
98
+                    )
99
+                result.append(hole)
100
+            elif current - result[-1].start > threshold:
101
+                break
102
+            
103
+    return result

+ 16
- 0
scripts/find_holesV2.py Dosyayı Görüntüle

@@ -0,0 +1,16 @@
1
+from million.analyze.find_holes import find_holesV2
2
+from million.analyze.retain_counts import retain_counts
3
+from million.parse.fb_exports import FacebookExportParser
4
+
5
+
6
+DATA_PATH = './data/'
7
+parser = FacebookExportParser()
8
+
9
+export = parser.parse(DATA_PATH)
10
+filtered = retain_counts(export.messages)
11
+
12
+holes = find_holesV2(filtered)
13
+
14
+for hole in holes:
15
+    print(f"{hole.start} - {hole.end} ({hole.end - hole.start})")
16
+    print(hole.end_message)

Loading…
İptal
Kaydet