fix(partition): classify text as an address only when all of it is one
Summary
is_us_city_state_zip() matches the start of the text instead of the whole text, so any sentence whose prefix is a city/state/zip is typed Address.
partition_text(), partition_html() and partition_docx() all call this check before is_possible_narrative_text(), so a full sentence turns into an Address element:
partition_text(text="Doylestown, PA 18901 is where the team met last spring.")
# [Address(text='Doylestown, PA 18901 is where the team met last spring.')]
The docstring of the function describes a whole city/state/zip value, and every example it lists is a bare address. Its sibling is_email_address() was switched to fullmatch in #4577 for the same reason ("classify text as an email address only when all of it is one"); this one kept the start-only match.
Change
unstructured/partition/text_type.py:US_CITY_STATE_ZIP_RE.match(...)->US_CITY_STATE_ZIP_RE.fullmatch(...).test_unstructured/partition/test_text_type.py: two parametrized cases that start with an address but continue as a sentence.test_unstructured/partition/test_text.py: onepartition_text()regression test asserting the sentence is not typedAddress.
The pattern in unstructured/nlp/patterns.py is not anchored, so every bare-address case keeps working: the eleven existing parametrized cases in test_text_type.py return identical results under both calls, and partition_text(filename="example-docs/fake-text.txt") still yields Address | Doylestown, PA 18901.
Test
python -m pytest test_unstructured/partition/test_text_type.py \
--noconftest -o addopts= -p no:cacheprovider -p stub_tokenize -p stub_oxmsg -q
before: 9 failed, 105 passed after: 9 failed, 107 passed
(the two new cases flip to pass; the nine failures are offline-env only - spaCy
`en_core_web_sm` is not installed here, so `contains_verb` returns False, and they
fail identically before and after)
python -m pytest test_unstructured/partition/test_text.py ...
before: 35 failed, 56 passed after: 35 failed, 57 passed
(the new test flips; the rest are FileNotFound / language-model env issues)
python -m pytest test_unstructured/partition/test_text.py \
-k does_not_make_an_address ...
1 failed before the change, 1 passed after
Fixes #4629