-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Added new SpellCheckTest() and submodule (common/Tests/Frontend.Translations.Tests/dictionaries) + Split tests on categories FastRunning|LongRunning + Added new build/run.translations.spellcheck.test.bat
- Loading branch information
1 parent
649e1b4
commit 4274e3a
Showing
9 changed files
with
222 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PUSHD %~dp0.. | ||
dotnet test common\Tests\Frontend.Translations.Tests\Frontend.Translations.Tests.csproj --filter Name~SpellCheckTest -l:html -r TestsResults |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
PUSHD %~dp0.. | ||
dotnet test common\Tests\Frontend.Translations.Tests\Frontend.Translations.Tests.csproj -l:html -r TestsResults | ||
dotnet test common\Tests\Frontend.Translations.Tests\Frontend.Translations.Tests.csproj --filter "TestCategory=FastRunning" -l:html -r TestsResults |
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
36 changes: 36 additions & 0 deletions
36
common/Tests/Frontend.Translations.Tests/Models/SpellCheckResult.cs
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,36 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Frontend.Translations.Tests.Models | ||
{ | ||
public class SpellCheckResult | ||
{ | ||
private Regex wordRegex = new Regex(@"\p{L}+", RegexOptions.Multiline | RegexOptions.Compiled); | ||
|
||
public SpellCheckResult(string text) | ||
{ | ||
Text = text; | ||
|
||
Words = wordRegex.Matches(text).Select(m => m.Value) | ||
.Where(w => !string.IsNullOrEmpty(w)) | ||
.Where(w => !w.StartsWith("{{")) | ||
.ToList(); | ||
|
||
SpellIssues = new List<SpellIssue>(); | ||
} | ||
|
||
public string Text { get; } | ||
public List<string> Words { get; } | ||
|
||
public List<SpellIssue> SpellIssues { get; set; } | ||
|
||
public bool HasProblems | ||
{ | ||
get | ||
{ | ||
return SpellIssues.Any(issue => issue.Suggestions.Any()); | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
common/Tests/Frontend.Translations.Tests/Models/SpellIssue.cs
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,16 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Frontend.Translations.Tests.Models | ||
{ | ||
public class SpellIssue | ||
{ | ||
public SpellIssue(string word, IEnumerable<string> suggestions) | ||
{ | ||
Word = word; | ||
Suggestions = suggestions; | ||
} | ||
|
||
public string Word { get; } | ||
public IEnumerable<string> Suggestions { get; } | ||
} | ||
} |
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,88 @@ | ||
using System; | ||
|
||
using WeCantSpell.Hunspell; | ||
|
||
namespace Frontend.Translations.Tests | ||
{ | ||
public static class SpellCheck | ||
{ | ||
public static Models.SpellCheckResult HasSpellIssues(string text, WordList dictionary) | ||
{ | ||
var result = new Models.SpellCheckResult(text); | ||
|
||
foreach (var word in result.Words) | ||
{ | ||
if (!dictionary.Check(word)) | ||
{ | ||
result.SpellIssues.Add(new Models.SpellIssue(word, dictionary.Suggest(word))); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static string GetDictionaryLanguage(string lng) | ||
{ | ||
// az,bg,cs,de,el,en,en-US,es,fi,fr,it,ja,ko,lo,lv,nl,pl,pt,pt-BR,ro,ru,sk,sl,tr,uk,vi,zh-CN | ||
switch (lng) | ||
{ | ||
case "az": | ||
return "az_Latn_AZ"; | ||
case "bg": | ||
return "bg_BG"; | ||
case "cs": | ||
return "cs_CZ"; | ||
case "de": | ||
return "de_DE"; | ||
case "el": | ||
return "el_GR"; | ||
case "en": | ||
return "en_GB"; | ||
case "en-US": | ||
return "en_US"; | ||
case "es": | ||
return "es_ES"; | ||
//case "fi": | ||
// return ""; | ||
case "fr": | ||
return "fr_FR"; | ||
case "it": | ||
return "it_IT"; | ||
//case "ja": | ||
// return ""; | ||
case "ko": | ||
return "ko_KR"; | ||
//case "lo": | ||
// return ""; | ||
case "lv": | ||
return "lv_LV"; | ||
case "nl": | ||
return "nl_NL"; | ||
case "pl": | ||
return "pl_PL"; | ||
case "pt": | ||
return "pt_PT"; | ||
case "pt-BR": | ||
return "pt_BR"; | ||
case "ro": | ||
return "ro_RO"; | ||
case "ru": | ||
return "ru_RU"; | ||
case "sk": | ||
return "sk_SK"; | ||
case "sl": | ||
return "sl_SI"; | ||
case "tr": | ||
return "tr_TR"; | ||
case "uk": | ||
return "uk_UA"; | ||
case "vi": | ||
return "vi_VN"; | ||
//case "zh-CN": | ||
// return ""; | ||
default: | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} | ||
} |
Submodule dictionaries
added at
8222c8