Browse Source

Ajout de commentaires

pull/5/head
Figg 6 months ago
parent
commit
6600ccb799

+ 13
- 0
million/analyze/find_holes.py View File

7
 
7
 
8
 
8
 
9
 def compute_sequences(messages: List[Message], accepted_max: int = 1_000_000) -> List[Sequence]:
9
 def compute_sequences(messages: List[Message], accepted_max: int = 1_000_000) -> List[Sequence]:
10
+    """ 
11
+    Takes a list of messages as input and returns a list of sequences
12
+    for every following messages with following 'counted values'
13
+    """
10
     sequences: List[Sequence] = [Sequence(start_message=messages[0])]
14
     sequences: List[Sequence] = [Sequence(start_message=messages[0])]
11
     
15
     
12
     for message in messages[1:]:
16
     for message in messages[1:]:
21
 
25
 
22
 
26
 
23
 def merge_duplicates(sequences: List[Sequence]) -> List[Sequence]:
27
 def merge_duplicates(sequences: List[Sequence]) -> List[Sequence]:
28
+    """ 
29
+    Take sequences as an input and returns a list with every
30
+    overlapping input sequences merged in one
31
+    """
24
     o_sequences = sorted(sequences, key= lambda s : s.start())
32
     o_sequences = sorted(sequences, key= lambda s : s.start())
25
     current = o_sequences[0]
33
     current = o_sequences[0]
26
 
34
 
38
 
46
 
39
 
47
 
40
 def invert_sequences(sequences: List[Sequence]) -> List[Sequence]:
48
 def invert_sequences(sequences: List[Sequence]) -> List[Sequence]:
49
+    """ 
50
+    Returns the sequences representing the spaces between
51
+    the ones given as input
52
+    """
41
     result = []
53
     result = []
42
 
54
 
43
     for previous, current in zip(sequences[:-1],sequences[1:]):
55
     for previous, current in zip(sequences[:-1],sequences[1:]):
51
 def find_holes(messages: List[Message], accepted_max: int = 1_000_000) -> List[Sequence]:
63
 def find_holes(messages: List[Message], accepted_max: int = 1_000_000) -> List[Sequence]:
52
     """
64
     """
53
     Find the holes in the conversation
65
     Find the holes in the conversation
66
+    TODO might need to be moved inside scripts/find_holes
54
     """
67
     """
55
     sequences = compute_sequences(messages, accepted_max)
68
     sequences = compute_sequences(messages, accepted_max)
56
     merged = merge_duplicates(sequences)
69
     merged = merge_duplicates(sequences)

+ 2
- 1
million/analyze/message_evaluation.py View File

21
     return value
21
     return value
22
 
22
 
23
 def get(msg: Message) -> int:
23
 def get(msg: Message) -> int:
24
-    """ Returns the estimated value counted in this message
24
+    """
25
+    Returns the estimated value counted in this message
25
     """
26
     """
26
     return memoization.get(msg, __compute__(msg))
27
     return memoization.get(msg, __compute__(msg))

+ 15
- 0
million/parse/fb_exports.py View File

6
 
6
 
7
 
7
 
8
 def is_file_valid(file_name: str) -> bool:
8
 def is_file_valid(file_name: str) -> bool:
9
+    """ 
10
+    Check if this file can be parsed into a FacebookExport
11
+    (Actually only check if its a json file atm)
12
+    """
9
     # NOTE is there a way to peek inside a json file to
13
     # NOTE is there a way to peek inside a json file to
10
     # check its internal structure ?
14
     # check its internal structure ?
11
     return os.path.splitext(file_name)[-1].lower() == '.json'
15
     return os.path.splitext(file_name)[-1].lower() == '.json'
12
 
16
 
13
 def valid_dirfiles(file_dir: str) -> List[str]:
17
 def valid_dirfiles(file_dir: str) -> List[str]:
18
+    """ 
19
+    Returns a list of parsable files contained
20
+    in this directory
21
+    """
14
     return [os.path.join(file_dir, file_name)
22
     return [os.path.join(file_dir, file_name)
15
             for file_name in os.listdir(file_dir)
23
             for file_name in os.listdir(file_dir)
16
             if is_file_valid(file_name)]
24
             if is_file_valid(file_name)]
17
 
25
 
18
 def parse_file(file_name: str) -> FacebookExport:
26
 def parse_file(file_name: str) -> FacebookExport:
27
+    """ 
28
+    Parses a single parsable file into a FacebookExport Object
29
+    """
19
     if not is_file_valid(file_name): return None
30
     if not is_file_valid(file_name): return None
20
 
31
 
21
     with open(file_name, 'rb') as f:
32
     with open(file_name, 'rb') as f:
23
         return FacebookExport.model_validate_json(json_data)
34
         return FacebookExport.model_validate_json(json_data)
24
 
35
 
25
 def parse_dirfiles(file_dir: str) -> FacebookExport:
36
 def parse_dirfiles(file_dir: str) -> FacebookExport:
37
+    """ 
38
+    Parses every parsable files inside this directory
39
+    into a single FacebookExport Object
40
+    """
26
     exports = [parse_file(f) for f in valid_dirfiles(file_dir)]
41
     exports = [parse_file(f) for f in valid_dirfiles(file_dir)]
27
     
42
     
28
     result = exports[0]
43
     result = exports[0]

Loading…
Cancel
Save