Recursive AI

Check the active OneContact model in C#

OneContact is a free, open-source contact data library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies, no network access.

ContactModels.PackageId tells you which package supplies the default address and name models.

OneContact uses built-in rules first to classify names; RecursiveAI.OneContact.Models.Tier1 bundles a small offline model for the United States and Canada, and RecursiveAI.OneContact.Models also covers Mexico, Australia, the United Kingdom, the Crown dependencies, and the Latin-script countries of Europe.

Terminal
dotnet add package RecursiveAI.OneContact.Models.Tier1
dotnet add package RecursiveAI.OneContact.Models

This demo installs both packages only to show which one wins; in your app, reference just one.

Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.

C#
using RecursiveAI.OneContact.Models;
 
Console.WriteLine(
    ContactModels.PackageId ?? "No model");

Paste the code above into Program.cs of a new dotnet new console project and dotnet run, or unzip the example and dotnet run.

With both packages, prints:

Text
RecursiveAI.OneContact.Models

If it prints No model, no default model package is active at the point where the code runs.

Variations

Check Tier 1 by itself

In a copy of the example project, remove the Tier 1 + Tier 2 package and rerun the same program:

Terminal
dotnet remove package RecursiveAI.OneContact.Models
dotnet run
Text
RecursiveAI.OneContact.Models.Tier1

The short answer

Read ContactModels.PackageId from the running application. With both published model packages referenced, it returns RecursiveAI.OneContact.Models. With only the Tier 1 model package, it returns RecursiveAI.OneContact.Models.Tier1. With just the core package and no custom configuration, it returns null. The property reports a registration; it doesn’t have to load the trained weights to tell you which package won.

Which OneContact model wins when both NuGet packages are installed?

Tier 1 registers its address and name models at rank 1; the Tier 1 + Tier 2 package registers them at rank 2. The registry keeps the higher rank, regardless of the order in which the packages register. In a normal C# project, each package contributes a module initializer that registers it automatically. There’s no need to call Register() to choose between the two.

Choose Tier 1 if you only need model support for US and Canadian inputs: it has about 10 MB of model weights. The Tier 1 + Tier 2 package handles US and Canadian inputs the same way and adds model support for Tier 2 inputs, with about 23 MB of weights. With Tier 1 alone, Tier 2 inputs still get the built-in rules but no model fallback.

How do I check which NuGet packages a .NET project references?

Run .NET’s package list command from the project directory:

Terminal
dotnet package list --include-transitive

The example lists both model packages as top-level dependencies. The core RecursiveAI.OneContact package is transitive: it’s brought in by the model packages. That list tells you what NuGet resolved; the C# output tells you which registration won. The namespace RecursiveAI.OneContact.Models also exists in the core package, so the fact that the using statement compiles does not prove a model was registered.

If you use ContactModels.Use to override the models for a scope, PackageId reports scoped inside it instead of a NuGet ID. And even outside such a scope, the package ID says what’s available to the parsers by default, not whether a particular field came from a model. For a field-level answer, look at that field’s ParseDetail; the model docs describe how it marks rule and model decisions.

All onecontact recipes