Synchronize chapter and navigation translations with Chinese prose indentation
This commit is contained in:
@@ -8,6 +8,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from src.common.data_model import BookStructure, ManifestEntry
|
||||
from src.preprocessing.epub_cleaner import EpubCleaner
|
||||
from src.preprocessing.text_extractor import FineGrainedExtractor
|
||||
from src.preprocessing.navigation import prepare_navigation
|
||||
from src.assembly.restoration_engine import RestorationEngine
|
||||
from src.assembly.backfiller import BackfillEngine
|
||||
from src.assembly.builder import BilingualBuilder
|
||||
@@ -17,6 +18,7 @@ async def run(args):
|
||||
args.out.mkdir(parents=True,exist_ok=True)
|
||||
structure=BookStructure.load(EpubCleaner(args.source,args.out/'source').clean())
|
||||
entries=FineGrainedExtractor().extract(structure)
|
||||
prepare_navigation(args.source,structure,entries)
|
||||
by_id={e.entry_id:e for e in entries}
|
||||
provided=[ManifestEntry.model_validate(e) for e in json.loads(args.manifest.read_text())]
|
||||
for sample in provided:
|
||||
|
||||
@@ -6,6 +6,7 @@ from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from src.preprocessing.epub_cleaner import EpubCleaner
|
||||
from src.preprocessing.text_extractor import FineGrainedExtractor
|
||||
from src.preprocessing.navigation import prepare_navigation
|
||||
from src.common.data_model import BookStructure
|
||||
from src.assembly.format_restorer import FormatRestorer
|
||||
from src.assembly.builder import BilingualBuilder
|
||||
@@ -23,10 +24,12 @@ def main():
|
||||
work=args.out/source.stem
|
||||
structure=BookStructure.load(EpubCleaner(source,work).clean())
|
||||
entries=FineGrainedExtractor().extract(structure)
|
||||
prepare_navigation(source,structure,entries)
|
||||
bad=[e.entry_id for e in entries if not FormatRestorer().restore(e.original_text,e.placeholders,original_text=e.original_text)[1]]
|
||||
output=BilingualBuilder(work,source).build(structure,work/'roundtrip.epub')
|
||||
before,after=audit_epub(source),audit_epub(output)
|
||||
row.update(entries=len(entries),format_failures=bad,source_issues=len(before['issues']),
|
||||
row.update(entries=len(entries),navigation_titles=len(structure.navigation_titles),
|
||||
unbound_titles=[r["source_label"] for r in structure.navigation_titles if r.get("binding_note")],format_failures=bad,source_issues=len(before['issues']),
|
||||
new_issues=compare_audits(before,after))
|
||||
except Exception as exc:
|
||||
row['error']=str(exc)
|
||||
|
||||
@@ -96,7 +96,7 @@ def main():
|
||||
'scope': 'provided manifest only'}
|
||||
if errors and not args.allow_partial:
|
||||
report['new_issues'].append({'kind': 'incomplete_translation', 'detail': str(len(errors))})
|
||||
chapter_hrefs = args.chapter or list(dict.fromkeys(e.file_path for e in entries if e.translated_text))
|
||||
chapter_hrefs = args.chapter or list(dict.fromkeys(e.file_path for e in entries if e.translated_text and e.file_path != "__navigation__"))
|
||||
if not args.chapter and args.max_chapters:
|
||||
chapter_hrefs = chapter_hrefs[:args.max_chapters]
|
||||
report['sampled_chapters'] = chapter_hrefs
|
||||
|
||||
Reference in New Issue
Block a user