MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / parse_string_list

Function parse_string_list

experiments/baselines/discourse_aware/runner.py:193–208  ·  view source on GitHub ↗
(raw_value: Any)

Source from the content-addressed store, hash-verified

191
192
193def parse_string_list(raw_value: Any) -> List[str]:
194 if raw_value in (None, "", []):
195 return []
196 if isinstance(raw_value, list):
197 return [str(item).strip() for item in raw_value if str(item).strip()]
198 if isinstance(raw_value, dict):
199 return [str(key).strip() for key in raw_value.keys() if str(key).strip()]
200 if isinstance(raw_value, str):
201 try:
202 parsed = json.loads(raw_value)
203 except json.JSONDecodeError:
204 parsed = None
205 if isinstance(parsed, (list, dict)):
206 return parse_string_list(parsed)
207 return [item.strip() for item in re.split(r"[,;|\s]+", raw_value) if item.strip()]
208 return [str(raw_value).strip()] if str(raw_value).strip() else []
209
210
211def normalize_phrase_text(value: Any) -> str:

Callers 2

_direction_termsFunction · 0.70
build_initial_profileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected