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.
27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
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);
|
|
}
|