 |
|
 |
Looks like the version I downloaded gets cranky if a textbox is shrunk to 0 height or width. I added the following:
Private Sub TextBoxBase_ClientSizeChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim tempTextBox As TextBoxBase = sender
If (tempTextBox.Width = 0) Or (tempTextBox.Height = 0) Then
Return
End If
An exception check would probably work as well. I tried to submit a SourceForge bug, but their login page was not working for some reason.
Thanks for an awesome tool!
|
|
|
|
 |
|
 |
I am attempting to use NHunspell 0.9.6 within an ASP.NET web application deployed underneath a SharePoint 2007 installation running on a Windows 2003 x64 server farm. I have so far gotten it to work but I have noticed that after about a few calls to the DLL, the application begins to hang. If I comment out my calls to the Hunspell object, the hang goes away. I am calling Dispose() on the Page.Unload() event and I hoped that would release the resource, but this problem won't go away. In the process explorer I see that the IE8 process status is waiting on something.
Has anyone else experienced this? My guess has something to do with the x64 environment, but I don't have anything to base this on.
Randy
|
|
|
|
 |
|
 |
Hi ,
I have placed the dll with hunspell spell check in dev server and placed all the required files in root folder, but im getting the exception "AFF file not found" when trying to view the page.
Its working fine in my local machine.
Any idea why is it so? is it expecting the aff file to be in the server machine somewhere??
|
|
|
|
 |
|
 |
Hi,
In my web app, I have some javascript that sends text from a textarea to the server using ajax when there has been no typing for 250ms, to update a div that shows spell-checked text. This works fine for the most part.
However, every now and then, the code throws an InvalidOperationException. When it happens, it usually happens quite a few times in a row, then suddenly it stops happening again.
All I have is what little ELMAH has salvaged from the exception:
System.InvalidOperationException: Stack empty.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at NHunspell.SpellFactory.Spell(String word)
at EuroSpell.LanguageAnalyzer.WordIsSpelledCorrectly(LanguageName language, String word)
(The EuroSpell stuff is obviously my code, with more of the same following)
The surprising stuff is that this comes and goes - it works perfectly fine in 97% of the requests (number made up, but probably within 10% of the correct value), and then suddenly doesn't work for a little while.
My own logs show that this rarely happens on the first word in a request (I am looping through all the words posted, naturally), it some times happens towards the end of the stream of words.
My problem is basically that I don't know why this happens, and can't seem to find out from the exception data either. Is there a way to debug myself out of this?
|
|
|
|
 |
|
 |
