unstructured
8f553b77 - fix(partition): recognize addresses in Alabama and Wyoming (#4581)

Commit
13 days ago
fix(partition): recognize addresses in Alabama and Wyoming (#4581) ## Summary `US_CITY_STATE_ZIP_PATTERN` wrapped both state alternations in `{` and `}`: ``` (?:{Alabama|Alaska|...|Wyoming}|{AL|AK|...|WY}) ``` In a Python regex these braces are literal characters, so the first and last entry of each list only matched with a brace attached (`{Alabama`, `Wyoming}`, `{AL`, `WY}`). The other states were not affected. Removing the four braces fixes it; the alternatives and their order stay the same. User impact: addresses in Alabama and Wyoming are now `Address` elements. Before, `partition_text` returned `Title` and `partition_html` / `partition_docx` returned `Text`: ``` # input lines: "Birmingham, AL 35203", "Cheyenne, Wyoming 82001", "Boston, MA 02108" text ['Title', 'Title', 'Address'] -> ['Address', 'Address', 'Address'] html ['Text', 'Text', 'Address'] -> ['Address', 'Address', 'Address'] docx ['Text', 'Text', 'Address'] -> ['Address', 'Address', 'Address'] ``` No file in `test_unstructured_ingest/expected-structured-output` contains an Alabama or Wyoming address, so the ingest fixtures do not change. ## Validation Four new `test_is_us_city_state_zip` cases (AL, Alabama, WY, Wyoming) and one `partition_text` test fail on main and pass here. ``` $ pytest test_unstructured/partition/test_text_type.py test_unstructured/partition/test_text.py test_unstructured/partition/html test_unstructured/partition/test_docx.py -q 845 passed ``` ## Checklist - [x] The PR title is a user-facing release-note entry with a conventional commit prefix. - [x] Apply a category label (`enhancement`, `bug`, or an appropriate existing label), or ask a maintainer to apply it. - [ ] For breaking changes, use `!` in the title and explain impact and migration above. Signed-off-by: Dmitry Sergeev <sergeevdms@gmail.com>
Author
Parents
Loading