MCPcopy
hub / github.com/TheAlgorithms/Python / split

Method split

sorts/external_sort.py:26–41  ·  view source on GitHub ↗
(self, block_size, sort_key=None)

Source from the content-addressed store, hash-verified

24 return self.block_filenames
25
26 def split(self, block_size, sort_key=None):
27 i = 0
28 with open(self.filename) as file:
29 while True:
30 lines = file.readlines(block_size)
31
32 if lines == []:
33 break
34
35 if sort_key is None:
36 lines.sort()
37 else:
38 lines.sort(key=sort_key)
39
40 self.write_block("".join(lines), i)
41 i += 1
42
43 def cleanup(self):
44 map(os.remove, self.block_filenames)

Callers 15

sortMethod · 0.95
collect_datasetFunction · 0.80
term_frequencyFunction · 0.80
document_frequencyFunction · 0.80
is_valid_email_addressFunction · 0.80
word_occurrenceFunction · 0.80
reverse_wordsFunction · 0.80
remove_duplicatesFunction · 0.80
sentence_to_title_caseFunction · 0.80
text_justificationFunction · 0.80
load_dictionaryFunction · 0.80
get_english_countFunction · 0.80

Calls 2

write_blockMethod · 0.95
sortMethod · 0.80

Tested by 3

mainFunction · 0.64
test_trieFunction · 0.64
test_trieFunction · 0.64