Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Russian support #231

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions WFInfo/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,10 @@ public int GetDifference(char c1, char c2)
public int LevenshteinDistance(string s, string t)
{
switch(_settings.Locale)
{
{
case "ru":
//for russian
return LevenshteinDistanceRussian(s, t);
case "ko":
// for korean
return LevenshteinDistanceKorean(s, t);
Expand All @@ -592,6 +595,14 @@ public int LevenshteinDistance(string s, string t)
}
}

int LevenshteinDistanceRussian(string firstWord, string secondWord)
{
firstWord = getLocaleNameData(firstWord);
firstWord = firstWord.Replace("Чертеж", "").Replace(":","").Trim();
secondWord = secondWord.Replace("Чертеж", "").Trim();
return LevenshteinDistanceDefault(firstWord, secondWord);
}

public int LevenshteinDistanceDefault(string s, string t)
{
// Levenshtein Distance determines how many character changes it takes to form a known result
Expand Down Expand Up @@ -636,10 +647,15 @@ public int LevenshteinDistanceDefault(string s, string t)
d[i, j] = Math.Min(Math.Min(opt1, opt2), opt3);
}



return d[n, m];
}
//I don't know why this method exists but korean does so does my
public static bool isRussian(String str)
{
char c = str[0];
if (0x0400 <= c && c <= 0x045F) return true;
return false;
}

public static bool isKorean(String str)
{
Expand All @@ -658,7 +674,8 @@ public string getLocaleNameData(string s)
if (marketItem.Key == "version")
continue;
string[] split = marketItem.Value.ToString().Split('|');
if (split[0] == s)
//So the first names can end with the Bluperint while second can start with Blueprint (or maybe vice versa, I forgot), I really don't want to fugure out why is that
if (split[0].Replace("Blueprint", "").Trim() == s.Replace("Blueprint", "").Trim())
{
if (split.Length == 3)
{
Expand Down
4 changes: 2 additions & 2 deletions WFInfo/Ocr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public enum WindowStyle
// Screen / Resolution Scaling - Used to adjust pixel values to each person's monitor
public static double screenScaling;

public static Regex RE = new Regex("[^a-z가-]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
public static Regex RE = new Regex("[^a-z가-힣а-я]", RegexOptions.IgnoreCase | RegexOptions.Compiled);

// Pixel measurements for reward screen @ 1920 x 1080 with 100% scale https://docs.google.com/drawings/d/1Qgs7FU2w1qzezMK-G1u9gMTsQZnDKYTEU36UPakNRJQ/edit
public const int pixleRewardWidth = 968;
Expand Down Expand Up @@ -788,7 +788,7 @@ private static WFtheme GetClosestTheme(Color clr, out int threshold)
/// <returns>If part name is close enough to valid to actually process</returns>
internal static bool PartNameValid (string partName)
{
if ((partName.Length < 13 && _settings.Locale == "en") || (partName.Replace(" ", "").Length < 6 && _settings.Locale == "ko")) // if part name is smaller than "Bo prime handle" skip current part
if ((partName.Length < 13 && _settings.Locale == "en") || (partName.Replace(" ", "").Length < 6 && _settings.Locale == "ko") || (partName.Length < 13 &&_settings.Locale == "ru")) // if part name is smaller than "Bo prime handle" skip current part
//TODO: Add a min character for other locale here.
return false;
return true;
Expand Down
3 changes: 2 additions & 1 deletion WFInfo/Services/TesseractService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ private void getLocaleTessdata()
JObject traineddata_checksums = new JObject
{
{"en", "7af2ad02d11702c7092a5f8dd044d52f"},
{"ko", "c776744205668b7e76b190cc648765da"}
{"ko", "c776744205668b7e76b190cc648765da"},
{"ru", "2e2022eddce032b754300a8188b41419"}
};

// get trainned data
Expand Down
4 changes: 4 additions & 0 deletions WFInfo/Settings/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
Content="한국어"
FontSize="14"
Background="#FF1B1B1B" />
<ComboBoxItem Tag="ru"
Content="Russian"
FontSize="14"
Background="#FF1B1B1B" />
</ComboBox>
</UniformGrid>
</Border>
Expand Down