fix(nlp): match single-letter bullets in the enumerated bullet pattern
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
調査の方向性
unstructured/nlp/patterns.py の ENUMERATED_BULLETS_RE と、新しい test_unstructured/nlp/test_patterns.py を読みます。Issue には正規表現の変更要件と再現例が記載されています。指定された pytest コマンドを実行し、正規表現、コンバーター、既存の数字と略語のケースを確認します。1 文字のリストマーカーが個別の項目に分割され、数字と略語のケースも引き続きパスすれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- HTML
- スター
- 15.6k
- フォーク
- 1.4k
- 平均マージ
- 3日 15時間
- マージ済み PR(30日)
- 78
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Unstructured-IO/unstructured のほかの issue
-
CoordinateSystem cannot be compared or converted without a caller-set `orientation`対応中かも @Eapp1e が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Unstructured-IO/unstructured#4614 ·
メンテナーはふだん 1 日以内に返信
-
bug(cleaners): translate_text passes text instead of chunk in attention window loop対応中かも @gunjan-l が 11 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
Unstructured-IO/unstructured#4558 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
extract_text_before/extract_text_after raise UnboundLocalError when the pattern is absent対応中かも @ayam04 が 71 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Unstructured-IO/unstructured#4427 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Large HTML documents cannot be partitioned using the partition_html function.対応中かも @CrepuscularIRIS が 197 日前に担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
Unstructured-IO/unstructured#4289 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug/Dependency resolution discrepancy for numba再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Unstructured-IO/unstructured#4216 · コメント 4 件 · リアクション 7 件 ·
メンテナーはふだん 1 日以内に返信
Unstructured-IO/unstructured の issue をすべて見る
似ている issue
-
repo:cms
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
craftcms/cms#20235 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
breaking change bug needs human review not ready priority medium size S
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
martin-francois/symphony-trello#1193 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
loopbackio/loopback-next#11878 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Dao-AILab/flash-attention#3097 ·
メンテナーはふだん 3 日以内に返信
-
bug 🐛
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
comunica/comunica#1925 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信