Skip to content

Commit f293da2

Browse files
committed
Add save functionality for WA; small bug in NPTC
1 parent eb763b0 commit f293da2

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/SIL.Machine.Translation.Thot/ThotWordAlignmentModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Linq;
66
using System.Runtime.InteropServices;
7+
using System.Threading;
78
using System.Threading.Tasks;
89
using SIL.Extensions;
910
using SIL.Machine.Corpora;
@@ -141,7 +142,7 @@ public ITrainer CreateTrainer(IParallelTextCorpus corpus, ITokenizer<string, int
141142
return trainer;
142143
}
143144

144-
public Task SaveAsync()
145+
public Task SaveAsync(CancellationToken cancellationToken = default)
145146
{
146147
CheckDisposed();
147148

src/SIL.Machine/Corpora/NParallelTextCorpus.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ NParallelTextRow row in CreateMinRefRows(
217217

218218
for (int i = 0; i < rangeInfo.Rows.Count; i++)
219219
{
220+
if (completed[i])
221+
continue;
220222
rangeInfo.AddTextRow(currentRows[i], i);
221223
sameRefRows[i].Clear();
222224
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
using SIL.Machine.Corpora;
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using SIL.Machine.Corpora;
24

35
namespace SIL.Machine.Translation
46
{
57
public interface IWordAlignmentModel : IWordAlignmentEngine
68
{
79
ITrainer CreateTrainer(IParallelTextCorpus corpus);
10+
Task SaveAsync(CancellationToken cancellationToken = default);
11+
void Save();
812
}
913
}

src/SIL.Machine/Translation/SymmetrizedWordAlignmentModel.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using SIL.Machine.Corpora;
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using SIL.Machine.Corpora;
24

35
namespace SIL.Machine.Translation
46
{
@@ -27,6 +29,20 @@ public ITrainer CreateTrainer(IParallelTextCorpus corpus)
2729
return new SymmetrizedWordAlignmentModelTrainer(directTrainer, inverseTrainer);
2830
}
2931

32+
public void Save()
33+
{
34+
CheckDisposed();
35+
_directWordAlignmentModel.Save();
36+
_inverseWordAlignmentModel.Save();
37+
}
38+
39+
public async Task SaveAsync(CancellationToken cancellationToken = default)
40+
{
41+
CheckDisposed();
42+
await _directWordAlignmentModel.SaveAsync(cancellationToken);
43+
await _inverseWordAlignmentModel.SaveAsync(cancellationToken);
44+
}
45+
3046
protected override void DisposeManagedResources()
3147
{
3248
_directWordAlignmentModel.Dispose();

0 commit comments

Comments
 (0)