NTextCat如何工作

6
如果有人知道我如何在C#中使用NTextCat,请帮忙解答。我已经下载了它,但发现有很多dll文件,不知道该使用哪个。以下是其官网链接: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");

但我应该首先做什么?我应该使用哪个dll等等。
2个回答

8

顺便说一下,我做到了,对于那些感兴趣的人:

  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");
    
在这行代码 var identifier = factory.Load.... 中,你需要注意所需使用的语言配置文件。例如,我使用的是 Wiki82.profile.xml

1

在Visual Studio中前往“管理Nuget包”,搜索NTextCat... Nuget包将弹出(确保是Ivan的那个)。点击安装,它将安装所有所需的DLL。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接