Panlingo.LanguageIdentification.Lingua 0.0.0.19

There is a newer version of this package available.
See the version list below for details.
dotnet add package Panlingo.LanguageIdentification.Lingua --version 0.0.0.19                
NuGet\Install-Package Panlingo.LanguageIdentification.Lingua -Version 0.0.0.19                
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.Lingua" Version="0.0.0.19" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Panlingo.LanguageIdentification.Lingua --version 0.0.0.19                
#r "nuget: Panlingo.LanguageIdentification.Lingua, 0.0.0.19"                
#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.
// Install Panlingo.LanguageIdentification.Lingua as a Cake Addin
#addin nuget:?package=Panlingo.LanguageIdentification.Lingua&version=0.0.0.19

// Install Panlingo.LanguageIdentification.Lingua as a Cake Tool
#tool nuget:?package=Panlingo.LanguageIdentification.Lingua&version=0.0.0.19                

Panlingo.LanguageIdentification.Lingua

Welcome to Panlingo.LanguageIdentification.Lingua, a .NET wrapper for the Lingua library, which is an efficient and easy-to-use language detection library. This package simplifies the integration of language identification capabilities into .NET applications, leveraging the Whatlang library to accurately and quickly recognize the languages of given texts. Perfect for projects that require lightweight yet reliable language detection.

Requirements

  • Runtime: .NET >= 5.0
  • OS: Linux
  • Arch: AMD64

Installation

To integrate the Lingua functionality, follow these steps:

  1. Install the NuGet package:

    dotnet add package Panlingo.LanguageIdentification.Lingua
    

Usage

Integrating the Lingua 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.Lingua package to your project using the provided installation command.
  2. Initialize the Library: Follow the example snippet to initialize and use the Lingua library for detecting languages.
using Panlingo.LanguageIdentification.Lingua;

class Program
{
    static void Main()
    {
        // Create an instance of the language detector
        using var linguaBuilder = new LinguaDetectorBuilder(Enum.GetValues<LinguaLanguage>())
            .WithPreloadedLanguageModels()     // optional
            .WithMinimumRelativeDistance(0.95) // optional
            .WithLowAccuracyMode();            // optional

        using var lingua = linguaBuilder.Build();

        var texts = new[]
        {
            "Hello, how are you?",
            "Привіт, як справи?",
            "Привет, как дела?",
        };

        var predictions = texts
            .Select(x => new
            {
                Text = x,
                Predictions = lingua.PredictLanguages(x),
            })
            .ToArray();

        foreach (var x in predictions)
        {
            var prediction = x.Predictions.FirstOrDefault();

            Console.WriteLine(
                $"Text: {x.Text}, " +
                $"Language: {prediction?.Language.ToString() ?? "NULL"}, " +
                $"Probability: {prediction?.Confidence.ToString() ?? "NULL"}"
            );
        }
    }
}

Alternatives

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

Sources

  1. Original Lingua Repository
  2. Language identification at Wikipedia

Supported languages

Language ISO 639-3 Enum
Afrikaans afr LinguaLanguage.Afrikaans
Albanian sqi LinguaLanguage.Albanian
Arabic ara LinguaLanguage.Arabic
Armenian hye LinguaLanguage.Armenian
Azerbaijani aze LinguaLanguage.Azerbaijani
Basque eus LinguaLanguage.Basque
Belarusian bel LinguaLanguage.Belarusian
Bengali ben LinguaLanguage.Bengali
Bokmal nob LinguaLanguage.Bokmal
Bosnian bos LinguaLanguage.Bosnian
Bulgarian bul LinguaLanguage.Bulgarian
Catalan cat LinguaLanguage.Catalan
Chinese zho LinguaLanguage.Chinese
Croatian hrv LinguaLanguage.Croatian
Czech ces LinguaLanguage.Czech
Danish dan LinguaLanguage.Danish
Dutch nld LinguaLanguage.Dutch
English eng LinguaLanguage.English
Esperanto epo LinguaLanguage.Esperanto
Estonian est LinguaLanguage.Estonian
Finnish fin LinguaLanguage.Finnish
French fra LinguaLanguage.French
Ganda lug LinguaLanguage.Ganda
Georgian kat LinguaLanguage.Georgian
German deu LinguaLanguage.German
Greek ell LinguaLanguage.Greek
Gujarati guj LinguaLanguage.Gujarati
Hebrew heb LinguaLanguage.Hebrew
Hindi hin LinguaLanguage.Hindi
Hungarian hun LinguaLanguage.Hungarian
Icelandic isl LinguaLanguage.Icelandic
Indonesian ind LinguaLanguage.Indonesian
Irish gle LinguaLanguage.Irish
Italian ita LinguaLanguage.Italian
Japanese jpn LinguaLanguage.Japanese
Kazakh kaz LinguaLanguage.Kazakh
Korean kor LinguaLanguage.Korean
Latin lat LinguaLanguage.Latin
Latvian lav LinguaLanguage.Latvian
Lithuanian lit LinguaLanguage.Lithuanian
Macedonian mkd LinguaLanguage.Macedonian
Malay msa LinguaLanguage.Malay
Maori mri LinguaLanguage.Maori
Marathi mar LinguaLanguage.Marathi
Mongolian mon LinguaLanguage.Mongolian
Nynorsk nno LinguaLanguage.Nynorsk
Persian fas LinguaLanguage.Persian
Polish pol LinguaLanguage.Polish
Portuguese por LinguaLanguage.Portuguese
Punjabi pan LinguaLanguage.Punjabi
Romanian ron LinguaLanguage.Romanian
Russian rus LinguaLanguage.Russian
Serbian srp LinguaLanguage.Serbian
Shona sna LinguaLanguage.Shona
Slovak slk LinguaLanguage.Slovak
Slovene slv LinguaLanguage.Slovene
Somali som LinguaLanguage.Somali
Sotho sot LinguaLanguage.Sotho
Spanish spa LinguaLanguage.Spanish
Swahili swa LinguaLanguage.Swahili
Swedish swe LinguaLanguage.Swedish
Tagalog tgl LinguaLanguage.Tagalog
Tamil tam LinguaLanguage.Tamil
Telugu tel LinguaLanguage.Telugu
Thai tha LinguaLanguage.Thai
Tsonga tso LinguaLanguage.Tsonga
Tswana tsn LinguaLanguage.Tswana
Turkish tur LinguaLanguage.Turkish
Ukrainian ukr LinguaLanguage.Ukrainian
Urdu urd LinguaLanguage.Urdu
Vietnamese vie LinguaLanguage.Vietnamese
Welsh cym LinguaLanguage.Welsh
Xhosa xho LinguaLanguage.Xhosa
Yoruba yor LinguaLanguage.Yoruba
Zulu zul LinguaLanguage.Zulu

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 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.0.22 111 9/22/2024
0.0.0.21 89 9/10/2024
0.0.0.20 75 9/8/2024
0.0.0.19 96 9/1/2024
0.0.0.18 85 8/26/2024
0.0.0.17 113 8/21/2024

- Initial release