To load .dic and .aff files we use the following code.
using (var hunspell = new Hunspell("en.aff", "en.dic"))
{
}
But,how do I load NHunspell .dic and .aff files if embedded as resource using c# ?
I am trying out the following code, but it is damn slow.
using (var hunspell = new Hunspell(GetBytes(Properties.Resources.enaff), GetBytes(Properties.Resources.endic)))
{
}
static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
Assuming you have both files as embedded resources in one of your application assemblies, for example:
MyApp.MyAssemblyWithResources
MyApp.MyAssemblyWithResources.AffFile
MyApp.MyAssemblyWithResources.DictFile
Then to load them and use them, do the following: