diff --git a/src/SIL.Machine.AspNetCore/Services/ClearMLService.cs b/src/SIL.Machine.AspNetCore/Services/ClearMLService.cs index 2805e9612..b7022dd6b 100644 --- a/src/SIL.Machine.AspNetCore/Services/ClearMLService.cs +++ b/src/SIL.Machine.AspNetCore/Services/ClearMLService.cs @@ -97,7 +97,7 @@ public async Task 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"; diff --git a/src/SIL.Machine.AspNetCore/Services/SmtTransferEngineBuildJob.cs b/src/SIL.Machine.AspNetCore/Services/SmtTransferEngineBuildJob.cs index 5edc3ac57..6ad7ab411 100644 --- a/src/SIL.Machine.AspNetCore/Services/SmtTransferEngineBuildJob.cs +++ b/src/SIL.Machine.AspNetCore/Services/SmtTransferEngineBuildJob.cs @@ -43,7 +43,6 @@ CancellationToken cancellationToken ) { IDistributedReaderWriterLock rwLock = await _lockFactory.CreateAsync(engineId, cancellationToken); - var tokenizer = new LatinWordTokenizer(); var detokenizer = new LatinWordDetokenizer(); ITrainer? smtModelTrainer = null; diff --git a/src/SIL.Machine/Corpora/CorpusAlignmentException.cs b/src/SIL.Machine/Corpora/CorpusAlignmentException.cs new file mode 100644 index 000000000..c86dd8cfd --- /dev/null +++ b/src/SIL.Machine/Corpora/CorpusAlignmentException.cs @@ -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." + ) { } + } +} diff --git a/src/SIL.Machine/Corpora/ParallelTextCorpus.cs b/src/SIL.Machine/Corpora/ParallelTextCorpus.cs index ac743933a..31baf1b79 100644 --- a/src/SIL.Machine/Corpora/ParallelTextCorpus.cs +++ b/src/SIL.Machine/Corpora/ParallelTextCorpus.cs @@ -94,7 +94,18 @@ public IEnumerable 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) @@ -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 ( @@ -378,9 +399,15 @@ private IEnumerable CreateRows( private bool CheckSameRefRows(List 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; }