MCPcopy Create free account
hub / github.com/Monalissaa/DisenDiff / tokenize

Function tokenize

utils/clipscore/generation_eval_utils.py:39–55  ·  view source on GitHub ↗
(refs, cands, no_op=False)

Source from the content-addressed store, hash-verified

37
38
39def tokenize(refs, cands, no_op=False):
40 # no_op is a debug option to see how significantly not using the PTB tokenizer
41 # affects things
42 tokenizer = PTBTokenizer()
43
44 if no_op:
45 refs = {idx: [r for r in c_refs] for idx, c_refs in enumerate(refs)}
46 cands = {idx: [c] for idx, c in enumerate(cands)}
47
48 else:
49 refs = {idx: [{'caption':r} for r in c_refs] for idx, c_refs in enumerate(refs)}
50 cands = {idx: [{'caption':c}] for idx, c in enumerate(cands)}
51
52 refs = tokenizer.tokenize(refs)
53 cands = tokenizer.tokenize(cands)
54
55 return refs, cands
56
57
58def pycoco_eval(scorer, refs, cands):

Callers 1

pycoco_evalFunction · 0.70

Calls 1

tokenizeMethod · 0.80

Tested by

no test coverage detected