test(cv-import): add frozen corpus and bounded accuracy qualification
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../../JobTrackerApi/JobTrackerApi.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using JobTrackerApi.Controllers;
|
||||
using JobTrackerApi.Services;
|
||||
|
||||
if (args.Length != 3 || args[1] is not ("pdf" or "docx"))
|
||||
throw new ArgumentException("Usage: CvImportBenchmark <extraction-directory> <pdf|docx> <fresh-output.json>");
|
||||
var options = new JsonSerializerOptions(JsonSerializerDefaults.Web) { WriteIndented = true };
|
||||
var outputs = new Dictionary<string, object>();
|
||||
foreach (var file in Directory.GetFiles(args[0], "*." + args[1] + ".extracted.json").Order())
|
||||
{
|
||||
using var json = JsonDocument.Parse(await File.ReadAllTextAsync(file));
|
||||
var root = json.RootElement;
|
||||
var id = Path.GetFileName(file)[..^(args[1].Length + ".extracted.json".Length + 1)];
|
||||
if (!root.GetProperty("ok").GetBoolean()) { outputs.Add(id, new { error = root.GetProperty("code").GetString() }); continue; }
|
||||
var text = root.GetProperty("text").GetString()!;
|
||||
var blocks = root.GetProperty("blocks").EnumerateArray().Select(b => new CvImportBlock(b.GetProperty("id").GetString()!, b.GetProperty("text").GetString()!, b.GetProperty("kind").GetString()!, b.GetProperty("page").ValueKind == JsonValueKind.Number ? b.GetProperty("page").GetInt32() : null)).ToArray();
|
||||
var document = new CvImportDocument(text, false, null, root.GetProperty("page_count").ValueKind == JsonValueKind.Number ? root.GetProperty("page_count").GetInt32() : null, text.Length, id + "." + args[1], blocks, root.GetProperty("warnings").EnumerateArray().Select(w => w.GetString()!).ToArray(), root.GetProperty("method").GetString()!);
|
||||
var clock = Stopwatch.StartNew();
|
||||
var profile = ProfileCvController.ParseImportDocument(document);
|
||||
clock.Stop();
|
||||
outputs.Add(id, new { profile, extractionMethod = document.Method, reviewRequired = CvDocumentReview.Build(new(), profile).Sum(g => g.Fields.Count), timing = new { interpretationMs = clock.Elapsed.TotalMilliseconds } });
|
||||
}
|
||||
using var destination = new FileStream(args[2], FileMode.CreateNew);
|
||||
await JsonSerializer.SerializeAsync(destination, outputs, options);
|
||||
Console.WriteLine($"Recorded {outputs.Count} {args[1]} cases; no generative model was invoked.");
|
||||
Reference in New Issue
Block a user