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

Function parse_string_list

experiments/baselines/scinup_strict/runner.py:71–93  ·  view source on GitHub ↗
(raw_value: Any)

Source from the content-addressed store, hash-verified

69
70
71def parse_string_list(raw_value: Any) -> List[str]:
72 if raw_value in (None, "", []):
73 return []
74 if isinstance(raw_value, list):
75 values: List[str] = []
76 for item in raw_value:
77 values.extend(parse_string_list(item))
78 return [item for item in values if item]
79 if isinstance(raw_value, dict):
80 values = []
81 for key, value in raw_value.items():
82 values.append(str(key))
83 values.extend(parse_string_list(value))
84 return [item.strip() for item in values if item.strip()]
85 if isinstance(raw_value, str):
86 try:
87 parsed = json.loads(raw_value)
88 except json.JSONDecodeError:
89 parsed = None
90 if isinstance(parsed, (list, dict)):
91 return parse_string_list(parsed)
92 return [item.strip() for item in re.split(r"[,;|\n]+", raw_value) if item.strip()]
93 return [str(raw_value).strip()] if str(raw_value).strip() else []
94
95
96def seed_direction_phrases(raw_value: Any) -> List[str]:

Callers 1

seed_direction_phrasesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected