fix(nlp): match single-letter bullets in the enumerated bullet pattern
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Đọc unstructured/nlp/patterns.py tại ENUMERATED_BULLETS_RE và tệp mới test_unstructured/nlp/test_patterns.py; issue cung cấp các yêu cầu thay đổi regex và ví dụ tái hiện lỗi. Chạy lệnh pytest được liệt kê để kiểm tra regex, bộ chuyển đổi và các trường hợp hiện có về số và chữ viết tắt. Hoàn thành khi các dấu đầu dòng chỉ gồm một chữ cái được tách thành các mục riêng biệt, còn các trường hợp về số và chữ viết tắt vẫn vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
ENUMERATED_BULLETS_RE cannot match a single-letter bullet.
unstructured/nlp/patterns.py:111 compiles
ENUMERATED_BULLETS_RE = re.compile(r"(?:(?:\d{1,3}|[a-z][A-Z])\.?){1,3}")
[a-z][A-Z] is two single-character classes placed next to each other, so it matches exactly two characters (aB) and never a single a or A. The two ordered-bullet helpers in this repo both accept a single letter as a marker:
unstructured/cleaners/core.py:53clean_ordered_bullets— docstring says "accounting numeric and alphanumeric types" and showsa.b This is a very important point -> This is a very important point.unstructured/cleaners/extract.py:104extract_ordered_bullets— docstring showsa.1 This is a very important point -> ("a", "1", None).
The splitter regex used by the list path cannot, so lettered lists come out as one blob:
from unstructured.partition.common.common import layout_list_to_list_items
[e.text for e in layout_list_to_list_items("a. foo\nb. bar", None, None, None, None)]
# ['a. foo\nb. bar'] expected ['foo', 'bar']
This is user visible through partition_image and partition_pdf(strategy="ocr_only"): ocr_data_to_elements -> normalize_layout_element -> layout_list_to_list_items (unstructured/partition/common/common.py:137).
Change
Keep the numeric branch byte for byte, and add a letter branch that only matches at the start of a line, only with a literal dot, and only when whitespace or the end of the text follows. The line anchor and the (?!\s[a-zA-Z]\.) guard are both required: \.? is optional, so an unanchored [a-zA-Z] turns every letter into a separator ("1. foo\n2. bar" would split into []), and without the guard "e. g. spaced example" loses its first word.
Verification
test_unstructured/nlp/test_patterns.py (new) covers both the regex and the converter, including the existing numeric behaviour and the abbreviation cases:
python -m pytest test_unstructured/nlp/test_patterns.py test_unstructured/nlp/test_tokenize.py test_unstructured/cleaners/test_core.py test_unstructured/cleaners/test_extract.py -q
pristine: 19 failed, 211 passed
patched: 10 failed, 220 passed
The 10 remaining failures are the pre-existing test_tokenize.py ones (no spaCy model in this offline environment); they are identical in both runs. The new file alone goes from 9 failed, 11 passed to 20 passed.
ruff format --check and ruff check are clean on both files.
- Ngôn ngữ chính
- HTML
- Star
- 15.6k
- Fork
- 1.4k
- Merge trung bình
- 3 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 78
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Unstructured-IO/unstructured
-
CoordinateSystem cannot be compared or converted without a caller-set `orientation`Có thể đã có người làm @Eapp1e đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Unstructured-IO/unstructured#4614 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(cleaners): translate_text passes text instead of chunk in attention window loopCó thể đã có người làm @gunjan-l đã nhận 11 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Unstructured-IO/unstructured#4558 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
extract_text_before/extract_text_after raise UnboundLocalError when the pattern is absentCó thể đã có người làm @ayam04 đã nhận 71 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Unstructured-IO/unstructured#4427 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Large HTML documents cannot be partitioned using the partition_html function.Có thể đã có người làm @CrepuscularIRIS đã nhận 197 ngày trước. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Unstructured-IO/unstructured#4289 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug/Dependency resolution discrepancy for numbaCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Unstructured-IO/unstructured#4216 · 4 bình luận · 7 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Unstructured-IO/unstructured
Issue tương tự
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
servo/rust-smallvec#827 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug webbackend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
DOMjudge/domjudge#3886 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
repo:cms
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
craftcms/cms#20235 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày