-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_spellcheck.csx
More file actions
55 lines (43 loc) · 1.58 KB
/
Copy pathtest_spellcheck.csx
File metadata and controls
55 lines (43 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env dotnet-script
#r "nuget: WeCantSpell.Hunspell, 5.0.0"
#r "nuget: Microsoft.Extensions.Logging.Console, 10.0.0"
using WeCantSpell.Hunspell;
using Microsoft.Extensions.Logging;
// Test dictionary loading and spell checking
var dictionaryPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"lucidrag", "models", "dictionaries");
Console.WriteLine($"Dictionary path: {dictionaryPath}");
var affPath = Path.Combine(dictionaryPath, "en_US.aff");
var dicPath = Path.Combine(dictionaryPath, "en_US.dic");
if (!File.Exists(affPath) || !File.Exists(dicPath))
{
Console.WriteLine("ERROR: Dictionary files not found!");
Console.WriteLine($" Looking for: {affPath}");
Console.WriteLine($" Looking for: {dicPath}");
return;
}
Console.WriteLine("Loading dictionary...");
var dict = WordList.CreateFromFiles(dicPath, affPath);
if (dict == null)
{
Console.WriteLine("ERROR: Failed to load dictionary!");
return;
}
Console.WriteLine("Dictionary loaded successfully!\n");
// Test words from "Back Bf the net"
var testWords = new[] { "Back", "Bf", "the", "net" };
foreach (var word in testWords)
{
var exact = dict.Check(word);
var lower = dict.Check(word.ToLowerInvariant());
Console.WriteLine($"Word: '{word}'");
Console.WriteLine($" Exact match: {exact}");
Console.WriteLine($" Lowercase match: {lower}");
if (!exact && !lower)
{
var suggestions = dict.Suggest(word).Take(3).ToList();
Console.WriteLine($" Suggestions: {string.Join(", ", suggestions)}");
}
Console.WriteLine();
}