Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 76 additions & 8 deletions llm_web_kit/extractor/html/post_main_html_processer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,82 @@

## 流程方案

![img.png](asserts/img.png)
![img.png](assets/img.png)

## 执行步骤

| filename | function | input & input_type | output_type | 实现功能 |
| :--------------- | :-------------------------- | :-------------------------------------------------------- | :------------------ | :------------- |
| choose_html.py | select_typical_html | html_strs: html迭代器 | str | 选出代表html |
| add_tags.py | process_html | input_html: str | str | 添加itemid |
| post_llm.py | get_llm_response | api_key: str, url: str, html_id_str: str, model_name: str | str | 模型打标 |
| generate_rule.py | restore_html_trim_ends_only | processed_html: str, llm_response: Dict\[str, int\] | Dict\[str, object\] | 生成删除规则 |
| post_mapping.py | mapping_html_by_rules | html_str: str, post_delete_node: List\[object\] | str | 推广到所有数据 |
| filename | function | input & input_type | output_type | 实现功能 |
| :--------------- | :-------------------------- | :------------------------------------------------------------------------------ | :------------------------- | :------------- |
| choose_html.py | select_typical_html | html_strs: html迭代器 | str | 选出代表html |
| add_tags.py | process_html | input_html: str | str | 添加itemid |
| post_llm.py | get_llm_response | api_key: str, url: str, html_id_str: str, model_name: str | Dict\[str, int\] \[^1\] | 模型打标 |
| generate_rule.py | restore_html_trim_ends_only | processed_html: str, llm_response: Dict\[str, int\](get_llm_response的输出结果) | Dict\[str, object\] \[^2\] | 生成删除规则 |
| post_mapping.py | mapping_html_by_rules | html_str: str, post_delete_node: List\[object\] \[^3\] | str | 推广到所有数据 |

\[^1\]

```jsonc

{"item_id 1": 0, "item_id 2": 0, "item_id 3": 1, "item_id 4": 1, "item_id 5": 1, "item_id 6": 1, "item_id 7": 1} // 0:删除;1:保留

```

\[^2\]

```jsonc

{
"html": "...", // 选出的代表main html经过处理之后的新html
"post_delete_node": [ // 删除规则
{
"del_location": "start", // 删除的位置【start(头部) or end(尾部)】
"xpath": "/div/div[1]/div/div/div[1]", // 删除节点的xpath
"tag": "div", // 删除节点的标签名称
"attributes": {"class": "left-content"}, // 删除节点的属性
"index_in_parent": 0, // 删除节点在父节点的索引
"parent_xpath": "/div/div[1]/div/div", // 删除节点的父节点的xpath
"parent_tag": "div", // 删除节点的父节点的标签名称
"parent_attributes": {"class": "main-content fl-clr"} // 删除节点的父节点的属性
},
{
"del_location": "end",
"xpath": "/div/div[3]",
"tag": "div",
"attributes": {"class": "footer"},
"index_in_parent": 2,
"parent_xpath": "/div",
"parent_tag": "div",
"parent_attributes": {}
}
]
}

```

\[^3\]

```jsonc
[
{
"del_location": "start", // 删除的位置【start(头部) or end(尾部)】
"xpath": "/div/div[1]/div/div/div[1]", // 删除节点的xpath
"tag": "div", // 删除节点的标签名称
"attributes": {"class": "left-content"}, // 删除节点的属性
"index_in_parent": 0, // 删除节点在父节点的索引
"parent_xpath": "/div/div[1]/div/div", // 删除节点的父节点的xpath
"parent_tag": "div", // 删除节点的父节点的标签名称
"parent_attributes": {"class": "main-content fl-clr"} // 删除节点的父节点的属性
},
{
"del_location": "end",
"xpath": "/div/div[3]",
"tag": "div",
"attributes": {"class": "footer"},
"index_in_parent": 2,
"parent_xpath": "/div",
"parent_tag": "div",
"parent_attributes": {}
}
]

```
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.