2026-07-07 13:05:07 +05:30
|
|
|
using FluentAssertions;
|
|
|
|
|
|
|
|
|
|
using PiiRedaction.Core.Models;
|
|
|
|
|
|
|
|
|
|
using PiiRedaction.Tests.Shared;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace PiiRedaction.Infrastructure.Tests.Onnx;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
|
|
|
|
[Category("RealModel")]
|
|
|
|
|
|
|
|
|
|
public sealed class RealNerModelRunnerTests : RealNerModelFixture
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[TestCase("Customer Ravi Kumar called about billing.", "Ravi", "Ravi Kumar")]
|
|
|
|
|
|
|
|
|
|
[TestCase("Mr. John Smith called about a duplicate debit.", "John", "John Smith")]
|
|
|
|
|
|
|
|
|
|
public void PredictEntities_DetectsPersonWithCorrectSpan(string prompt, string expectedNamePart, string expectedValue)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
2026-07-08 12:18:27 +05:30
|
|
|
var result = Runner.PredictEntities(prompt);
|
|
|
|
|
var entities = result.Entities;
|
2026-07-07 13:05:07 +05:30
|
|
|
|
|
|
|
|
entities.Should().Contain(entity =>
|
|
|
|
|
entity.Type == PiiEntityType.Person &&
|
|
|
|
|
entity.Source == PiiDetectionSource.Ner &&
|
2026-07-08 12:18:27 +05:30
|
|
|
entity.ModelOrigin == NerModelOrigin.English &&
|
2026-07-07 13:05:07 +05:30
|
|
|
entity.Value.Contains(expectedNamePart, StringComparison.Ordinal) &&
|
|
|
|
|
|
|
|
|
|
prompt.AsSpan(entity.StartIndex, entity.Length).ToString() == entity.Value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entities.Should().Contain(entity => entity.Value == expectedValue);
|
2026-07-08 12:18:27 +05:30
|
|
|
result.InvokedModels.Should().Equal(NerModelOrigin.English);
|
2026-07-07 13:05:07 +05:30
|
|
|
}
|
|
|
|
|
}
|