Skip to content

fix: combine_text with empty text#510

Merged
drunkpig merged 2 commits into
ccprocessor:devfrom
e06084:dev
Aug 8, 2025
Merged

fix: combine_text with empty text#510
drunkpig merged 2 commits into
ccprocessor:devfrom
e06084:dev

Conversation

@e06084
Copy link
Copy Markdown
Collaborator

@e06084 e06084 commented Aug 8, 2025

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.

Modification

修复了下面的问题:

llm-webkit提取失败: string index out of range
❌ 错误详情: Traceback (most recent call last):
  File "/home/lulindong/Pycharm_projects/cc/WebMainBench/webmainbench/extractors/llm_webkit_extractor.py", line 597, in _extract_content_from_main_html
    content = extract_html_to_md(url or "", main_html, clip_html=False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/simple.py", line 84, in extract_html_to_md
    result = __extract_main_html_by_no_clip_html(url, html_content, raw_html)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/simple.py", line 53, in __extract_main_html_by_no_clip_html
    result = extractor.extract(d)
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/extractor.py", line 34, in extract
    return self._do_extract(data_json)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/extractor.py", line 102, in _do_extract
    parsed_html = extract_func(base_url, parsed_html, raw_html, language)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/extractor.py", line 237, in _extract_paragraph
    lst = self.__paragraph_recognizer.recognize(base_url, html_lst, raw_html, language)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 118, in recognize
    new_lst = self.__to_cctext_lst(lst, language)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 136, in __to_cctext_lst
    para_text = self.__get_paragraph_text(el_element, language)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 260, in __get_paragraph_text
    if final := __get_paragraph_text_recusive(root, ''):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 246, in __get_paragraph_text_recusive
    text = __get_paragraph_text_recusive(child, text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 246, in __get_paragraph_text_recusive
    text = __get_paragraph_text_recusive(child, text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 246, in __get_paragraph_text_recusive
    text = __get_paragraph_text_recusive(child, text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 1 more time]
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 244, in __get_paragraph_text_recusive
    text = self.__combine_text(tem_text, _text, language)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lulindong/Pycharm_projects/llm-webkit-mirror/llm_web_kit/extractor/html/recognizer/text.py", line 198, in __combine_text
    if (text2[0] in string.punctuation) or (text2[0] in special_symbols) or (text2[0] in other_symbols) or (text1 and text1[-1] in other_symbols):
        ~~~~~^^^
IndexError: string index out of range

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
Copy link
Copy Markdown

codecov Bot commented Aug 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #510      +/-   ##
==========================================
+ Coverage   89.97%   91.01%   +1.04%     
==========================================
  Files         107      106       -1     
  Lines        8288     8940     +652     
==========================================
+ Hits         7457     8137     +680     
+ Misses        831      803      -28     
Files with missing lines Coverage Δ
llm_web_kit/extractor/html/recognizer/text.py 94.70% <100.00%> (+0.33%) ⬆️

... and 25 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.

@drunkpig drunkpig merged commit 0875de8 into ccprocessor:dev Aug 8, 2025
6 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