简体   繁体   English

NTextCat是如何工作的

[英]NTextCat how it works

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. 如果有人知道我如何在c#中使用NTextCat,我已经下载但是我发现了很多dll文件,我不知道应该使用什么。 This is its website http://ntextcat.codeplex.com i found i code: 这是它的网站http://ntextcat.codeplex.com我发现我的代码:

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.. 但我应该先做什么dll我应该使用等..

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 浏览并导入dll IvanAkcheurov.NTextCat.Lib.dll并将其添加到项目的引用
  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. 在行var identifier = factory.Load....您必须注意您需要使用的语言配置文件。 For example, I use Wiki82.profile.xml 例如,我使用Wiki82.profile.xml

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). 转到Visual Studio中的“Manage Nuget Packages”并搜索NTextCat ...将弹出nuget包(确保它是Ivan的那个)。 Click install and it will install all DLLs needed. 单击安装,它将安装所需的所有DLL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM