MCPcopy Create free account
hub / github.com/FLC777/GLAT / update_sample

Function update_sample

scripts/split_train_valid_docs.py:33–45  ·  view source on GitHub ↗
(doc)

Source from the content-addressed store, hash-verified

31 num_docs = [0]
32
33 def update_sample(doc):
34 if len(sample) < args.k:
35 sample.append(doc.copy())
36 else:
37 i = num_docs[0]
38 j = random.randrange(i + 1)
39 if j < args.k:
40 remainder.append(sample[j])
41 sample[j] = doc.copy()
42 else:
43 remainder.append(doc.copy())
44 num_docs[0] += 1
45 doc.clear()
46
47 with open(args.input, "r", encoding="utf-8") as h:
48 doc = []

Callers 1

mainFunction · 0.85

Calls 1

copyMethod · 0.45

Tested by

no test coverage detected