How do you construct your SpellFactory? Is this been done in AppInit or do you use code like this:
if( spellfactory == null )
spellfactory = new SpellFactory( ...
spellfactory.Spell( ... )
Can you post some code how you init SpellFactory and how you call Spell()?
|
|
|
|
 |
|
 |
Hi Thomas, thanks for your reply.
This is an ASP.NET MVC application. For context; I have a specific controller called SpellController that handles all spell requests. In this particular site, only administrators can edit text and are affected by spelling - so this controller only exists when an admin is logged on and doing some editing.
Further, the site supports three languages - english, norwegian and danish. Each page being edited has an indicator of the language, so that I can spell check properly.
Before you replied to my question, I actually didn't use the SpellFactory at all. I don't remember why, but what I ended up doing was creating three LanguageConfig objects, then created a SpellEngine and did an _engine.AddLanguage with the config for each language. Spellchecking was done via this method:
return _engine[code].Spell(word);
Where code was the language code given in the LanguageConfig objects.
This works very well, except for the occasional exception as stated above.
However, because of your suggestion, I also went ahead and added a way to do this with three SpellFactory objects instead of the single SpellEngine. I used the same LanguageConfig except I had to set the "Processors" property (I set it to 2 just for fun, didn't research a proper value yet).
Now I get the exception on either the first request, or soon after, after a seemingly random amount of words (the controller calls this spell method for each word in the article being edited).
Here is an example of how I do it for the norwegian language:
var noConfig = new LanguageConfig
{
LanguageCode = "no",
HunspellAffFile = _appPath + @"\Dictionaries\nb_NO.aff",
HunspellDictFile = _appPath + @"\Dictionaries\nb_NO.dic",
HunspellKey = "",
Processors = 2
};
_norskFactory = new SpellFactory(noConfig);
(I hope the formatting for this is sane)
Then in another method:
var factory = FactoryFromLanguage(language);
return factory.Spell(word);
The FactoryFromLanguage() methods just gets the correct SpellFactory() for the given language code.
The first time I get an exception, I get a NullReferenceException (Object reference not set to an instance of an object) on the factory.Spell(string) method. There is no inner exception. The factory object is not null, so there must be something inside it.
If I now refresh the page that does the spellchecking via ajax, I get a different exception in the same place. InvalidOperationException with a message "Stack empty", no inner exception.
If you need any further information from me, please let me know, I am eager to figure this out. Again, thank you very much for the help!
|
|
|
|
 |
|
 |
Hi Rune,
is there any reason why you don't use the Singleton pattern that I proposed in this article:
http://www.codeproject.com/KB/recipes/spell-check-asp-net-web.aspx
Here is the basic building block:
public class Global : System.Web.HttpApplication
{
static SpellEngine spellEngine;
static public SpellEngine SpellEngine { get { return spellEngine; } }
...
protected void Application_Start(object sender, EventArgs e)
{
try
{
string dictionaryPath = Server.MapPath("Bin") + "\\";
Hunspell.NativeDllPath = dictionaryPath;
spellEngine = new SpellEngine();
LanguageConfig enConfig = new LanguageConfig();
enConfig.LanguageCode = "en";
enConfig.HunspellAffFile = dictionaryPath + "en_us.aff";
enConfig.HunspellDictFile = dictionaryPath + "en_us.dic";
enConfig.HunspellKey = "";
enConfig.HyphenDictFile = dictionaryPath + "hyph_en_us.dic";
enConfig.MyThesIdxFile = dictionaryPath + "th_en_us_new.idx";
enConfig.MyThesDatFile = dictionaryPath + "th_en_us_new.dat";
spellEngine.AddLanguage(enConfig);
}
catch (Exception ex)
{
if (spellEngine != null)
spellEngine.Dispose();
}
}
protected void Application_End(object sender, EventArgs e)
{
if( spellEngine != null )
spellEngine.Dispose();
spellEngine = null;
}
That ensures you have only one SpellEngine in your app.
Best regards Thomas
|
|
|
|
 |
|
 |
Hi Thomas,
I am using the singleton pattern - at a different level. I.e. I have wrapped all the NHunspell stuff in my own class called LanguageAnalyzer - this is used as a singleton in my web application. So even if the actual instances of SpellFactory/SpellEngine are not singleton instances as such (i.e. not static), the containing class is, so there should never be more than one instance.
Thanks again!
|
|
|
|
 |
|
|
 |
|
 |
Hi,
I am trying to use NHunspell (v0.9.4.0) in a class library which in turn is being used by an ASP.NET MVC 2 application running under .Net 4.0 on a Win2008 R2 server with IIS 7.5. When the libraries are (attempted) loaded, it complains about not being able to load the AMD (!?) version of the native file:
Hunspell AMD 64Bit DLL not found: C:\inetpub\websites\testsite\Hunspellx64.dll
(This directory is the same as AppDomain.CurrentDomain.BaseDirectory)
The file it refers to is there (and so is the 32 bit version), and the web service has full access to the directory.
The server is an Intel Quad Core - no AMD at all.
And the same works on my dev machine - a 32 bit Vista machine.
How on earth can I get it to accept that the file is there?
Thanks!
|
|
|
|
 |
|
 |
Are you sure that the DLLs are here:
C:\inetpub\websites\testsite\Hunspellx64.dll
and not here:
C:\inetpub\websites\testsite\bin\Hunspellx64.dll
NHunspell hasn't used the bin folder in 0.9.4, this is fixed in 0.9.5, please download it from sourceforge
|
|
|
|
 |
|
 |
This was a bit hard to debug because it is an ASP.NET MVC application, where all binaries are apparently in the \bin\ folder.. But after a good debugging session and updating to 0.9.6 (since that came out in the meantime), it works!
Thank you very much for the help and the library. You are a hero!
|
|
|
|
 |
|
 |
Hi,
I am using NHunspell to work on my current project.
Just wondering if there is any way that I can edit the Thes and dictionary file.
The current project that I am working now requires me to do editing to the files.If anyone know how to go about doing it, please tell me. Thank you.
Other than that, how is AddWithAffix being use? The word will be added to the dictionary? Wha about the example? How do we retrieve it ???
Viki
|
|
|
|
 |
|
 |
Hunspell dictionaries are simple text files. A good starting point how to write your own or modify some existing is the Open Office Lingucomponent Project Pages
http://lingucomponent.openoffice.org/
AddWithAffix() is used to add a word with affixiation of a exampe. e.G.
bool spellBefore = hunspell.Spell("phantasos");
spellBefore = hunspell.Spell("phantasoses");
add = hunspell.AddWithAffix("phantasos","fish"); // this fantasy word is affixed like the word fish ( plural es ...)
spellAfter = hunspell.Spell("phantasos");
spellAfter = hunspell.Spell("phantasoses"); // the plural (like fish) is also correct
The word will be added to the INTERNAL directory (never written to disk) with the same affixiation as the sample (plural, tenses ... )
|
|
|
|
 |
|
 |
hi! we are 3 students from Portugal and we have a project in development that consists in a script (in Jscript) for Messenger Plus! that does spell checking using NHunspell. In my computer the solution is running, but when i try to export it, it wont work... Always fails when i test the script (.js) file. I think it is related to the COM and/or .Net registering part. Even making batch files to register the dll files with regasm isn't working... I have the following files: Hunspellx86.dll that is used by NHunspell.dll that is used by NM.dll... and in the script file, i created an ActiveXObject(x.y) where x is the namespace and y the class that NM.dll exposes. Could use some help! Thanks for the shared work
|
|
|
|
 |
|
 |
I'm not familiar with ActiveX. Some scripting environments needs parameterless constructors. They are provided in the new 0.9.5 version of NHunspell
|
|
|
|
 |
|
 |
Hi Thomas,
Thanks for wrapping the code into a C# dll
To get used to the code, I created a small console application and everything is working fine.
But when I used the same code on a windows application,
string test = "keep";
bool correct = hunspell.Spell(test);
'correct' is returning always false.
Them I tried to type the word "keep" in the console application and it worked
Do you have an idea of what the problem could be?
thanks again
sandro
|
|
|
|
 |
|
 |
hi again
I made another simple windows app application and here it is also working :/
In my original application for some reason it is not working!
any help?
|
|
|
|
 |
|
 |
Hi again!!
I think I solved the problem!
I followed the steps suggested by Heinrich on 13th March 2009, by adding the full path.
I think that since in my code I am selecting a file from the hardisk, the application is 'loosing' the directory!
If you would need more info about the problem, do not hesitate to contact me.
thanks again
sandro
|
|
|
|
 |
|
 |
Hi,
I used NHunspell in an application for digital subtitle editing, that is the base of my thesis for the University, and I'm having problems with adding new words to the dictionaries:
using the Add method of the Hunspell class always returns false.
A simple piece of code like this won't work.
Hunspell hun = new Hunspell("es_ES.aff","es_ES.dic");
hun.Add("Brau");
I don't know what can I be possibly doing wrong.
I also tried to add the same functionality to the code of the samples provided with 0.9.2 version of NHunspell, and also returns always false.
Thanks in advance.
|
|
|
|
 |
|
 |
Hey, I just wanted to mention that I had the same problem. And yes it always does return false. But what is also really not explained very well, that the ADD is only during the life of the Object. So in your example,
Hunspell hun = new Hunspell("es_ES.aff","es_ES.dic");
hun.Add("Brau");
The word Brau does indeed get added, but only remains during the live of "Hun". Once that gets destroyed, no additions remain. It seems to me that you have to maintain your "custom" list and add them everytime you run the spell check.
Let me know if you find anything otherwise.
Thanks JJ
|
|
|
|
 |
|
 |
JJ, this is the desired behaviour of Add(). You must stor your user dirctionary yourself.
BR Thomas
|
|
|
|
 |
|
|
 |
|
 |
Has there been any thought or work done into getting this into an ExtenderProvider format to extend controls to provide spell checking capabilities?
|
|
|
|
 |
|
 |
Yes. It will be done when we do a WCF project with spell checking in my company, because then i get the time and money to do this. Several other things are in our focus, like TinyMCE support etc. Maybe we implement this for WinForms too, to be complete. But there is no timeframe for this at the moment.
Regards Thomas
|
|
|
|
 |