-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SF-2986 Add step to confirm language codes before generating draft
- Loading branch information
Showing
8 changed files
with
299 additions
and
6 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...ientApp/src/app/translate/draft-generation/confirm-sources/confirm-sources.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<h1 class="mat-headline-4">Confirm project setup</h1> | ||
<h2>Training the language model</h2> | ||
<div class="training-data"> | ||
<div class="source-description"> | ||
<h3>References</h3> | ||
<p>These are in the source language for the translation model.</p> | ||
</div> | ||
<span class="gap"></span> | ||
<div class="target-description"> | ||
<h3>Translation project</h3> | ||
<p>These are in the receptor language you are translating into.</p> | ||
</div> | ||
<div class="sources"> | ||
@for (project of trainingSources; track project.paratextId) { | ||
<div class="project"> | ||
<span class="project-name">{{ project.name }}</span> | ||
<span> | ||
Language code: <strong>{{ project.writingSystem.tag }}</strong> | ||
</span> | ||
</div> | ||
} | ||
</div> | ||
<span class="arrow"><mat-icon>arrow_right_alt</mat-icon></span> | ||
<div class="targets"> | ||
@for (project of trainingTargets; track project.paratextId) { | ||
<div class="project"> | ||
<span class="project-name">{{ project.name }}</span> | ||
<span> | ||
Language code: <strong>{{ project.writingSystem.tag }}</strong> | ||
</span> | ||
</div> | ||
} | ||
</div> | ||
</div> | ||
|
||
<h2>Drafting from</h2> | ||
<p class="translation-data-description">This is the text that will be translated by the language model.</p> | ||
<div class="translation-data"> | ||
@for (project of draftingSources; track project.paratextId) { | ||
<div class="project"> | ||
<span class="project-name">{{ project.name }}</span> | ||
<span> | ||
Language code: <strong>{{ project.writingSystem.tag }}</strong> | ||
</span> | ||
</div> | ||
} | ||
</div> | ||
|
||
<app-notice mode="fill-dark"> | ||
<strong>Incorrect language codes will dramatically reduce draft quality.</strong> | ||
<p>Language codes can be changed in Paratext by going to Project Settings > Project Properties > Language.</p> | ||
<mat-checkbox (change)="confirmationChanged($event)">All the language codes are correct.</mat-checkbox> | ||
</app-notice> |
79 changes: 79 additions & 0 deletions
79
...ientApp/src/app/translate/draft-generation/confirm-sources/confirm-sources.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
.training-data { | ||
display: grid; | ||
grid-template-areas: '. . .' '. . .'; | ||
row-gap: 1em; | ||
} | ||
|
||
.gap, | ||
.arrow { | ||
padding-inline: 2em; | ||
} | ||
|
||
.sources, | ||
.targets, | ||
.arrow { | ||
background: #f0f0f0; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
padding-block: 1em; | ||
gap: 1em; | ||
} | ||
|
||
.source-description, | ||
.sources, | ||
.translation-data-description, | ||
.translation-data { | ||
padding-inline-start: 1em; | ||
} | ||
|
||
.target-description, | ||
.targets { | ||
padding-inline-end: 1em; | ||
} | ||
|
||
.source-description p, | ||
.target-description p, | ||
.translation-data-description { | ||
font-style: italic; | ||
font-size: 0.95em; | ||
} | ||
|
||
.training-data h3 { | ||
margin-block: 0 0.5em; | ||
} | ||
|
||
.training-data p { | ||
margin: 0; | ||
} | ||
|
||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
strong { | ||
font-weight: 500; | ||
} | ||
|
||
h1 { | ||
margin-bottom: 0; | ||
} | ||
|
||
h2 { | ||
margin-top: 2em; | ||
} | ||
|
||
.project { | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: 0.25em; | ||
} | ||
|
||
.project-name { | ||
font-size: 1.1em; | ||
font-weight: 500; | ||
} | ||
|
||
.translation-data { | ||
margin-bottom: 2.5em; | ||
} |
58 changes: 58 additions & 0 deletions
58
...ClientApp/src/app/translate/draft-generation/confirm-sources/confirm-sources.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Component, EventEmitter, Output } from '@angular/core'; | ||
import { MatCheckboxChange, MatCheckboxModule } from '@angular/material/checkbox'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { TranslocoModule } from '@ngneat/transloco'; | ||
import { SFProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project'; | ||
import { TranslateSource } from 'realtime-server/lib/esm/scriptureforge/models/translate-config'; | ||
import { ActivatedProjectService } from '../../../../xforge-common/activated-project.service'; | ||
import { NoticeComponent } from '../../../shared/notice/notice.component'; | ||
|
||
@Component({ | ||
selector: 'app-confirm-sources', | ||
standalone: true, | ||
imports: [TranslocoModule, NoticeComponent, MatCheckboxModule, MatIconModule], | ||
templateUrl: './confirm-sources.component.html', | ||
styleUrl: './confirm-sources.component.scss' | ||
}) | ||
export class ConfirmSourcesComponent { | ||
@Output() languageCodesVerified = new EventEmitter<boolean>(false); | ||
|
||
trainingSources: TranslateSource[] = []; | ||
trainingTargets: SFProjectProfile[] = []; | ||
draftingSources: TranslateSource[] = []; | ||
|
||
constructor(activatedProjectService: ActivatedProjectService) { | ||
const project = activatedProjectService.projectDoc!.data!; | ||
this.trainingTargets.push(project); | ||
|
||
let trainingSource: TranslateSource | undefined; | ||
if (project.translateConfig.draftConfig.alternateTrainingSourceEnabled) { | ||
trainingSource = project.translateConfig.draftConfig.alternateTrainingSource; | ||
} else { | ||
trainingSource = project.translateConfig.source; | ||
} | ||
|
||
if (trainingSource != null) { | ||
this.trainingSources.push(trainingSource); | ||
} | ||
|
||
if (project.translateConfig.draftConfig.additionalTrainingSourceEnabled) { | ||
this.trainingSources.push(project.translateConfig.draftConfig.additionalTrainingSource!); | ||
} | ||
|
||
let draftingSource: TranslateSource | undefined; | ||
if (project.translateConfig.draftConfig.alternateSourceEnabled) { | ||
draftingSource = project.translateConfig.draftConfig.alternateSource; | ||
} else { | ||
draftingSource = project.translateConfig.source; | ||
} | ||
|
||
if (draftingSource != null) { | ||
this.draftingSources.push(draftingSource); | ||
} | ||
} | ||
|
||
confirmationChanged(change: MatCheckboxChange): void { | ||
this.languageCodesVerified.emit(change.checked); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...e/ClientApp/src/app/translate/draft-generation/confirm-sources/confirm-sources.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { TranslocoModule } from '@ngneat/transloco'; | ||
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular'; | ||
// import { I18nStoryModule } from '../../../../xforge-common/i18n-story.module'; | ||
// import { UICommonModule } from '../../../../xforge-common/ui-common.module'; | ||
import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data'; | ||
import { instance, mock, when } from 'ts-mockito'; | ||
import { ActivatedProjectService } from '../../../../xforge-common/activated-project.service'; | ||
import { SFProjectProfileDoc } from '../../../core/models/sf-project-profile-doc'; | ||
import { ConfirmSourcesComponent } from './confirm-sources.component'; | ||
|
||
const mockedActivatedProjectService = mock(ActivatedProjectService); | ||
|
||
when(mockedActivatedProjectService.projectDoc).thenReturn({ | ||
data: createTestProjectProfile({ | ||
name: 'Test Project', | ||
translateConfig: { | ||
source: { | ||
projectRef: 'source-project', | ||
shortName: 'SP', | ||
name: 'THIS PROJECT SHOULD NOT BE SHOWN!!!!!****', | ||
paratextId: 'source-project', | ||
writingSystem: { tag: 'es' } | ||
}, | ||
draftConfig: { | ||
alternateTrainingSourceEnabled: true, | ||
alternateTrainingSource: { | ||
projectRef: 'alternate-training-source', | ||
shortName: 'ATS', | ||
name: 'Alternate Training Source', | ||
paratextId: 'alternate-training-source', | ||
writingSystem: { tag: 'es' } | ||
}, | ||
additionalTrainingSourceEnabled: true, | ||
additionalTrainingSource: { | ||
projectRef: 'additional-training-source', | ||
shortName: 'ATS', | ||
name: 'Additional Training Source', | ||
paratextId: 'additional-training-source', | ||
writingSystem: { tag: 'es' } | ||
}, | ||
alternateSourceEnabled: true, | ||
alternateSource: { | ||
projectRef: 'alternate-drafting-source', | ||
shortName: 'ADS', | ||
name: 'Alternate Drafting Source', | ||
paratextId: 'alternate-drafting-source', | ||
writingSystem: { tag: 'es' } | ||
} | ||
} | ||
} | ||
}) | ||
} as SFProjectProfileDoc); | ||
|
||
const meta: Meta = { | ||
title: 'Translate/ConfirmSources', | ||
component: ConfirmSourcesComponent, | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [CommonModule, TranslocoModule], | ||
providers: [{ provide: ActivatedProjectService, useValue: instance(mockedActivatedProjectService) }] | ||
}) | ||
] | ||
}; | ||
|
||
export default meta; | ||
|
||
interface StoryState {} | ||
|
||
type Story = StoryObj<StoryState>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
book: 1, | ||
progress: 0.37, | ||
hues: [0] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...p/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
:host { | ||
display: block; | ||
max-width: 80em; | ||
} | ||
|
||
.stepper-multi-header { | ||
h2, | ||
h3 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters