MCPcopy Create free account
hub / github.com/SooLab/CGFormer / get_pairs

Function get_pairs

utils/simple_tokenizer.py:38–47  ·  view source on GitHub ↗

Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).

(word)

Source from the content-addressed store, hash-verified

36
37
38def get_pairs(word):
39 """Return set of symbol pairs in a word.
40 Word is represented as tuple of symbols (symbols being variable-length strings).
41 """
42 pairs = set()
43 prev_char = word[0]
44 for char in word[1:]:
45 pairs.add((prev_char, char))
46 prev_char = char
47 return pairs
48
49
50def basic_clean(text):

Callers 1

bpeMethod · 0.85

Calls 1

addMethod · 0.80

Tested by

no test coverage detected