MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / tally_persons

Function tally_persons

src/summarycode/copyright_tallies.py:225–248  ·  view source on GitHub ↗

Return a list of mapping of {value:string, count:int} given a list of holders strings or Text() objects.

(texts)

Source from the content-addressed store, hash-verified

223
224
225def tally_persons(texts):
226 """
227 Return a list of mapping of {value:string, count:int} given a
228 list of holders strings or Text() objects.
229 """
230 texts_to_tally = []
231 no_detection_counter = 0
232 for text in texts:
233 if not text:
234 no_detection_counter += 1
235 continue
236 # Keep Text objects as-is
237 if isinstance(text, Text):
238 texts_to_tally.append(text)
239 else:
240 cano = canonical_holder(text)
241 texts_to_tally.append(Text(cano, cano))
242
243 counter = tally(texts_to_tally)
244
245 if no_detection_counter:
246 counter[None] = no_detection_counter
247
248 return counter
249
250
251def tally(summary_texts):

Callers 1

closure_test_functionFunction · 0.90

Calls 4

canonical_holderFunction · 0.85
TextClass · 0.85
tallyFunction · 0.85
appendMethod · 0.45

Tested by 1

closure_test_functionFunction · 0.72