46 lines
1.3 KiB
C#
46 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="TamilOnnxNerRunner"/> per fixture for performance.
|
||
|
|
/// Skips all tests in the class when the Tamil ONNX model is missing or cannot be loaded.
|
||
|
|
/// </summary>
|
||
|
|
public abstract class RealTamilNerModelFixture
|
||
|
|
{
|
||
|
|
protected TamilOnnxNerRunner Runner { get; private set; } = null!;
|
||
|
|
|
||
|
|
protected string ModelPath { get; private set; } = null!;
|
||
|
|
|
||
|
|
[OneTimeSetUp]
|
||
|
|
public void OneTimeSetUpTamilModel()
|
||
|
|
{
|
||
|
|
ModelPath = RealTamilNerModelPaths.ResolveRepoModelPath();
|
||
|
|
if (!File.Exists(ModelPath))
|
||
|
|
{
|
||
|
|
Assert.Ignore(RealTamilNerModelPaths.ModelMissingMessage);
|
||
|
|
}
|
||
|
|
|
||
|
|
var options = Options.Create(new PiiRedactionOptions
|
||
|
|
{
|
||
|
|
TamilOnnxModelPath = ModelPath
|
||
|
|
});
|
||
|
|
Runner = new TamilOnnxNerRunner(options, NullLogger<TamilOnnxNerRunner>.Instance);
|
||
|
|
|
||
|
|
if (!Runner.IsModelAvailable)
|
||
|
|
{
|
||
|
|
Runner.Dispose();
|
||
|
|
Assert.Ignore(RealTamilNerModelPaths.ModelMissingMessage);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
[OneTimeTearDown]
|
||
|
|
public void OneTimeTearDownTamilModel()
|
||
|
|
{
|
||
|
|
Runner?.Dispose();
|
||
|
|
}
|
||
|
|
}
|