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:
26
src/PiiRedaction.Infrastructure/Onnx/NerLabelConfig.cs
Normal file
26
src/PiiRedaction.Infrastructure/Onnx/NerLabelConfig.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace PiiRedaction.Infrastructure.Onnx;
|
||||
|
||||
public sealed class NerLabelConfig
|
||||
{
|
||||
private readonly Func<string, bool> _isPersonLabel;
|
||||
|
||||
private NerLabelConfig(Func<string, bool> isPersonLabel) => _isPersonLabel = isPersonLabel;
|
||||
|
||||
public static NerLabelConfig English { get; } = new(IsEnglishPersonLabel);
|
||||
|
||||
public static NerLabelConfig Tamil { get; } = new(IsTamilPersonLabel);
|
||||
|
||||
public bool IsPersonLabel(string label) => _isPersonLabel(label);
|
||||
|
||||
public bool IsBeginLabel(string label) => label.StartsWith("B-", StringComparison.Ordinal);
|
||||
|
||||
public bool IsInsideLabel(string label) => label.StartsWith("I-", StringComparison.Ordinal);
|
||||
|
||||
private static bool IsEnglishPersonLabel(string label) =>
|
||||
label is "B-PER" or "I-PER" or "B-PERSON" or "I-PERSON"
|
||||
|| (label.EndsWith("-PER", StringComparison.Ordinal) &&
|
||||
(label.StartsWith("B-", StringComparison.Ordinal) || label.StartsWith("I-", StringComparison.Ordinal)));
|
||||
|
||||
private static bool IsTamilPersonLabel(string label) =>
|
||||
label.Contains("person", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
Reference in New Issue
Block a user