compass.utilities.finalize.trim_ordinance_text#

trim_ordinance_text(db)[source]#

Trim the ordinance_text column to a maximum character count

LLMs occasionally return a very long excerpt for ordinance_text, which makes the output CSV unwieldy. Any excerpt longer than MAX_ORDINANCE_TEXT_CHARS is cut back to the last whole word that fits and marked with a trailing ellipsis, matching the ellipsis convention already used for elided text within an excerpt.

Parameters:

db (pandas.DataFrame) – The database containing extraction results, which may include an "ordinance_text" column.

Returns:

pandas.DataFrame – The updated database, with any over-long ordinance_text entries trimmed. Databases without that column are returned unchanged.