Files
llm-pii-poc/tests/TestSupport.Shared/RealNerModelPaths.cs

32 lines
990 B
C#
Raw Permalink Normal View History

namespace PiiRedaction.Tests.Shared;
public static class RealNerModelPaths
{
public const string ModelMissingMessage =
"ONNX model not found. Run scripts/download-ner-model.ps1 from the repository root.";
public static string ResolveRepoModelPath()
{
foreach (var relativePath in new[]
{
Path.Combine("models", "en", "ner-model.onnx"),
Path.Combine("models", "ner-model.onnx")
})
{
var directory = new DirectoryInfo(AppContext.BaseDirectory);
while (directory is not null)
{
var candidate = Path.Combine(directory.FullName, relativePath);
if (File.Exists(candidate))
{
return candidate;
}
directory = directory.Parent;
}
}
return Path.Combine(Environment.CurrentDirectory, "models", "ner-model.onnx");
}
}