MCPcopy Create free account
hub / github.com/TIGER-AI-Lab/LongRAG / SimpleTokenizer

Class SimpleTokenizer

utils/eval_util.py:9–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class SimpleTokenizer(object):
10 ALPHA_NUM = r'[\p{L}\p{N}\p{M}]+'
11 NON_WS = r'[^\p{Z}\p{C}]'
12
13 def __init__(self):
14 """
15 Args:
16 annotators: None or empty set (only tokenizes).
17 """
18 self._regexp = regex.compile(
19 '(%s)|(%s)' % (self.ALPHA_NUM, self.NON_WS),
20 flags=regex.IGNORECASE + regex.UNICODE + regex.MULTILINE
21 )
22
23 def tokenize(self, text, uncased=False):
24 matches = [m for m in self._regexp.finditer(text)]
25 if uncased:
26 tokens = [m.group().lower() for m in matches]
27 else:
28 tokens = [m.group() for m in matches]
29 return tokens
30
31
32def remove_articles(text):

Callers 1

has_correct_answerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected