2013-03-06 29 views
5

Sử dụng C# NHunspell, làm cách nào để kiểm tra xem một từ có đúng chính tả hay không và nếu không chính tả là gì?Sử dụng C# NHunspell làm cách nào để kiểm tra các từ?

Tôi đã nhập NHunspell.dll vào dự án. Và đã xem the documentation.

Nhưng có một chút mới khi đọc tài liệu thật khó để biết bắt đầu từ đâu. Ai đó có thể cung cấp một ví dụ về cách kiểm tra xem một từ được viết đúng chính tả không? Về cơ bản tôi cần một Helloworld cho NHunspell.

+1

http://www.codeproject.com/Articles/33658/NHunspell-Hunspell-for-the-NET-platform –

+1

Ngoài ra, duyệt các bài kiểm tra đơn vị: http://nhunspell.svn.sourceforge.net/viewvc/nhunspell/trunk/UnitTests/UnitTestsHunspell.cs?revision=81&view=markup –

+0

Tôi thực sự đã sử dụng NetSpell vì nó dễ triển khai hơn. Cảm ơn bạn mặc dù! – rotaercz

Trả lời

8
using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic")) 
{ 
    Console.WriteLine("Hunspell - Spell Checking Functions"); 
    Console.WriteLine("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯"); 

    Console.WriteLine("Check if the word 'Recommendation' is spelled correct"); 
    bool correct = hunspell.Spell("Recommendation"); 
    Console.WriteLine("Recommendation is spelled " + 
     (correct ? "correct":"not correct")); 

    Console.WriteLine(""); 
    Console.WriteLine("Make suggestions for the word 'Recommendatio'"); 
    List<string> suggestions = hunspell.Suggest("Recommendatio"); 
    Console.WriteLine("There are " + 
     suggestions.Count.ToString() + " suggestions"); 
    foreach (string suggestion in suggestions) 
    { 
     Console.WriteLine("Suggestion is: " + suggestion); 
    } 
} 

Từ Điều http://www.codeproject.com/Articles/43495/Spell-Check-Hyphenation-and-Thesaurus-for-NET-with

+0

làm thế nào chúng ta có thể nhận được tất cả các từ? Tôi có nghĩa là quét từng dòng của tập tin dic và nhận được tất cả các kết hợp có thể được sản xuất từ ​​dòng đó. Làm thế nào tôi có thể làm điều đó? ty – MonsterMMORPG

+0

https://www.codeproject.com/Articles/43495/Spell-Check-Hyphenation-and-Thesaurus-for-NET-with?msg=5368357#xx5368357xx – MonsterMMORPG

Các vấn đề liên quan