Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

fix(nlp): match single-letter bullets in the enumerated bullet pattern

Đang mở Phù hợp với người mới
#4,635 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Eapp1e đang làm issue này rồi.

Từ ngày 30/10/2026.

  • #4636 của @Eapp1e — đang mở

Đá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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend, data

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:53 clean_ordered_bullets — docstring says "accounting numeric and alphanumeric types" and shows a.b This is a very important point -> This is a very important point.
  • unstructured/cleaners/extract.py:104 extract_ordered_bullets — docstring shows a.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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Unstructured-IO/unstructured

Tất cả issue của Unstructured-IO/unstructured

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.