Repository navigation
refactor title.py - #2657
Merged
Merged
refactor title.py#2657
Conversation
scanny
approved these changes
Mar 19, 2024
scanny
left a comment
Contributor
There was a problem hiding this comment.
Yep, LGTM. Some small polishing items to fix up before merge but approving in advance.
kaaloo
pushed a commit
to inclusif/unstructured
that referenced
this pull request
Apr 8, 2024
Minor refactor after conversation with @scanny Updates docstring and how chunking options are accessed. `self._kwargs.get()` should only be used in the `lazyproperty` definition of an instance's attribute. Other calls should use `self.<attribute>`
kaaloo
pushed a commit
to inclusif/unstructured
that referenced
this pull request
Apr 8, 2024
Minor refactor after conversation with @scanny Updates docstring and how chunking options are accessed. `self._kwargs.get()` should only be used in the `lazyproperty` definition of an instance's attribute. Other calls should use `self.<attribute>`
abo3losh1
added a commit
to abo3losh1/unstructured
that referenced
this pull request
Sep 22, 2026
`combine_text_under_n_chars` is documented as capped at `new_after_n_chars`: a combine-threshold above the soft-max recombines pre-chunks the soft-max has already declared full, so the caller gets chunks well past the size they asked for. The cap was implemented until the `title.py` refactor in 9ac4445 (Unstructured-IO#2657), which replaced return soft_max if combine_text_under_n_chars > soft_max else combine_text_under_n_chars with a plain read of the argument, while leaving both the property's own docstring ("Is reduced to `new_after_n_chars` when it exceeds that value") and the public option documentation in `base.py` ("Note this value is 'capped' at the `new_after_n_chars` value") describing the old behavior. chunk_by_title( elements, max_characters=500, new_after_n_chars=100, combine_text_under_n_chars=400, ) returned one 367-character chunk where three 121-character chunks were asked for. Restore the cap. Validation now reads the argument as the caller gave it rather than the capped property, so a negative value and a value greater than `max_characters` are both still rejected with the same messages; the cap would otherwise have hidden the second case.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Minor refactor after conversation with @scanny
Updates docstring and how chunking options are accessed.
self._kwargs.get()should only be used in thelazypropertydefinition of an instance's attribute. Other calls should useself.<attribute>