From 716bef2e5983159a212d777784ea56f512512a9c Mon Sep 17 00:00:00 2001 From: Zhongkai Fu Date: Fri, 1 Sep 2023 09:57:59 -0700 Subject: [PATCH] Bug fix. --- Seq2SeqSharp/Corpus/MonoCorpus.cs | 9 ++++++--- Seq2SeqSharp/Corpus/ParallelCorpus.cs | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Seq2SeqSharp/Corpus/MonoCorpus.cs b/Seq2SeqSharp/Corpus/MonoCorpus.cs index 136aabc8..c7ec2054 100644 --- a/Seq2SeqSharp/Corpus/MonoCorpus.cs +++ b/Seq2SeqSharp/Corpus/MonoCorpus.cs @@ -344,10 +344,13 @@ public IEnumerator GetEnumerator() { var tgtLine = tgtLines[i]; - if ((100 * batchIdx / m_batchNumInTotal) > currentBatchPercent) + if (m_batchNumInTotal > 0) { - Logger.WriteLine($"Processing batch '{batchIdx}/{m_batchNumInTotal}'."); // The '{i}th' record in this batch is: Target = '{tgtLine}'"); - currentBatchPercent++; + if ((100 * batchIdx / m_batchNumInTotal) > currentBatchPercent) + { + Logger.WriteLine($"Processing batch '{batchIdx}/{m_batchNumInTotal}'."); // The '{i}th' record in this batch is: Target = '{tgtLine}'"); + currentBatchPercent++; + } } SntPair sntPair = new SntPair(tgtLine, tgtLine); diff --git a/Seq2SeqSharp/Corpus/ParallelCorpus.cs b/Seq2SeqSharp/Corpus/ParallelCorpus.cs index 95d9e006..146f242d 100644 --- a/Seq2SeqSharp/Corpus/ParallelCorpus.cs +++ b/Seq2SeqSharp/Corpus/ParallelCorpus.cs @@ -442,10 +442,13 @@ public IEnumerator GetEnumerator() var srcLine = srcLines[i]; var tgtLine = tgtLines[i]; - if ((100 * batchIdx / m_batchNumInTotal) > currentBatchPercent) + if (m_batchNumInTotal > 0) { - Logger.WriteLine($"Processing batch '{batchIdx}/{m_batchNumInTotal}'."); // The '{i}th' record in this batch is: Source = '{srcLine}' Target = '{tgtLine}'"); - currentBatchPercent++; + if ((100 * batchIdx / m_batchNumInTotal) > currentBatchPercent) + { + Logger.WriteLine($"Processing batch '{batchIdx}/{m_batchNumInTotal}'."); // The '{i}th' record in this batch is: Source = '{srcLine}' Target = '{tgtLine}'"); + currentBatchPercent++; + } } SntPair sntPair = new SntPair(srcLine, tgtLine);