Skip to content

增加元素识别和抽取magic-html的接口#457

Merged
drunkpig merged 9 commits into
ccprocessor:devfrom
dt-yy:dev
Jun 16, 2025
Merged

增加元素识别和抽取magic-html的接口#457
drunkpig merged 9 commits into
ccprocessor:devfrom
dt-yy:dev

Conversation

@dt-yy

@dt-yy dt-yy commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Please describe the motivation of this PR and the goal you want to achieve through this PR.
增加元素识别和抽取magic-html的接口

Modification

Please briefly describe what modification is made in this PR.

BC-breaking (Optional)

Does the modification introduce changes that break the backward compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here and update the documentation.

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects.
  • CLA has been signed and all committers have signed the CLA in this PR.

@codecov

codecov Bot commented Jun 16, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
llm_web_kit/simple.py 68.18% 7 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #457      +/-   ##
==========================================
- Coverage   89.97%   89.69%   -0.28%     
==========================================
  Files         107      102       -5     
  Lines        8288     8433     +145     
==========================================
+ Hits         7457     7564     +107     
- Misses        831      869      +38     
Files with missing lines Coverage Δ
llm_web_kit/extractor/html/extractor.py 93.37% <100.00%> (+0.42%) ⬆️
llm_web_kit/extractor/html/recognizer/ccmath.py 87.50% <ø> (+0.32%) ⬆️
llm_web_kit/libs/html_utils.py 92.39% <100.00%> (-1.14%) ⬇️
llm_web_kit/tools/cli.py 91.11% <100.00%> (ø)
llm_web_kit/simple.py 84.61% <68.18%> (-12.45%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread llm_web_kit/simple.py Outdated
return result


def __extract_magic_html(url:str, html_str: str, page_layout_type:str) -> DataJson:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page_layout_type应该是个枚举值。字符串的话,写什么难找

Comment thread llm_web_kit/simple.py Outdated
return result


def extract_pure_html_to_md(url:str, html_content: str) -> str:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--> extract_xx_html_to_md, 和下方的extract_html_to_md,可合成一个,用参数clip_html=True|False区分。 pure_html有点含糊。

Comment thread llm_web_kit/simple.py Outdated
return result.get_content_list().to_mm_md()


def extract_magic_html(url:str, html_str: str, page_layout_type:str = 'article') -> str:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

函数名字建议为extract_main_html_by_maigic_html

Comment thread llm_web_kit/extractor/html/extractor.py Outdated


class HTMLFileFormatExtractor(BaseFileFormatExtractor):
class HTMLFileFormatExtractor(PureHTMLFileFormatExtractor):

@drunkpig drunkpig Jun 16, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

从文件组织来说extractor.py更像是基类,pure_extractor.py是子类。
另外PureHTMLFIleFormatorExtractor和HTMLFIleFormatorExtractor 名字建议修改为
HTMLFIleFormatorExtractor -> MagicHTMLFIleFormatorExtractor
PureHTMLFIleFormatorExtractor -> NoClipHTMLFIleFormatorExtractor
未来可能还会有 LLM7BHTMLFIleFormatorExtractor ...

Comment thread llm_web_kit/simple.py Outdated


def __extract_pure_html(url:str, html_content: str) -> DataJson:
extractor = PureHTMLFileFormatExtractor(load_pipe_tpl('html'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/ccprocessor/llm-webkit-mirror/blob/dev/llm_web_kit/config/pipe_tpl/html.jsonc 这个配置理论上是不会选取PureHTMLFileFormatExtractor生效。这里要么代码有歧义,要么想要的功能并没有实现。

@drunkpig drunkpig merged commit c198110 into ccprocessor:dev Jun 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants