2026-07-07 13:05:07 +05:30
|
|
|
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()
|
|
|
|
|
{
|
2026-07-07 17:12:38 +05:30
|
|
|
foreach (var relativePath in new[]
|
|
|
|
|
{
|
|
|
|
|
Path.Combine("models", "en", "ner-model.onnx"),
|
|
|
|
|
Path.Combine("models", "ner-model.onnx")
|
|
|
|
|
})
|
2026-07-07 13:05:07 +05:30
|
|
|
{
|
2026-07-07 17:12:38 +05:30
|
|
|
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
|
|
|
|
while (directory is not null)
|
2026-07-07 13:05:07 +05:30
|
|
|
{
|
2026-07-07 17:12:38 +05:30
|
|
|
var candidate = Path.Combine(directory.FullName, relativePath);
|
|
|
|
|
if (File.Exists(candidate))
|
|
|
|
|
{
|
|
|
|
|
return candidate;
|
|
|
|
|
}
|
2026-07-07 13:05:07 +05:30
|
|
|
|
2026-07-07 17:12:38 +05:30
|
|
|
directory = directory.Parent;
|
|
|
|
|
}
|
2026-07-07 13:05:07 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Path.Combine(Environment.CurrentDirectory, "models", "ner-model.onnx");
|
|
|
|
|
}
|
|
|
|
|
}
|