转换为分段对象 :param result_tree: 解析文本的树 :param result: 传[] 用于递归 :param parent_chain: 传[] 用户递归存储数据 :param with_filter: 是否过滤block :return: List[{'problem':'xx','content':'xx'}]
(result_tree: List[dict], result, parent_chain, with_filter: bool)
| 247 | |
| 248 | |
| 249 | def result_tree_to_paragraph(result_tree: List[dict], result, parent_chain, with_filter: bool): |
| 250 | """ |
| 251 | 转换为分段对象 |
| 252 | :param result_tree: 解析文本的树 |
| 253 | :param result: 传[] 用于递归 |
| 254 | :param parent_chain: 传[] 用户递归存储数据 |
| 255 | :param with_filter: 是否过滤block |
| 256 | :return: List[{'problem':'xx','content':'xx'}] |
| 257 | """ |
| 258 | for item in result_tree: |
| 259 | if item.get('state') == 'block': |
| 260 | result.append({'title': " ".join(parent_chain), |
| 261 | 'content': filter_special_char(item.get("content")) if with_filter else item.get("content")}) |
| 262 | children = item.get("children") |
| 263 | if children is not None and len(children) > 0: |
| 264 | result_tree_to_paragraph(children, result, |
| 265 | [*parent_chain, remove_special_symbol(item.get('content'))], with_filter) |
| 266 | return result |
| 267 | |
| 268 | |
| 269 | def post_handler_paragraph(content: str, limit: int): |
no test coverage detected