// demo-project.jsx — A canned MQM result so reviewers can land on the
// Results screen without running a real assessment. Modeled on the
// ATC-DL paper the user sent as a reference (RU → EN, ML domain) but
// with English labels per the user's explicit request.

window.__APE_DEMO_PROJECT = {
  project: {
    id: 'p_demo_atcdl',
    name: 'ATC-DL paper (RU \u2192 EN)',
    sourceFile: 'atc-dl_source.docx',
    targetFile: 'atc-dl_translation.docx',
    sourceText: '(demo)',
    targetText: '(demo)',
    glossary: '',
  },
  data: {
    source_language: 'Russian',
    source_language_code: 'ru',
    target_language: 'English',
    target_language_code: 'en',
    domain: 'Machine learning research paper \u2014 distributed optimization',
    source_word_count: 3796,
    verdict: 'High-quality translation of a research paper. Terminology is rendered consistently at a near-specialist level and the technical exposition is faithful. Main risks are a small set of meaning-altering additions (notably an inserted \u201cdegradation\u201d framing in the abstract and a self-contradictory clause about DissDL speedup), plus a systemic table-numbering conflict introduced by the translator. Style and register are otherwise idiomatic and publication-ready after light post-editing.',

    segments: [
      { id: 1, section: 'Title',
        source: '\u0410\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0443\u0447\u0451\u0442\u043e\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0433\u0435\u0442\u0435\u0440\u043e\u0433\u0435\u043d\u043d\u043e\u0441\u0442\u0438.',
        target: 'Adaptive Decentralized Deep Learning with Joint Consideration of Statistical and System Heterogeneity.',
        corrected: 'Adaptive Decentralized Deep Learning with Joint Consideration of Statistical and System Heterogeneity.' },
      { id: 2, section: 'Abstract',
        source: '\u0414\u0435\u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u0443\u0437\u043b\u043e\u0432.',
        target: 'Decentralized deep learning enables the training of neural networks on data distributed across multiple nodes.',
        corrected: 'Decentralized deep learning enables the training of neural networks on data distributed across multiple nodes.' },
      { id: 3, section: 'Abstract',
        source: '\u0418\u0445 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u0430\u0451\u0442 \u0441\u0432\u0435\u0440\u0445\u0430\u0434\u0434\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.',
        target: 'Their joint action yields a super-additive gain in convergence speed without degradation of accuracy.',
        corrected: 'Their joint action yields a super-additive gain in convergence speed.' },
      { id: 4, section: '\u00a71.1',
        source: '\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u043e\u0439 \u0434\u043b\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439.',
        target: 'Distributed deep learning has emerged as a foundational paradigm for scaling neural network training.',
        corrected: 'Distributed deep learning is a key paradigm for scaling neural network training.' },
      { id: 5, section: '\u00a71.1',
        source: '\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u0430\u044f \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044f \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u0430 \u0436\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u044b\u0445 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 (T4), \u0442\u0435\u0440\u044f\u044f \u0434\u043e 60% wall-clock \u0432\u0440\u0435\u043c\u0435\u043d\u0438.',
        target: 'A static ring topology must wait for the slowest nodes (T4), wasting up to 60% of wall-clock time.',
        corrected: 'A static ring topology must wait for the slowest nodes (T4), losing up to 60% of wall-clock time.' },
      { id: 6, section: '\u00a71.2 Table',
        source: '\u0423\u0447\u0451\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0433\u0435\u0442\u0435\u0440.',
        target: 'System Heterogeneity',
        corrected: 'System Heterogeneity Awareness' },
      { id: 7, section: '\u00a71.2 Table caption',
        source: '[\u043d\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435]',
        target: 'Table 1: Comparison with related methods',
        corrected: '[no caption in source]' },
      { id: 8, section: '\u00a73.2',
        source: '\u03c4max\u00b7\u03c3\u00b2: \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043e\u0442 \u0441\u0442\u0440\u044d\u0433\u0433\u043b\u0435\u0440\u043e\u0432 (\u03c4max) \u0443\u0441\u0438\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0443\u043c.',
        target: '\u03c4max\u00b7\u03c3\u00b2: straggler-induced delay (\u03c4max) amplifies stochastic gradient noise.',
        corrected: '\u03c4max\u00b7\u03c3\u00b2: straggler-induced delay (\u03c4max) amplifies stochastic noise.' },
      { id: 9, section: '\u00a75.4',
        source: '\u0428\u0430\u0433 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f | \u03b7 | \u0423\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u03b7\u22641/(4LT); \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 grid search.',
        target: 'Learning rate | \u03b7 | Satisfies \u03b7\u22641/(4LT); selected via grid search.',
        corrected: 'Learning rate | \u03b7 | Satisfies \u03b7\u22641/(4LT); in practice, selected via grid search.' },
      { id: 10, section: '\u00a76.1',
        source: '\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u043c \u0438\u0437 [10] (\u0422\u0430\u0431\u043b\u0438\u0446\u0430 3, \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0441\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u0445 GPU).',
        target: 'LogNormal and Pareto parameters were fitted from real measurements reported in [10] (Table 3, mixed-GPU cluster).',
        corrected: 'LogNormal and Pareto parameters were calibrated against real measurements reported in [10] (Table 3, mixed-GPU cluster).' },
      { id: 11, section: '\u00a76.1',
        source: '\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438: (\u0430) \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 1\u20132 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u00abATC-DL (sync, doubly stoch.)\u00bb',
        target: 'For correctness: (a) a row "ATC-DL (sync, doubly stoch.)" is added to the main Tables 1\u20132',
        corrected: 'For fairness: (a) a row "ATC-DL (sync, doubly stoch.)" is added to the main Tables 1\u20132' },
      { id: 12, section: '\u00a76.4 Table 1',
        source: '\u0422\u0430\u0431\u043b\u0438\u0446\u0430 1. Top-1 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c (%), n=32, 300 \u044d\u043f\u043e\u0445 (CIFAR), 100 \u044d\u043f\u043e\u0445 (FEMNIST), 200 \u044d\u043f\u043e\u0445 (ImageNette).',
        target: 'Table 1. Top-1 accuracy (%), n=32, 300 epochs (CIFAR), 100 epochs (FEMNIST), 200 epochs (ImageNette).',
        corrected: 'Table 5. Top-1 accuracy (%), n=32, 300 epochs (CIFAR), 100 epochs (FEMNIST), 200 epochs (ImageNette).' },
      { id: 13, section: '\u00a76.5',
        source: 'ATC-DL (async) \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 2.4\u00d7 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 D-PSGD \u0438 \u0432 1.4\u00d7 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 ADSGD (\u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442).',
        target: 'ATC-DL (async) reaches target accuracy 2.4\u00d7 faster than D-PSGD and 1.4\u00d7 faster than ADSGD (the strongest competitor).',
        corrected: 'ATC-DL (async) reaches target accuracy 2.4\u00d7 faster than D-PSGD and 1.4\u00d7 faster than ADSGD (the closest competitor).' },
      { id: 14, section: '\u00a76.7',
        source: 'DissDL \u0443\u0445\u0443\u0434\u0448\u0430\u0435\u0442\u0441\u044f \u0441 1.3\u00d7 \u0434\u043e 1.5\u00d7.',
        target: 'DissDL DEGRADES from 1.3\u00d7 to 1.5\u00d7.',
        corrected: 'DissDL improves from 1.3\u00d7 to 1.5\u00d7.' },
      { id: 15, section: '\u00a77.2',
        source: 'ATC-DL \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443: \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u0430\u044f \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.',
        target: 'ATC-DL partially addresses this issue: the adaptive topology is guided by actual model divergence.',
        corrected: 'ATC-DL partially mitigates this issue: the adaptive topology is guided by actual model divergence.' },
      { id: 16, section: '\u00a77.5',
        source: '\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 Byzantine-\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0445 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0438.',
        target: 'Integration of Byzantine-robust aggregators with coordinated adaptation.',
        corrected: 'Inclusion of Byzantine-robust aggregators under coordinated adaptation.' },
    ],

    errors: [
      { segment_id: 7, category: 'Design / Markup', subcategory: 'Formatting', severity: 'critical',
        source_span: '[\u043d\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435]', target_span: 'Table 1: Comparison with related methods',
        description: 'Translator added a table caption that does not exist in the source; this creates a numbering conflict (\u201cTable 1\u201d) with the Table 1 in \u00a76.4 and breaks all in-text references.',
        suggestion: 'Drop the inserted caption or renumber subsequent tables.' },
      { segment_id: 14, category: 'Accuracy', subcategory: 'Mistranslation', severity: 'major',
        source_span: '\u0443\u0445\u0443\u0434\u0448\u0430\u0435\u0442\u0441\u044f \u0441 1.3\u00d7 \u0434\u043e 1.5\u00d7', target_span: 'DEGRADES from 1.3\u00d7 to 1.5\u00d7',
        description: '1.5\u00d7 speedup is larger than 1.3\u00d7, so \u201cdegrades\u201d is internally contradictory. The Russian uses \u201c\u0443\u0445\u0443\u0434\u0448\u0430\u0435\u0442\u0441\u044f\u201d in an ironic register that the translator mis-reads.',
        suggestion: 'improves from 1.3\u00d7 to 1.5\u00d7' },
      { segment_id: 3, category: 'Accuracy', subcategory: 'Addition', severity: 'major',
        source_span: '\u0441\u0432\u0435\u0440\u0445\u0430\u0434\u0434\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438', target_span: 'super-additive gain in convergence speed without degradation of accuracy',
        description: 'The clause \u201cwithout degradation of accuracy\u201d is not in the source and changes the abstract\'s claim.',
        suggestion: 'super-additive gain in convergence speed' },
      { segment_id: 4, category: 'Style', subcategory: 'Unidiomatic', severity: 'minor',
        source_span: '\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u043e\u0439', target_span: 'has emerged as a foundational paradigm',
        description: 'Double shift: tense (present \u2192 present-perfect) and intensifier (\u201ckey\u201d \u2192 \u201cfoundational\u201d). Both are over-statements.',
        suggestion: 'is a key paradigm' },
      { segment_id: 5, category: 'Style', subcategory: 'Unidiomatic', severity: 'minor',
        source_span: '\u0442\u0435\u0440\u044f\u044f \u0434\u043e 60% wall-clock \u0432\u0440\u0435\u043c\u0435\u043d\u0438', target_span: 'wasting up to 60% of wall-clock time',
        description: '\u201cWasting\u201d carries a moral overtone absent from the neutral source verb \u201c\u0442\u0435\u0440\u044f\u0442\u044c\u201d (to lose). \u201cLosing\u201d is more accurate.',
        suggestion: 'losing up to 60% of wall-clock time' },
      { segment_id: 6, category: 'Terminology', subcategory: 'Wrong term', severity: 'minor',
        source_span: '\u0423\u0447\u0451\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0433\u0435\u0442\u0435\u0440.', target_span: 'System Heterogeneity',
        description: 'The table column header drops \u201c\u0443\u0447\u0451\u0442\u201d (awareness/consideration). The other columns in the table also use the \u201cawareness\u201d framing.',
        suggestion: 'System Heterogeneity Awareness' },
      { segment_id: 8, category: 'Accuracy', subcategory: 'Addition', severity: 'minor',
        source_span: '\u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0443\u043c', target_span: 'stochastic gradient noise',
        description: 'Added \u201cgradient\u201d \u2014 defensible from context but formally an addition.',
        suggestion: 'stochastic noise' },
      { segment_id: 9, category: 'Style', subcategory: 'Awkward', severity: 'minor',
        source_span: '\u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 grid search', target_span: 'selected via grid search',
        description: 'Omitted \u201c\u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435\u201d (in practice).',
        suggestion: 'in practice, selected via grid search' },
      { segment_id: 10, category: 'Terminology', subcategory: 'Wrong term', severity: 'minor',
        source_span: '\u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u0430\u043d\u044b', target_span: 'fitted',
        description: '\u201cCalibration\u201d and \u201cfitting\u201d are distinct statistical procedures.',
        suggestion: 'calibrated against' },
      { segment_id: 11, category: 'Style', subcategory: 'Unidiomatic', severity: 'minor',
        source_span: '\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438', target_span: 'For correctness',
        description: 'Literal rendering; idiomatic English research usage is \u201cfor fairness\u201d.',
        suggestion: 'For fairness' },
      { segment_id: 12, category: 'Design / Markup', subcategory: 'Formatting', severity: 'minor',
        source_span: '\u0422\u0430\u0431\u043b\u0438\u0446\u0430 1.', target_span: 'Table 1.',
        description: 'Conflicts with the table inserted in \u00a71.2 (see seg #7). Should be Table 5 after renumbering.',
        suggestion: 'Table 5.' },
      { segment_id: 13, category: 'Style', subcategory: 'Unidiomatic', severity: 'minor',
        source_span: '\u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442', target_span: 'the strongest competitor',
        description: '\u201c\u0411\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439\u201d means closest-in-performance, not strongest.',
        suggestion: 'the closest competitor' },
      { segment_id: 15, category: 'Style', subcategory: 'Unidiomatic', severity: 'minor',
        source_span: '\u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0441\u043d\u0438\u043c\u0430\u0435\u0442', target_span: 'partially addresses',
        description: '\u201c\u0421\u043d\u0438\u043c\u0430\u0435\u0442\u201d is stronger than \u201caddresses\u201d; \u201cmitigates\u201d matches.',
        suggestion: 'partially mitigates' },
      { segment_id: 16, category: 'Style', subcategory: 'Unidiomatic', severity: 'minor',
        source_span: '\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435', target_span: 'Integration',
        description: '\u201c\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u201d = inclusion. \u201cIntegration\u201d implies deeper interleaving than the source.',
        suggestion: 'Inclusion \u2026 under' },
    ],

    corrected_full_text: '(Demo project \u2014 full corrected text omitted; use Download .docx after a real run.)',
  },
};

// Compute metrics + lev distance for the demo so the Results screen renders correctly.
(function compute() {
  const data = window.__APE_DEMO_PROJECT.data;
  const counts = { critical: 0, major: 0, minor: 0 };
  let penalty = 0;
  for (const e of data.errors) {
    const sev = (e.severity || 'minor').toLowerCase();
    counts[sev]++; penalty += window.SEVERITY_WEIGHTS[sev];
  }
  const dimCounts = {};
  window.MQM_DIMENSIONS.forEach((d) => { dimCounts[d.label] = 0; });
  for (const e of data.errors) {
    if (dimCounts[e.category] !== undefined) dimCounts[e.category]++;
  }
  const wc = data.source_word_count;
  data.metrics = {
    counts, penalty,
    quality_score: Math.max(0, (1 - penalty / wc) * 100),
    source_word_count: wc,
    dimension_counts: dimCounts,
  };
  for (const seg of data.segments) {
    const a = seg.target || '', b = seg.corrected || '';
    if (a && b && a !== b) {
      seg.lev_distance = window.levenshtein(a, b);
      seg.lev_norm = seg.lev_distance / Math.max(a.length, b.length);
    } else { seg.lev_distance = 0; seg.lev_norm = 0; }
  }
})();
