fix(nlp): match single-letter bullets in the enumerated bullet pattern
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Lee unstructured/nlp/patterns.py en ENUMERATED_BULLETS_RE y el nuevo test_unstructured/nlp/test_patterns.py; el issue proporciona los requisitos del cambio de regex y un ejemplo reproducible. Ejecuta el comando pytest indicado para comprobar la regex, el convertidor y los casos existentes de números y abreviaturas. El trabajo estará terminado cuando los marcadores de lista de una sola letra se separen en elementos independientes y los casos de números y abreviaturas sigan pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- HTML
- Estrellas
- 15.6k
- Forks
- 1.4k
- Merge medio
- 3 d 15 h
- PR fusionados (30 d)
- 78
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Unstructured-IO/unstructured
-
CoordinateSystem cannot be compared or converted without a caller-set `orientation`Posiblemente ocupada @Eapp1e la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Unstructured-IO/unstructured#4614 ·
Los mantenedores suelen responder en 1 día
-
bug(cleaners): translate_text passes text instead of chunk in attention window loopPosiblemente ocupada @gunjan-l la tomó hace 11 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Unstructured-IO/unstructured#4558 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
extract_text_before/extract_text_after raise UnboundLocalError when the pattern is absentPosiblemente ocupada @ayam04 la tomó hace 70 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Unstructured-IO/unstructured#4427 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Large HTML documents cannot be partitioned using the partition_html function.Posiblemente ocupada @CrepuscularIRIS la tomó hace 196 días. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Unstructured-IO/unstructured#4289 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug/Dependency resolution discrepancy for numbaQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Unstructured-IO/unstructured#4216 · 4 comentarios · 7 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de Unstructured-IO/unstructured
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
pollen-robotics/reachy_mini#1527 ·
Los mantenedores suelen responder en 1 día
-
A seed and its negative give the same run, so realizations of a negative seed repeat each otherAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
inflate: total_in uses plain += on c_ulong (32-bit on Windows), panics in debug for streams > 4 GiBAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
trifectatechfoundation/zlib-rs#570 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
gbourgeat/ddd-ts-kit#680 ·
Los mantenedores suelen responder en 1 día