For US and Canadian names, NameParsing.Classify can ask the local model when the rules are unsure.
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.
dotnet add package RecursiveAI.OneContact.Models.Tier1Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneContact.Names; var kind = NameParsing.Classify( "Northwind & Finch"); Console.WriteLine(kind);
The example is the full program below: unzip it and dotnet run. To run only the code above, paste it into Program.cs of a new dotnet new console project and dotnet run.
Prints:
CompanyThe full program
Run the rules alone and then with the installed model. The last line for each name is the raw model vote, not a score returned by Classify.
using RecursiveAI.OneContact.Models.Tier1; using RecursiveAI.OneContact.Names; foreach (var name in new[] { "Northwind & Finch", "Morrow" }) { var rules = NameParsing.Classify(name, default, model: null); var kind = NameParsing.Classify(name); var vote = Tier1Model.Instance.Analyze(name); Console.WriteLine(name); Console.WriteLine($"Rules: {rules}; with model: {kind}"); Console.WriteLine(FormattableString.Invariant( $"Model vote: {vote.Class} ({vote.ClassConfidence:F2})")); }
Northwind & Finch Rules: Unknown; with model: Company Model vote: Company (1.00) Morrow Rules: Unknown; with model: Unknown Model vote: Unknown (1.00)
If the final class is Unknown, keep the name unclassified or ask for more context rather than treating it as a person by default.
Variations
Read just the model’s vote
Use Analyze to inspect what the embedded model predicts without the parser’s rules. This is useful for comparing the two readings, not for replacing the parser’s result.
using RecursiveAI.OneContact.Models.Tier1; var vote = Tier1Model.Instance.Analyze("Northwind"); Console.WriteLine(FormattableString.Invariant( $"{vote.Class} ({vote.ClassConfidence:F2})"));
Company (1.00)Related recipes
The short answer
Reference RecursiveAI.OneContact.Models.Tier1 and call NameParsing.Classify with one name string. Once you reference the package in a C# project, Classify can use the model for names the rules leave undecided, with no setup code. To see what changed, call the overload with model: null on the same input; that one call uses only the rules.
How can I tell whether a name string is a person or a company?
Give the classifier the name alone, not the whole contact block. The name rules can recognize evidence such as a title on a person’s name or a legal form on a company name. Those rule hits stay. A bare name can be ambiguous: the rules return Unknown for Northwind & Finch, but the installed model supplies Company in the example. Morrow stays Unknown even with the model.
Classify gives you the kind, not the name’s constituent fields. It can also report Multiple for several people. If a later step needs given and family names or a company’s legal form, use NameParsing.Split for the parsed result. The model notes distinguish those jobs: a model can predict that a string names several people, but it doesn’t split those people for you.
What does confidence mean when the model classifies a name?
The model labels the individual words and combines their class votes, weighted by their probabilities. Punctuation and line breaks don’t vote. For an eligible Unknown from the rules, the classifier requires a weighted vote greater than 0.5 to take the model’s class. There’s a separate case: if the rules only defaulted to Person for lack of company evidence (person.no-evidence), a Company or Unknown prediction can replace that default at 0.6 or above for US and Canadian names. A definite rule hit is not replaced. See the name-model decision code.
The raw score describes the model’s vote, not the chance that a name in your database belongs to a real company. It can even be high for Unknown, as with Morrow. Keep the raw vote separate from your final decision: the parser can refuse an input or preserve a rule result regardless of what Analyze predicts.