Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//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

This comment has been minimized.

@chuongmep

This comment has been minimized.

Copy link
Owner Author

@chuongmep chuongmep commented Jun 16, 2021

ảnh

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