Add Tamil NER routing and WPF test harness for POC validation.
Introduce dual-script ONNX NER routing (English/Tamil/mixed), Tamil console samples and integration tests, model download scripts, and a resizable WPF MVVM harness with click-to-load prompts, batch validation, and runtime-adjustable detection panels.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using PiiRedaction.Core.Abstractions;
|
||||
using PiiRedaction.Core.Configuration;
|
||||
using PiiRedaction.Core.Detection;
|
||||
using PiiRedaction.Core.Redaction;
|
||||
using PiiRedaction.Core.Sanitization;
|
||||
using PiiRedaction.Infrastructure.Onnx;
|
||||
|
||||
namespace PiiRedaction.Core.Tests.TestSupport;
|
||||
|
||||
@@ -10,6 +13,15 @@ public static class ProductionPipelineFactory
|
||||
public static IPromptSanitizer CreateWithRealModel(IOnnxNerModelRunner runner) =>
|
||||
new PromptSanitizer(CreateCompositeDetector(runner), new PlaceholderPiiRedactor());
|
||||
|
||||
public static IPromptSanitizer CreateWithRoutingRealModels(
|
||||
EnglishOnnxNerRunner englishRunner,
|
||||
TamilOnnxNerRunner tamilRunner,
|
||||
IOptions<PiiRedactionOptions>? options = null) =>
|
||||
CreateWithRealModel(new RoutingOnnxNerModelRunner(
|
||||
englishRunner,
|
||||
tamilRunner,
|
||||
options ?? Options.Create(new PiiRedactionOptions { EnableTamilNer = true })));
|
||||
|
||||
public static IPiiDetector CreateCompositeDetector(IOnnxNerModelRunner runner) =>
|
||||
new CompositePiiDetector(
|
||||
[
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using NUnit.Framework;
|
||||
using PiiRedaction.Core.Models;
|
||||
|
||||
namespace PiiRedaction.Core.Tests.TestSupport;
|
||||
|
||||
/// <summary>
|
||||
/// Golden end-to-end scenarios for Tamil script, Tanglish, and mixed-script prompts.
|
||||
/// Uses fake NER spans for person names; regex and domain rules run for real.
|
||||
/// </summary>
|
||||
public static class TamilPromptScenarioCatalog
|
||||
{
|
||||
public static IEnumerable<TestCaseData> AllScenarios()
|
||||
{
|
||||
foreach (var scenario in BuildScenarios())
|
||||
{
|
||||
yield return new TestCaseData(scenario).SetName(scenario.Name);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<PromptScenario> BuildScenarios()
|
||||
{
|
||||
yield return TamilCustomerNameOnly();
|
||||
yield return TamilWithPhonePan();
|
||||
yield return TanglishCustomer();
|
||||
yield return MixedTamilEnglish();
|
||||
yield return TamilFullFinancial();
|
||||
}
|
||||
|
||||
private static PromptScenario TamilCustomerNameOnly() => new(
|
||||
"Tamil_CustomerNameOnly",
|
||||
"வாடிக்கையாளர் ராஜேஷ் குமார் சேமிப்பு கணக்கில் அங்கீகரிக்கப்படாத பரிவர்த்தனைகளைப் புகாரளித்தார்.",
|
||||
"வாடிக்கையாளர் <PERSON_1> சேமிப்பு கணக்கில் அங்கீகரிக்கப்படாத பரிவர்த்தனைகளைப் புகாரளித்தார்.",
|
||||
[PiiEntityType.Person],
|
||||
["ராஜேஷ் குமார்"]);
|
||||
|
||||
private static PromptScenario TamilWithPhonePan() => new(
|
||||
"Tamil_WithPhonePan",
|
||||
"வாடிக்கையாளர் ராஜேஷ் குமார் தொலைபேசி 9876543210 PAN ABCDE1234F.",
|
||||
"வாடிக்கையாளர் <PERSON_1> தொலைபேசி <PHONE_1> PAN <PAN_1>.",
|
||||
[PiiEntityType.Person, PiiEntityType.Phone, PiiEntityType.Pan],
|
||||
["ராஜேஷ் குமார்", "9876543210", "ABCDE1234F"]);
|
||||
|
||||
private static PromptScenario TanglishCustomer() => new(
|
||||
"Tanglish_CustomerPhone",
|
||||
"Customer Senthil phone 9876543210 reported a failed UPI transfer.",
|
||||
"Customer <PERSON_1> phone <PHONE_1> reported a failed UPI transfer.",
|
||||
[PiiEntityType.Person, PiiEntityType.Phone],
|
||||
["Senthil", "9876543210"]);
|
||||
|
||||
private static PromptScenario MixedTamilEnglish() => new(
|
||||
"Mixed_TamilEnglish",
|
||||
"வாடிக்கையாளர் Ravi Kumar phone 9876543210 disputed the charge.",
|
||||
"வாடிக்கையாளர் <PERSON_1> phone <PHONE_1> disputed the charge.",
|
||||
[PiiEntityType.Person, PiiEntityType.Phone],
|
||||
["Ravi Kumar", "9876543210"]);
|
||||
|
||||
private static PromptScenario TamilFullFinancial() => new(
|
||||
"Tamil_FullFinancial",
|
||||
"வாடிக்கையாளர் ராஜேஷ் குமார் மின்னஞ்சல் ravi.kumar@gmail.com தொலைபேசி 9876543210 LoanNumber LN-456789 PAN ABCDE1234F. இந்த வாடிக்கையாளர் புகாரை சுருக்கமாக கூறுங்கள்.",
|
||||
"வாடிக்கையாளர் <PERSON_1> மின்னஞ்சல் <EMAIL_1> தொலைபேசி <PHONE_1> LoanNumber <LOAN_NUMBER_1> PAN <PAN_1>. இந்த வாடிக்கையாளர் புகாரை சுருக்கமாக கூறுங்கள்.",
|
||||
[PiiEntityType.Person, PiiEntityType.Email, PiiEntityType.Phone, PiiEntityType.LoanNumber, PiiEntityType.Pan],
|
||||
["ராஜேஷ் குமார்", "ravi.kumar@gmail.com", "9876543210", "LN-456789", "ABCDE1234F"]);
|
||||
}
|
||||
Reference in New Issue
Block a user