MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / split_known_choice

Function split_known_choice

tools/commitlist.py:149–166  ·  view source on GitHub ↗
(raw_text: str, choices: list[str], default: str)

Source from the content-addressed store, hash-verified

147
148
149def split_known_choice(raw_text: str, choices: list[str], default: str) -> str:
150 parts = [
151 cleanup_markdown_text(part)
152 for part in re.split(r'[,|\n]+', raw_text or '')
153 ]
154 parts = [part for part in parts if part]
155 if not parts:
156 return default
157 for part in parts:
158 for choice in choices:
159 if part.casefold() == choice.casefold():
160 return choice
161 for part in parts:
162 lowered = part.casefold()
163 for choice in choices:
164 if choice.casefold() in lowered:
165 return choice
166 return default
167
168
169def label_value(labels: Iterable[str], prefix: str) -> str | None:

Callers 2

resolve_categoryFunction · 0.85
resolve_topicFunction · 0.85

Calls 2

cleanup_markdown_textFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected