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.
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Microsoft.Extensions.Options;
|
|
using PiiRedaction.Core.Configuration;
|
|
using PiiRedaction.Infrastructure.Onnx;
|
|
|
|
namespace PiiRedaction.Tests.Shared;
|
|
|
|
/// <summary>
|
|
/// Reuses a single <see cref="EnglishOnnxNerRunner"/> per fixture for performance.
|
|
/// Skips all tests in the class when the ONNX model is missing or cannot be loaded.
|
|
/// </summary>
|
|
public abstract class RealNerModelFixture
|
|
{
|
|
protected EnglishOnnxNerRunner Runner { get; private set; } = null!;
|
|
|
|
protected string ModelPath { get; private set; } = null!;
|
|
|
|
[OneTimeSetUp]
|
|
public void OneTimeSetUpRealModel()
|
|
{
|
|
ModelPath = RealNerModelPaths.ResolveRepoModelPath();
|
|
if (!File.Exists(ModelPath))
|
|
{
|
|
Assert.Ignore(RealNerModelPaths.ModelMissingMessage);
|
|
}
|
|
|
|
var options = Options.Create(new PiiRedactionOptions
|
|
{
|
|
EnglishOnnxModelPath = ModelPath,
|
|
OnnxModelPath = ModelPath
|
|
});
|
|
Runner = new EnglishOnnxNerRunner(options, NullLogger<EnglishOnnxNerRunner>.Instance);
|
|
|
|
if (!Runner.IsModelAvailable)
|
|
{
|
|
Runner.Dispose();
|
|
Assert.Ignore(RealNerModelPaths.ModelMissingMessage);
|
|
}
|
|
}
|
|
|
|
[OneTimeTearDown]
|
|
public void OneTimeTearDownRealModel()
|
|
{
|
|
Runner?.Dispose();
|
|
}
|
|
}
|