Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NTextCat how it works

Tags:

c#

if anyone know how i can use NTextCat in c#, I've downloaded but I found many of dll files, i don't know what i should use. This is its website http://ntextcat.codeplex.com i found i code:

var factory = new RankedLanguageIdentifierFactory();
 var identifier = factory.Load("Core14.profile.xml");
 var languages = identifier.Identify("your text to get its language identified");
 var mostCertainLanguage = languages.FirstOrDefault();
 if (mostCertainLanguage != null)  
    Console.WriteLine("The language of the text is '{0}' (ISO639-3  code)",mostCertainLanguage.Item1.Iso639_3);  
 else 
    Console.WriteLine("The language couldn’t be identified with an acceptable degree of certainty");

but what i should do first what a dll i should use ect..

like image 653
Hamza Kouadri Avatar asked Apr 19 '14 08:04

Hamza Kouadri


2 Answers

I did it by the way, for who's interested:

  1. copy the folder you downloaded to your directory
  2. browse and import dll IvanAkcheurov.NTextCat.Lib.dll and add it to the references of the project
  3. In your code:

    using IvanAkcheurov.NTextCat.Lib;
    
    // ....
    // <YOUR CODE>
    // ....
    var factory = new RankedLanguageIdentifierFactory();
    var identifier = factory.Load("NTextCat 0.2.1.1\\LanguageModels\\Core14.profile.xml");
    var languages = identifier.Identify("your text to get its language identified");
    var mostCertainLanguage = languages.FirstOrDefault();
    if (mostCertainLanguage != null)  
        Console.WriteLine("The language of the text is '{0}' (ISO639-3  code)",mostCertainLanguage.Item1.Iso639_3);  
    else 
        Console.WriteLine("The language couldn’t be identified with an acceptable degree of certainty");
    

In the line var identifier = factory.Load.... you must pay attention to language profile you'll need to use. For example, I use Wiki82.profile.xml

like image 173
Hamza Kouadri Avatar answered Oct 16 '22 08:10

Hamza Kouadri


Go to "Manage Nuget Packages" in Visual Studio and Search for NTextCat... the nuget package will pop up (make sure it's the one by Ivan). Click install and it will install all DLLs needed.

like image 39
Xena Avatar answered Oct 16 '22 08:10

Xena