MCPcopy Create free account
hub / github.com/InternScience/SciReason / general_postprocess

Function general_postprocess

opencompass/utils/text_postprocessors.py:8–24  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

6
7@TEXT_POSTPROCESSORS.register_module('general')
8def general_postprocess(text: str) -> str:
9 # Cut off the first newline, period, or comma
10 truncated_text = re.split(r'[\n.,]', text, 1)[0]
11
12 # Remove punctuation
13 no_punctuation = re.sub(r'[^\w\s]', '', truncated_text)
14
15 # Remove article
16 no_articles = re.sub(r'\b(a|an|the)\b',
17 '',
18 no_punctuation,
19 flags=re.IGNORECASE)
20
21 # Remove duplicated blank spaces
22 cleaned_text = re.sub(r'\s+', ' ', no_articles).strip()
23
24 return cleaned_text
25
26
27@TEXT_POSTPROCESSORS.register_module('general_cn')

Callers 10

scoreMethod · 0.90
scoreMethod · 0.90
scoreMethod · 0.90
scoreMethod · 0.90
scoreMethod · 0.90
scoreMethod · 0.90
f1_scoreMethod · 0.90
exact_match_scoreMethod · 0.90
scoreMethod · 0.90
scoreMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected