Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Last active June 16, 2021 06:50
Show Gist options
  • Save chuongmep/365a4bf17c3fccfc9b09e6f9ac9e9c89 to your computer and use it in GitHub Desktop.
Save chuongmep/365a4bf17c3fccfc9b09e6f9ac9e9c89 to your computer and use it in GitHub Desktop.
//https://www.jetbrains.com/help/resharper/Spell_Checking.html#configuring-respeller-inspections
void ex()
{
string path = @"D:\API\dictionaries\dictionaries\vi\index.dic";
string newpath = @"D:\API\dictionaries\dictionaries\vi\index2.dic";
string text = File.ReadAllText(path);
string newtext = RemoveSign4VietnameseString(text);
string[] lines = newtext.Split(
new[] { "\r\n", "\r", "\n" },
StringSplitOptions.None
);
List<string> ss = lines.ToList().Distinct().ToList();
ss.Sort();
string[] strings = ss.ToArray();
strings[0] = strings.Length.ToString();
string textfilter = string.Empty;
foreach (string s in strings)
{
textfilter += s+"\n";
}
File.WriteAllText(newpath,textfilter);
}
public static string[] RemoveDuplicates(string[] s)
{
HashSet<string> set = new HashSet<string>(s);
string[] result = new string[set.Count];
set.CopyTo(result);
return result;
}
public static string RemoveSign4VietnameseString(string str)
{
for (int i = 1; i < VietnameseSigns.Length; i++)
{
for (int j = 0; j < VietnameseSigns[i].Length; j++)
str = str.Replace(VietnameseSigns[i][j], VietnameseSigns[0][i - 1]);
}
return str;
}
private static readonly string[] VietnameseSigns = new string[]
{
"aAeEoOuUiIdDyY",
"áàạảãâấầậẩẫăắằặẳẵ",
"ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ",
"éèẹẻẽêếềệểễ",
"ÉÈẸẺẼÊẾỀỆỂỄ",
"óòọỏõôốồộổỗơớờợởỡ",
"ÓÒỌỎÕÔỐỒỘỔỖƠỚỜỢỞỠ",
"úùụủũưứừựửữ",
"ÚÙỤỦŨƯỨỪỰỬỮ",
"íìịỉĩ",
"ÍÌỊỈĨ",
"đ",
"Đ",
"ýỳỵỷỹ",
"ÝỲỴỶỸ"
};
@chuongmep
Copy link
Author

ảnh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment