-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from aarondandy/release-4
Release 4.0
- Loading branch information
Showing
138 changed files
with
9,160 additions
and
7,780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Text; | ||
|
||
namespace WeCantSpell.Hunspell.TestHarness; | ||
|
||
public class CheckTest | ||
{ | ||
public static void Run(string dicFilePath, string wordFilePath) | ||
{ | ||
var wordList = WordListReader.ReadFile(dicFilePath); | ||
var checkWords = new List<string>(); | ||
|
||
using var reader = new StreamReader(new FileStream(wordFilePath, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8, true); | ||
|
||
var lineSplitChars = " \t,".ToCharArray(); | ||
string? line; | ||
while ((line = reader.ReadLine()?.Trim()) is not null) | ||
{ | ||
if (line.Length == 0 || line.StartsWith('#') || line.StartsWith('[')) | ||
{ | ||
continue; | ||
} | ||
|
||
checkWords.AddRange(line.Split(lineSplitChars, StringSplitOptions.RemoveEmptyEntries)); | ||
} | ||
|
||
const int numLoops = 500; | ||
|
||
Console.WriteLine($"Checking {checkWords.Count} words {numLoops} times"); | ||
|
||
for (var i = 0; i < numLoops; i++) | ||
{ | ||
foreach (var word in checkWords) | ||
{ | ||
_ = wordList.CheckDetails(word); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace WeCantSpell.Hunspell.TestHarness; | ||
|
||
public class LoadTest | ||
{ | ||
public static void LoadDictionary(string filePath) | ||
{ | ||
var wordList = WordListReader.ReadFile(filePath); | ||
Console.WriteLine($"Loaded {wordList.RootWords.Count()} roots"); | ||
} | ||
|
||
public static void LoadAllDictionaries(string path) | ||
{ | ||
var paths = Directory.GetFiles(path, "*.dic"); | ||
|
||
foreach (var filePath in paths) | ||
{ | ||
var wordList = WordListReader.ReadFile(filePath); | ||
Console.WriteLine($"Loaded {wordList.RootWords.Count()} roots from {filePath}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Cocona; | ||
|
||
using WeCantSpell.Hunspell.TestHarness; | ||
|
||
var app = CoconaApp.Create(); | ||
|
||
app.AddCommand("load", (string file) => LoadTest.LoadDictionary(file)); | ||
app.AddCommand("load-all", (string path) => LoadTest.LoadAllDictionaries(path)); | ||
app.AddCommand("check", (string dicFile, string wordFile) => CheckTest.Run(dicFile, wordFile)); | ||
app.AddCommand("suggest", (string dicFile, string wordFile) => SuggestTest.Run(dicFile, wordFile)); | ||
app.AddCommand("suggest-word", (string dicFile, string word) => SuggestWordTest.Run(dicFile, word)); | ||
|
||
app.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"profiles": { | ||
"TestHarness": { | ||
"commandName": "Project" | ||
}, | ||
"Load en-US": { | ||
"commandName": "Project", | ||
"commandLineArgs": "load --file \"../samples/English (American).dic\"", | ||
"workingDirectory": "./" | ||
}, | ||
"Load All": { | ||
"commandName": "Project", | ||
"commandLineArgs": "load-all --path \"../samples/\"", | ||
"workingDirectory": "./" | ||
}, | ||
"Suggest en-US": { | ||
"commandName": "Project", | ||
"commandLineArgs": "suggest --dic-file \"../samples/English (American).dic\" --word-file \"../hunspell-origin/tests/suggestiontest/List_of_common_misspellings.txt\"", | ||
"workingDirectory": "./" | ||
}, | ||
"Check en-US": { | ||
"commandName": "Project", | ||
"commandLineArgs": "check --dic-file \"../samples/English (American).dic\" --word-file \"../hunspell-origin/tests/suggestiontest/List_of_common_misspellings.txt\"", | ||
"workingDirectory": "./" | ||
}, | ||
"Issue #40": { | ||
"commandName": "Project", | ||
"commandLineArgs": "suggest-word --dic-file \"../temp-data/fr-toutesvariantes.dic\" --word Systemes", | ||
"workingDirectory": "./" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Text; | ||
|
||
namespace WeCantSpell.Hunspell.TestHarness; | ||
|
||
public class SuggestTest | ||
{ | ||
public static void Run(string dicFilePath, string wordFilePath) | ||
{ | ||
var wordList = WordListReader.ReadFile(dicFilePath); | ||
var checkWords = new List<string>(); | ||
|
||
using var reader = new StreamReader(new FileStream(wordFilePath, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8, true); | ||
|
||
var lineSplitChars = " \t,".ToCharArray(); | ||
string? line; | ||
while ((line = reader.ReadLine()?.Trim()) is not null) | ||
{ | ||
if (line.Length == 0 || line.StartsWith('#') || line.StartsWith('[')) | ||
{ | ||
continue; | ||
} | ||
|
||
checkWords.AddRange(line.Split(lineSplitChars, StringSplitOptions.RemoveEmptyEntries)); | ||
} | ||
|
||
const int wordLimit = 2000; | ||
|
||
if (checkWords.Count > wordLimit) | ||
{ | ||
checkWords.RemoveRange(wordLimit, checkWords.Count - wordLimit); | ||
} | ||
|
||
Console.WriteLine($"Suggesting for {checkWords.Count} words"); | ||
|
||
foreach (var word in checkWords) | ||
{ | ||
_ = wordList.Suggest(word); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace WeCantSpell.Hunspell.TestHarness; | ||
|
||
public class SuggestWordTest | ||
{ | ||
public static void Run(string dicFilePath, string word) | ||
{ | ||
var wordList = WordListReader.ReadFile(dicFilePath); | ||
const int wordLimit = 20; | ||
|
||
var results = new List<int>(wordLimit); | ||
var allSuggestions = new HashSet<string>(); | ||
|
||
Console.WriteLine($"Suggesting for word \"{word}\" {wordLimit} times"); | ||
|
||
var options = new QueryOptions | ||
{ | ||
TimeLimitCompoundSuggest = TimeSpan.FromSeconds(10), | ||
TimeLimitCompoundCheck = TimeSpan.FromSeconds(10), | ||
TimeLimitSuggestGlobal = TimeSpan.FromSeconds(10), | ||
TimeLimitSuggestStep = TimeSpan.FromSeconds(10), | ||
MaxSuggestions = 10 | ||
}; | ||
|
||
for (var i = 0; i < wordLimit; i++) | ||
{ | ||
var suggestions = wordList.Suggest(word, options); | ||
allSuggestions.UnionWith(suggestions); | ||
results.Add(suggestions.Count()); | ||
} | ||
|
||
Console.WriteLine("Results:"); | ||
foreach (var r in results) | ||
{ | ||
Console.WriteLine($"{r}"); | ||
} | ||
|
||
Console.WriteLine("Suggestions:"); | ||
foreach (var s in allSuggestions) | ||
{ | ||
Console.WriteLine(s); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>WeCantSpell.Hunspell.TestHarness</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Cocona" Version="2.0.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="WeCantSpell.Hunspell.TestHarness.v3.ncrunchproject" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\WeCantSpell.Hunspell\WeCantSpell.Hunspell.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ProjectConfiguration> | ||
<Settings> | ||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> | ||
</Settings> | ||
</ProjectConfiguration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.