File tree Expand file tree Collapse file tree 2 files changed +2
-6
lines changed Expand file tree Collapse file tree 2 files changed +2
-6
lines changed Original file line number Diff line number Diff line change 4646from unstructured .file_utils .encoding import detect_file_encoding , format_encoding_str
4747from unstructured .file_utils .model import FileType
4848from unstructured .logger import logger
49- from unstructured .nlp .patterns import EMAIL_HEAD_RE , JSON_PATTERN_NO_LIST , LIST_OF_DICTS_PATTERN
49+ from unstructured .nlp .patterns import EMAIL_HEAD_RE , LIST_OF_DICTS_PATTERN
5050from unstructured .partition .common .common import add_element_metadata , exactly_one
5151from unstructured .partition .common .metadata import set_element_hierarchy
5252from unstructured .utils import get_call_args_applying_defaults , lazyproperty
@@ -140,8 +140,7 @@ def is_ndjson_processable(
140140 file_text = _FileTypeDetectionContext .new (
141141 file_path = filename , file = file , encoding = encoding
142142 ).text_head
143-
144- return re .match (JSON_PATTERN_NO_LIST , file_text ) is not None
143+ return file_text .lstrip ().startswith ("{" )
145144
146145
147146class _FileTypeDetector :
Original file line number Diff line number Diff line change 132132# or the closing bracket to handle cases where the JSON array is cut off
133133JSON_PATTERN = r"(?s)\{(?=.*:).*?(?:\}|$)|\[(?s:.*?)\](?:$|,|\])"
134134
135- # JSON Pattern without support for lists
136- JSON_PATTERN_NO_LIST = r"(?s)\{(?=.*:).*?(?:\}|$)|(?:$|,|\])"
137-
138135
139136# taken from https://stackoverflow.com/a/3845829/12406158
140137VALID_JSON_CHARACTERS = r"[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]"
You can’t perform that action at this time.
0 commit comments