Implements detect-redact-sanitize pipeline with regex, domain rules, and ONNX NER before the LLM boundary, plus NUnit tests and Xenovex push documentation. Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.0 KiB
C#
52 lines
1.0 KiB
C#
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)
|
|
|
|
{
|
|
|
|
var entities = Runner.PredictEntities(prompt);
|
|
|
|
|
|
|
|
entities.Should().Contain(entity =>
|
|
|
|
entity.Type == PiiEntityType.Person &&
|
|
|
|
entity.Source == PiiDetectionSource.Ner &&
|
|
|
|
entity.Value.Contains(expectedNamePart, StringComparison.Ordinal) &&
|
|
|
|
prompt.AsSpan(entity.StartIndex, entity.Length).ToString() == entity.Value);
|
|
|
|
|
|
|
|
entities.Should().Contain(entity => entity.Value == expectedValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|