Skip to content

A .NET library for converting numeric words into numbers.

License

Notifications You must be signed in to change notification settings

ladenedge/WordsToNumbers

Repository files navigation

WordsToNumbers

A .NET library for converting numeric words into numbers.

Try it out on the 🔗 demo site.

Installation

NuGet Badge

New versions of the library are published to NuGet.

Install-Package WordsToNumbers

Usage

The library contains an interface, IWordToNumberStrategy, and the following implementations of that interface:

Implementation Class Description
SimpleReplacementStrategy A simple replacement strategy that handles most number phrases up to (but not including) one million.

Use it by mapping it in your service container:

public void ConfigureServices(IServiceCollection services)
{
   services.AddScoped<IWordToNumberStrategy, SimpleReplacementStrategy>();
}

or just construct the strategy class yourself and use it:

var converter = new SimpleReplacementStrategy();
converter.ConvertWordsToNumbers(words);

Number Support

To see what kind of phrases this library supports, check out the test cases. Bug reports on phrases that don't work are welcome!

About

A .NET library for converting numeric words into numbers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published