---
title: "Classify a name as person or company in C#"
url: https://recursiveai.org/onecontact/cookbook/classify-ambiguous-person-or-company-name/
description: "Classify ambiguous US and Canadian names in C# with OneContact’s local Tier 1 model. Compare rule-only results with the model’s class and confidence."
version: "1.1.0"
---

# Classify a name as person or company 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.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneContact.Models.Tier1) · [GitHub](https://github.com/recursive-ai-oss/onecontact-csharp) · [Docs](https://recursiveai.org/onecontact/docs/) · [Download example (.zip)](https://recursiveai.org/onecontact/cookbook/classify-ambiguous-person-or-company-name/classify-ambiguous-person-or-company-name.zip)

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.

```shell
dotnet add package RecursiveAI.OneContact.Models.Tier1
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneContact.Names;

var kind = NameParsing.Classify(
    "Northwind & Finch");
Console.WriteLine(kind);
```

[The example](https://recursiveai.org/onecontact/cookbook/classify-ambiguous-person-or-company-name/classify-ambiguous-person-or-company-name.zip) 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:

```text
Company
```

## The 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`.

```csharp
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})"));
}
```

```text
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.

```csharp
using RecursiveAI.OneContact.Models.Tier1;

var vote = Tier1Model.Instance.Analyze("Northwind");
Console.WriteLine(FormattableString.Invariant(
    $"{vote.Class} ({vote.ClassConfidence:F2})"));
```

```text
Company (1.00)
```

## Related recipes

- [Parse a person’s name](https://recursiveai.org/onecontact/cookbook/parse-person-name/)
- [Parse a company name](https://recursiveai.org/onecontact/cookbook/parse-company-name/)
- [Check which OneContact model package is active](https://recursiveai.org/onecontact/cookbook/choose-active-address-model-package/)

## 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](https://recursiveai.org/onecontact/docs/names/) 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](https://recursiveai.org/onecontact/docs/models/) 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](https://github.com/recursive-ai-oss/onecontact-csharp/blob/b7cda1cc0109da5eabdf85bd8cb2f3d9b052e8ac/src/OneContact/Names/ModelNameReader.cs#L76-L93).

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.
