vomebook commited on
Commit
1295e16
·
verified ·
1 Parent(s): 55c219e

Expose OCR origins directly at source folder root

Browse files
Files changed (1) hide show
  1. ocr_release.py +5 -2
ocr_release.py CHANGED
@@ -152,7 +152,10 @@ def directory_payloads(records: list[dict]) -> tuple[list[dict], dict]:
152
  return {"name": name, "path": path, "count": counts[path], "hasDirectFiles": bool(direct[path]),
153
  "hasChildren": bool(children[path]), "showSelfToggle": bool(path and direct[path] and children[path]),
154
  "children": [node(child, (path + "/" if path else "") + child) for child in sorted(children[path])]}
155
- return [node(SOURCE_NAME, "")], dict(browser)
 
 
 
156
 
157
 
158
  def zip_member(record: dict) -> str:
@@ -167,7 +170,7 @@ def zip_member(record: dict) -> str:
167
  return value
168
  parts = safe_path(record["display_rel_path"]).split("/")
169
  parts[-1] = component(PurePosixPath(parts[-1]).stem) + ".txt"
170
- return "/".join([SOURCE_NAME, *[component(part) for part in parts[:-1]], parts[-1]])
171
 
172
 
173
  def validate_database(path: Path, records: list[dict], text_root: Path) -> None:
 
152
  return {"name": name, "path": path, "count": counts[path], "hasDirectFiles": bool(direct[path]),
153
  "hasChildren": bool(children[path]), "showSelfToggle": bool(path and direct[path] and children[path]),
154
  "children": [node(child, (path + "/" if path else "") + child) for child in sorted(children[path])]}
155
+ # The source slug identifies this collection. Do not add a synthetic
156
+ # `OCR成果/` directory above the preserved origin hierarchy; VoiceOfML,
157
+ # or any other source owner, is the actual top-level folder.
158
+ return [node(child, child) for child in sorted(children[""])], dict(browser)
159
 
160
 
161
  def zip_member(record: dict) -> str:
 
170
  return value
171
  parts = safe_path(record["display_rel_path"]).split("/")
172
  parts[-1] = component(PurePosixPath(parts[-1]).stem) + ".txt"
173
+ return "/".join([component(part) for part in parts])
174
 
175
 
176
  def validate_database(path: Path, records: list[dict], text_root: Path) -> None: