示例#1
0
        private void ValidateSummaryDocumentResult(SummarySentenceCollection sentences, SummarySentencesOrder expectedOrder)
        {
            Assert.IsNotNull(sentences.Warnings);
            Assert.LessOrEqual(sentences.Count, ExtractSummaryMaxSentenceCount);

            for (int i = 0; i < sentences.Count; i++)
            {
                SummarySentence sentence = sentences[i];

                Assert.True(s_extractSummaryBatchConvenienceDocuments.Any(document => document.Contains(sentence.Text)));
                Assert.GreaterOrEqual(sentence.Offset, 0);
                Assert.GreaterOrEqual(sentence.RankScore, 0.0);
                Assert.LessOrEqual(sentence.RankScore, 1.0);
                Assert.AreEqual(sentence.Text.Length, sentence.Length);

                if (i > 0)
                {
                    SummarySentence previousSentence = sentences[i - 1];

                    if (expectedOrder == SummarySentencesOrder.Offset)
                    {
                        Assert.Greater(sentence.Offset, previousSentence.Offset);
                    }
                    else if (expectedOrder == SummarySentencesOrder.Rank)
                    {
                        Assert.LessOrEqual(sentence.RankScore, previousSentence.RankScore);
                    }
                }
            }
        }
示例#2
0
        private void ValidateSummaryBatchResult(ExtractSummaryResultCollection results, SummarySentencesOrder expectedOrder = SummarySentencesOrder.Offset, bool includeStatistics = false)
        {
            Assert.That(results.ModelVersion, Is.Not.Null.And.Not.Empty);

            if (includeStatistics)
            {
                Assert.IsNotNull(results.Statistics);
                Assert.Greater(results.Statistics.DocumentCount, 0);
                Assert.Greater(results.Statistics.TransactionCount, 0);
                Assert.GreaterOrEqual(results.Statistics.InvalidDocumentCount, 0);
                Assert.GreaterOrEqual(results.Statistics.ValidDocumentCount, 0);
            }
            else
            {
                Assert.IsNull(results.Statistics);
            }

            foreach (ExtractSummaryResult result in results)
            {
                Assert.That(result.Id, Is.Not.Null.And.Not.Empty);
                Assert.False(result.HasError);

                if (includeStatistics)
                {
                    Assert.GreaterOrEqual(result.Statistics.CharacterCount, 0);
                    Assert.Greater(result.Statistics.TransactionCount, 0);
                }
                else
                {
                    Assert.AreEqual(0, result.Statistics.CharacterCount);
                    Assert.AreEqual(0, result.Statistics.TransactionCount);
                }

                ValidateSummaryDocumentResult(result.Sentences, expectedOrder);
            }
        }
 public static string ToSerialString(this SummarySentencesOrder value) => value switch
 {