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

Function parse_string_list

experiments/baselines/nl_profile/runner.py:98–123  ·  view source on GitHub ↗
(raw_value: Any)

Source from the content-addressed store, hash-verified

96
97
98def parse_string_list(raw_value: Any) -> List[str]:
99 if raw_value in (None, "", []):
100 return []
101 if isinstance(raw_value, list):
102 values: List[str] = []
103 for item in raw_value:
104 if isinstance(item, dict):
105 values.extend(parse_string_list(item))
106 else:
107 values.append(str(item))
108 return [item.strip() for item in values if item.strip()]
109 if isinstance(raw_value, dict):
110 values: List[str] = []
111 for key, value in raw_value.items():
112 values.append(str(key))
113 values.extend(parse_string_list(value))
114 return [item.strip() for item in values if item.strip()]
115 if isinstance(raw_value, str):
116 try:
117 parsed = json.loads(raw_value)
118 except json.JSONDecodeError:
119 parsed = None
120 if isinstance(parsed, (list, dict)):
121 return parse_string_list(parsed)
122 return [item.strip() for item in re.split(r"[,;|\n]+", raw_value) if item.strip()]
123 return [str(raw_value).strip()] if str(raw_value).strip() else []
124
125
126def normalize_phrase_text(value: Any) -> str:

Callers 2

_direction_termsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected