Spaces:
Running
Running
Bor Hodošček
commited on
Commit
·
d7f58cf
1
Parent(s):
b38b340
fix: filename convention
Browse files
app.py
CHANGED
@@ -103,13 +103,13 @@ def function_export():
|
|
103 |
E.g., 'e-r-eddison_the-worm-ouroboros.txt' -> 'ERE-TWO'.
|
104 |
"""
|
105 |
stem = _strip_advanced(fn)
|
106 |
-
fields = stem.split("
|
107 |
if len(fields) == 2:
|
108 |
author, title = fields
|
109 |
else:
|
110 |
author = fields[0]
|
111 |
title = fields[0]
|
112 |
-
initials = lambda s: "".join(part[0].upper() for part in s.split("
|
113 |
return f"{initials(author)}-{initials(title)}"
|
114 |
|
115 |
def format_chunk_label(
|
@@ -313,11 +313,11 @@ def function_export():
|
|
313 |
# infer author & work from the file's true stem (no extension, no "_advanced")
|
314 |
def _extract_auth_work(fn: str) -> tuple[str, str]:
|
315 |
base = Path(fn).stem.replace("_advanced", "")
|
316 |
-
auth, *rest = base.split("
|
317 |
work_raw = rest[0] if rest else base
|
318 |
return (
|
319 |
-
auth.replace("
|
320 |
-
work_raw.replace("
|
321 |
)
|
322 |
|
323 |
aw = df_p["filename"].apply(_extract_auth_work)
|
@@ -473,8 +473,8 @@ def data_check(
|
|
473 |
|
474 |
if mode_tabs.value == "Speech vs Non-Speech":
|
475 |
defaults = [
|
476 |
-
"
|
477 |
-
"
|
478 |
]
|
479 |
df_pre = prepare_files(
|
480 |
speech_form.value.get("files_s", []),
|
|
|
103 |
E.g., 'e-r-eddison_the-worm-ouroboros.txt' -> 'ERE-TWO'.
|
104 |
"""
|
105 |
stem = _strip_advanced(fn)
|
106 |
+
fields = stem.split("-", 1)
|
107 |
if len(fields) == 2:
|
108 |
author, title = fields
|
109 |
else:
|
110 |
author = fields[0]
|
111 |
title = fields[0]
|
112 |
+
initials = lambda s: "".join(part[0].upper() for part in s.split("_"))
|
113 |
return f"{initials(author)}-{initials(title)}"
|
114 |
|
115 |
def format_chunk_label(
|
|
|
313 |
# infer author & work from the file's true stem (no extension, no "_advanced")
|
314 |
def _extract_auth_work(fn: str) -> tuple[str, str]:
|
315 |
base = Path(fn).stem.replace("_advanced", "")
|
316 |
+
auth, *rest = base.split("-", 1)
|
317 |
work_raw = rest[0] if rest else base
|
318 |
return (
|
319 |
+
auth.replace("_", " ").title(),
|
320 |
+
work_raw.replace("_", " ").title(),
|
321 |
)
|
322 |
|
323 |
aw = df_p["filename"].apply(_extract_auth_work)
|
|
|
473 |
|
474 |
if mode_tabs.value == "Speech vs Non-Speech":
|
475 |
defaults = [
|
476 |
+
"e_r_eddison-the_worm_ouroboros_advanced.txt",
|
477 |
+
"h_g_wells-the_wonderful_visit_advanced.txt",
|
478 |
]
|
479 |
df_pre = prepare_files(
|
480 |
speech_form.value.get("files_s", []),
|
e-r-eddison_the-worm-ouroboros_advanced.txt → e_r_eddison-the_worm_ouroboros_advanced.txt
RENAMED
File without changes
|
h-g-wells_the-wonderful-visit_advanced.txt → h_g_wells-the_wonderful_visit_advanced.txt
RENAMED
File without changes
|