Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF-2900 Mixed Source: Selecting books from each source #2825

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ describe('DraftGenerationStepsComponent', () => {
component.tryAdvanceStep();

expect(component.done.emit).toHaveBeenCalledWith({
translationBooks,
trainingDataFiles,
trainingBooks: trainingBooks.filter(book => !translationBooks.includes(book)),
trainingDataFiles,
trainingScriptureRanges: [],
translationBooks,
translationScriptureRanges: [],
fastTraining: false
} as DraftGenerationStepsResult);
});
Expand Down Expand Up @@ -330,7 +332,9 @@ describe('DraftGenerationStepsComponent', () => {
expect(component.done.emit).toHaveBeenCalledWith({
trainingBooks,
trainingDataFiles,
trainingScriptureRanges: [],
translationBooks,
translationScriptureRanges: [],
fastTraining: true
} as DraftGenerationStepsResult);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { TrainingDataDoc } from '../../../core/models/training-data-doc';
import { BookMultiSelectComponent } from '../../../shared/book-multi-select/book-multi-select.component';
import { SharedModule } from '../../../shared/shared.module';
import { NllbLanguageService } from '../../nllb-language.service';
import { ProjectScriptureRange } from '../draft-generation';
import { DraftSource, DraftSourcesService } from '../draft-sources.service';
import { TrainingDataMultiSelectComponent } from '../training-data/training-data-multi-select.component';
import { TrainingDataUploadDialogComponent } from '../training-data/training-data-upload-dialog.component';
Expand All @@ -26,8 +27,10 @@ export interface DraftGenerationStepsResult {
trainingBooks: number[];
trainingDataFiles: string[];
trainingScriptureRange?: string;
trainingScriptureRanges: ProjectScriptureRange[];
translationBooks: number[];
translationScriptureRange?: string;
translationScriptureRanges: ProjectScriptureRange[];
fastTraining: boolean;
}

Expand Down Expand Up @@ -248,8 +251,10 @@ export class DraftGenerationStepsComponent extends SubscriptionDisposable implem
} else {
this.done.emit({
trainingBooks: this.userSelectedTrainingBooks,
trainingScriptureRanges: [],
trainingDataFiles: this.selectedTrainingDataIds,
translationBooks: this.userSelectedTranslateBooks,
translationScriptureRanges: [],
fastTraining: this.fastTraining
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1749,15 +1749,19 @@ describe('DraftGenerationComponent', () => {
env.component.startBuild({
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false,
projectId: projectId
});
expect(mockDraftGenerationService.startBuildOrGetActiveBuild).toHaveBeenCalledWith({
projectId: projectId,
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false
});
});
Expand All @@ -1775,15 +1779,19 @@ describe('DraftGenerationComponent', () => {
env.component.startBuild({
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false,
projectId: projectId
});
expect(mockDraftGenerationService.startBuildOrGetActiveBuild).toHaveBeenCalledWith({
projectId: projectId,
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false
});
verify(mockDialogRef.getState()).never();
Expand All @@ -1803,15 +1811,19 @@ describe('DraftGenerationComponent', () => {
env.component.startBuild({
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false,
projectId: projectId
});
expect(mockDraftGenerationService.startBuildOrGetActiveBuild).toHaveBeenCalledWith({
projectId: projectId,
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false
});
verify(mockDialogRef.getState()).never();
Expand All @@ -1831,15 +1843,19 @@ describe('DraftGenerationComponent', () => {
env.component.startBuild({
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false,
projectId: projectId
});
expect(mockDraftGenerationService.startBuildOrGetActiveBuild).toHaveBeenCalledWith({
projectId: projectId,
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false
});
verify(mockDialogRef.getState()).never();
Expand All @@ -1860,15 +1876,19 @@ describe('DraftGenerationComponent', () => {
env.component.startBuild({
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false,
projectId: projectId
});
expect(mockDraftGenerationService.startBuildOrGetActiveBuild).toHaveBeenCalledWith({
projectId: projectId,
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false
});
verify(mockDialogRef.close()).once();
Expand All @@ -1884,7 +1904,9 @@ describe('DraftGenerationComponent', () => {
env.component.startBuild({
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false,
projectId: projectId
});
Expand All @@ -1894,7 +1916,9 @@ describe('DraftGenerationComponent', () => {
projectId: projectId,
trainingBooks: [],
trainingDataFiles: [],
trainingScriptureRanges: [],
translationBooks: [],
translationScriptureRanges: [],
fastTraining: false
});
expect(mockAuthService.requestParatextCredentialUpdate).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,10 @@ export class DraftGenerationComponent extends DataLoadingComponent implements On
trainingBooks: result.trainingBooks,
trainingDataFiles: result.trainingDataFiles,
trainingScriptureRange: result.trainingScriptureRange,
trainingScriptureRanges: result.trainingScriptureRanges,
translationBooks: result.translationBooks,
translationScriptureRange: result.translationScriptureRange,
translationScriptureRanges: result.trainingScriptureRanges,
fastTraining: result.fastTraining
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ describe('DraftGenerationService', () => {
projectId,
trainingBooks: [],
trainingDataFiles: [],
translationScriptureRanges: [],
translationBooks: [],
trainingScriptureRanges: [],
fastTraining: false
};
const buildDto: BuildDto = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { InjectionToken } from '@angular/core';
import { BuildStates } from '../../machine-api/build-states';

/*
/**
* The build configuration for a pre-translation build.
*/
export interface BuildConfig {
projectId: string;
trainingBooks: number[];
trainingDataFiles: string[];
trainingScriptureRange?: string;
trainingScriptureRanges: ProjectScriptureRange[];
translationBooks: number[];
translationScriptureRange?: string;
translationScriptureRanges: ProjectScriptureRange[];
fastTraining: boolean;
}

/**
* A per-project scripture range.
*/
export interface ProjectScriptureRange {
projectId: string;
scriptureRange: string;
}

/**
* Dictionary of 'segmentRef -> segment text'.
*/
Expand Down
20 changes: 20 additions & 0 deletions src/SIL.XForge.Scripture/Models/BuildConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BuildConfig
/// </summary>
/// <value>The numbers of the books to use as the source texts for training.</value>
/// <remarks>
/// This property is for legacy client use.
/// You should not set this property and <see cref="TrainingScriptureRange"/> at the same time.
/// </remarks>
public HashSet<int> TrainingBooks { get; set; } = [];
Expand All @@ -34,16 +35,26 @@ public class BuildConfig
/// </summary>
/// <value>The book ids and chapter numbers separated by semicolons.</value>
/// <remarks>
/// This property is for legacy client use.
/// See https://github.com/sillsdev/serval/wiki/Filtering-Paratext-Project-Data-with-a-Scripture-Range for syntax.
/// You should not set this property and <see cref="TrainingBooks"/> at the same time.
/// </remarks>
public string? TrainingScriptureRange { get; set; }

/// <summary>
/// Gets or sets the per-project books and chapters to use for training.
/// </summary>
/// <value>
/// A list containing the project identifiers and scripture ranges.
/// </value>
public HashSet<ProjectScriptureRange> TrainingScriptureRanges { get; set; } = [];

/// <summary>
/// Gets or sets the books to use for translation.
/// </summary>
/// <value>The numbers of the books to use as the source texts for training.</value>
/// <remarks>
/// This property is for legacy client use.
/// You should not set this property and <see cref="TranslationScriptureRange"/> at the same time.
/// </remarks>
public HashSet<int> TranslationBooks { get; set; } = [];
Expand All @@ -53,11 +64,20 @@ public class BuildConfig
/// </summary>
/// <value>The book ids and chapter numbers separated by semicolons.</value>
/// <remarks>
/// This property is for legacy client use.
/// See https://github.com/sillsdev/serval/wiki/Filtering-Paratext-Project-Data-with-a-Scripture-Range for syntax.
/// You should not set this property and <see cref="TranslationBooks"/> at the same time.
/// </remarks>
public string? TranslationScriptureRange { get; set; }

/// <summary>
/// Gets or sets the per-project books and chapters to use for training.
/// </summary>
/// <value>
/// A list containing the project identifiers and scripture ranges.
/// </value>
public HashSet<ProjectScriptureRange> TranslationScriptureRanges { get; set; } = [];

/// <summary>
/// Gets or sets the project identifier.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/SIL.XForge.Scripture/Models/DraftConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ public class DraftConfig
public TranslateSource? AlternateTrainingSource { get; set; }
public IList<int> LastSelectedTrainingBooks { get; set; } = [];
public string? LastSelectedTrainingScriptureRange { get; set; }
public IList<ProjectScriptureRange> LastSelectedTrainingScriptureRanges { get; set; } = [];
public IList<string> LastSelectedTrainingDataFiles { get; set; } = [];
public IList<int> LastSelectedTranslationBooks { get; set; } = [];
public string? LastSelectedTranslationScriptureRange { get; set; }
public IList<ProjectScriptureRange> LastSelectedTranslationScriptureRanges { get; set; } = [];
public string? ServalConfig { get; set; }
}
22 changes: 22 additions & 0 deletions src/SIL.XForge.Scripture/Models/ProjectScriptureRange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SIL.XForge.Scripture.Models;

/// <summary>
/// A scripture range for a specific project.
/// This is used by <see cref="BuildConfig"/>.
/// </summary>
public record ProjectScriptureRange
{
/// <summary>
/// The project identifier.
/// </summary>
public string ProjectId { get; set; } = string.Empty;

/// <summary>
/// The scripture range.
/// </summary>
/// <value>The book ids and chapter numbers separated by semicolons.</value>
/// <remarks>
/// See https://github.com/sillsdev/serval/wiki/Filtering-Paratext-Project-Data-with-a-Scripture-Range for syntax.
/// </remarks>
public string ScriptureRange { get; set; } = string.Empty;
}
32 changes: 32 additions & 0 deletions src/SIL.XForge.Scripture/Models/ServalAdditionalTrainingData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;

namespace SIL.XForge.Scripture.Models;

/// <summary>
/// Configuration for uploading Additional Training Data to Serval.
/// </summary>
public class ServalAdditionalTrainingData
{
/// <summary>
/// Gets or sets the Parallel Corpus identifier.
/// </summary>
public string ParallelCorpusId { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the identifier of the corpus to be used as the source in the Parallel Corpus.
/// </summary>
public string SourceCorpusId { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the identifier of the corpus to be used as the target in the Parallel Corpus.
/// </summary>
public string TargetCorpusId { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the corpus files uploaded to Serval.
/// </summary>
/// <value>
/// The files in both the source and target corpora.
/// </value>
public List<ServalCorpusFile> CorpusFiles { get; set; } = [];
}
4 changes: 2 additions & 2 deletions src/SIL.XForge.Scripture/Models/ServalCorpus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public class ServalCorpus
/// <value>
/// The source corpus files.
/// </value>
public List<ServalCorpusFile> SourceFiles { get; set; } = new List<ServalCorpusFile>();
public List<ServalCorpusFile> SourceFiles { get; set; } = [];

/// <summary>
/// Gets or sets the target files uploaded to Serval.
/// </summary>
/// <value>
/// The target corpus files.
/// </value>
public List<ServalCorpusFile> TargetFiles { get; set; } = new List<ServalCorpusFile>();
public List<ServalCorpusFile> TargetFiles { get; set; } = [];
}
Loading
Loading