Panlingo.LanguageIdentification.FastText.Native 0.6.0

dotnet add package Panlingo.LanguageIdentification.FastText.Native --version 0.6.0
                    
NuGet\Install-Package Panlingo.LanguageIdentification.FastText.Native -Version 0.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Panlingo.LanguageIdentification.FastText.Native" Version="0.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Panlingo.LanguageIdentification.FastText.Native" Version="0.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Panlingo.LanguageIdentification.FastText.Native" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Panlingo.LanguageIdentification.FastText.Native --version 0.6.0
                    
#r "nuget: Panlingo.LanguageIdentification.FastText.Native, 0.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Panlingo.LanguageIdentification.FastText.Native&version=0.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Panlingo.LanguageIdentification.FastText.Native&version=0.6.0
                    
Install as a Cake Tool

Panlingo.LanguageIdentification.FastText

Welcome to Panlingo.LanguageIdentification.FastText, a .NET wrapper for the FastText library by Facebook AI Research (FAIR). This package seamlessly integrates language identification capabilities into .NET applications, leveraging the powerful and efficient FastText library to recognize and classify texts in multiple languages. Ideal for applications that require fast and accurate language detection.

Requirements

  • Runtime: .NET >= 5.0
  • OS: Linux (Ubuntu, Debian), Windows 10+ or Windows Server 2019+, macOS
  • Arch: AMD64 (or ARM for macOS)

Installation

To integrate the FastText functionality, follow these steps:

Install the NuGet package:

dotnet add package Panlingo.LanguageIdentification.FastText

Usage

Integrating the FastText library into your .NET application is straightforward. Here’s a quick guide to get you started:

  1. Install the Package: Ensure you have added the Panlingo.LanguageIdentification.FastText package to your project using the provided installation command.
  2. Download the Models: Follow the provided commands to download the pretrained language identification models.
  3. Initialize the Library: Follow the example snippet to initialize and use the FastText library for detecting languages.
using Panlingo.LanguageIdentification.FastText;

class Program
{
    static void Main()
    {
        using var fastText = new FastTextDetector();
        fastText.LoadDefaultModel();

        var predictions = fastText.Predict(
            text: "Привіт, як справи?", 
            count: 10
        );

        foreach (var prediction in predictions)
        {
            Console.WriteLine($"{prediction.Label}: {prediction.Probability}");
        }

        var dimensions = fastText.GetModelDimensions();
        var labels = fastText.GetLabels();
    }
}

Custom models

The default model for this package is quantized lid.176.ftz (see below). You can use the default model by calling the LoadDefaultModel() method.

We recommend using the following models, but you can use any model depending on your needs. It could even be a model for another text classinfiction tasks, e.g: supervised models

Model Vendor Languages Label format Learn more Download
lid.176 Meta Platforms, Inc. 176 __label__en __label__uk __label__hi fasttext.cc lid.176.bin
lid218e Meta Platforms, Inc. 217 __label__eng_Latn __label__ukr_Cyrl __label__hin_Deva @facebook/fasttext-language-identification model.bin
GlotLID CIS, LMU Munich 2155(?) __label__eng_Latn __label__ukr_Cyrl __label__hin_Deva @cis-lmu/glotlid model_v3.bin
Use custom model in codes

You can use the model included in this NuGet package:

using var fastText = new FastTextDetector();
fastText.LoadDefaultModel();

You can specify the path to the model file:

using var fastText = new FastTextDetector();

var modelPath = "/path/to/model/fasttext176.bin";
fastText.LoadModel(modelPath);

Also you can also load the model as a memory stream:

using var fastText = new FastTextDetector();

var modelPath = "/path/to/model/fasttext176.bin";
using var stream = File.Open(modelPath, FileMode.Open);
fastText.LoadModel(stream);

Alternatives

If you are exploring other options, here are some alternatives to consider:

Sources

  1. Original FastText Repository
  2. Enriching Word Vectors with Subword Information
  3. Language identification at Wikipedia

License

This project is licensed under the MIT License © 2024–2025 Alexander Gluschenko.

Includes software from the following project(s):

  • FastText — © 2016–present Meta Platforms, Inc., licensed under MIT

See the LICENSE file for full details.


We value your feedback. Feel free to open issues or contribute to the repository. Let’s make language detection in .NET even more powerful and versatile! 🌍📝

Happy coding! 👩‍💻👨‍💻


Stay updated by following our repository. For any inquiries or support, reach out through the issues page.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Panlingo.LanguageIdentification.FastText.Native:

Package Downloads
Panlingo.LanguageIdentification.FastText

This is a .NET wrapper for the FastText library by Facebook AI Research (FAIR). This package facilitates the integration of language identification capabilities into .NET applications, leveraging the powerful and efficient FastText library to recognize and classify texts in multiple languages. Ideal for applications that require fast and accurate language detection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 140 7/1/2025
0.5.0 186 6/18/2025
0.4.0 404 1/20/2025
0.3.0 207 12/15/2024
0.2.0 207 11/10/2024
0.1.1 241 10/22/2024
0.1.0 158 10/7/2024
0.0.0.22 206 9/22/2024
0.0.0.21 180 9/10/2024
0.0.0.20 171 9/8/2024
0.0.0.19 155 9/1/2024
0.0.0.18 157 8/26/2024
0.0.0.17 196 8/21/2024
0.0.0.16 187 8/9/2024
0.0.0.15 147 8/8/2024
0.0.0.14 126 8/3/2024
0.0.0.13 137 8/1/2024
0.0.0.12 150 7/20/2024
0.0.0.10 149 7/14/2024

- Initial release