Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/SIL.Machine.AspNetCore/Services/ClearMLService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task<string> CreateTaskAsync(
+ $" 'trg_lang': '{ConvertLanguageTag(targetLanguageTag)}',\n"
+ $" 'max_steps': {_options.CurrentValue.MaxSteps},\n"
+ $" 'shared_file_uri': '{sharedFileUri}',\n"
+ $" 'clearml': True\n"
+ $" 'clearml': True,\n"
+ "}\n"
+ "run(args)\n";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ CancellationToken cancellationToken
)
{
IDistributedReaderWriterLock rwLock = await _lockFactory.CreateAsync(engineId, cancellationToken);

var tokenizer = new LatinWordTokenizer();
var detokenizer = new LatinWordDetokenizer();
ITrainer? smtModelTrainer = null;
Expand Down
12 changes: 12 additions & 0 deletions src/SIL.Machine/Corpora/CorpusAlignmentException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace SIL.Machine.Corpora
{
public class CorpusAlignmentException : Exception
{
public CorpusAlignmentException(string sourceRef, string targetRef)
: base(
$"Invalid format in {sourceRef} and {targetRef}. Mismatched key formats \"{sourceRef}\" and \"{targetRef}\". There may be an extraneous tab, missing ref, or inconsistent use of user-defined refs."
) { }
}
}
41 changes: 34 additions & 7 deletions src/SIL.Machine/Corpora/ParallelTextCorpus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,18 @@ public IEnumerable<ParallelTextRow> GetRows()
bool trgCompleted = !trgEnumerator.MoveNext();
while (!srcCompleted && !trgCompleted)
{
int compare1 = RowRefComparer.Compare(srcEnumerator.Current.Ref, trgEnumerator.Current.Ref);
int compare1 = 0;
try
{
compare1 = RowRefComparer.Compare(srcEnumerator.Current.Ref, trgEnumerator.Current.Ref);
}
catch (ArgumentException)
{
throw new CorpusAlignmentException(
srcEnumerator.Current.Ref.ToString(),
trgEnumerator.Current.Ref.ToString()
);
}
if (compare1 < 0)
{
if (!AllTargetRows && srcEnumerator.Current.IsInRange)
Expand Down Expand Up @@ -176,9 +187,19 @@ ParallelTextRow row in CreateTargetRows(
int compare2;
do
{
compare2 = alignmentEnumerator.MoveNext()
? RowRefComparer.Compare(srcEnumerator.Current.Ref, alignmentEnumerator.Current.Ref)
: 1;
try
{
compare2 = alignmentEnumerator.MoveNext()
? RowRefComparer.Compare(srcEnumerator.Current.Ref, alignmentEnumerator.Current.Ref)
: 1;
}
catch (ArgumentException)
{
throw new CorpusAlignmentException(
srcEnumerator.Current.Ref.ToString(),
trgEnumerator.Current.Ref.ToString()
);
}
} while (compare2 < 0);

if (
Expand Down Expand Up @@ -378,9 +399,15 @@ private IEnumerable<ParallelTextRow> CreateRows(

private bool CheckSameRefRows(List<TextRow> sameRefRows, TextRow otherRow)
{
if (sameRefRows.Count > 0 && RowRefComparer.Compare(sameRefRows[0].Ref, otherRow.Ref) != 0)
sameRefRows.Clear();

try
{
if (sameRefRows.Count > 0 && RowRefComparer.Compare(sameRefRows[0].Ref, otherRow.Ref) != 0)
sameRefRows.Clear();
}
catch (ArgumentException)
{
throw new CorpusAlignmentException(sameRefRows[0].Ref.ToString(), otherRow.Ref.ToString());
}
return sameRefRows.Count > 0;
}

Expand Down