|
@@ -1,7 +1,6 @@
|
1
|
1
|
|
2
|
2
|
|
3
|
3
|
from typing import List
|
4
|
|
-from million.model.hole import Hole
|
5
|
4
|
from million.model.message import Message
|
6
|
5
|
from million.model.sequence import Sequence
|
7
|
6
|
import million.analyze.message_evaluation as msg_val
|
|
@@ -20,7 +19,6 @@ def compute_sequences(messages: List[Message], accepted_max: int = 1_000_000) ->
|
20
|
19
|
sequences.append(current)
|
21
|
20
|
current = Sequence(start_message=message)
|
22
|
21
|
|
23
|
|
- # order the sequences by start
|
24
|
22
|
sequences.sort(key=lambda s: s.start())
|
25
|
23
|
|
26
|
24
|
merged_sequences: List[Sequence] = []
|
|
@@ -33,24 +31,20 @@ def compute_sequences(messages: List[Message], accepted_max: int = 1_000_000) ->
|
33
|
31
|
merged_sequences.append(previous)
|
34
|
32
|
previous = sequence
|
35
|
33
|
|
36
|
|
- # Having merged the sequences once, any sequence having start = end can be removed
|
37
|
34
|
return [s for s in merged_sequences if s.length() > 1]
|
38
|
35
|
|
39
|
36
|
|
40
|
|
-def find_holes(messages: List[Message], accepted_max: int = 1_000_000) -> List[Hole]:
|
|
37
|
+def find_holes(messages: List[Message], accepted_max: int = 1_000_000) -> List[Sequence]:
|
41
|
38
|
"""
|
42
|
39
|
Find the holes in the conversation
|
43
|
40
|
"""
|
44
|
|
- merged_sequences = compute_sequences(messages, accepted_max)
|
|
41
|
+ sequences = compute_sequences(messages, accepted_max)
|
45
|
42
|
holes = []
|
46
|
|
- for i in range(1, len(merged_sequences)):
|
47
|
|
- previous_sequence = merged_sequences[i - 1]
|
48
|
|
- sequence = merged_sequences[i]
|
49
|
|
- if sequence.start() - previous_sequence.end() > 1:
|
50
|
|
- holes.append(Hole(
|
51
|
|
- start=previous_sequence.end(),
|
52
|
|
- end=sequence.start(),
|
53
|
|
- start_message=previous_sequence.end_message,
|
54
|
|
- end_message=sequence.start_message
|
55
|
|
- ))
|
|
43
|
+
|
|
44
|
+ for previous, current in zip(sequences[:-1],sequences[1:]):
|
|
45
|
+ holes.append(Sequence(
|
|
46
|
+ start_message=previous.end_message,
|
|
47
|
+ end_message=current.start_message
|
|
48
|
+ ))
|
|
49
|
+
|
56
|
50
|
return holes
|