Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spell checker 3

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
0
0
US
anyone know of a good spell checker? Like if I had an app where people enter text into a field and wanted to do a spell check on it.....

[conehead]
 
By "spell check" do you mean to see if it contains words like "abracadabra", "alakazam", etc.? Are you afraid of someone cursing your computer?


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
converting php into asp shouldnt be that difficult.

You may also find some converting tools online...try google

-DNG
 
Ah, so it is.. I use it for a forum but the forum is in php.. doh !

Anyway, I believe it is a server based service hosted at rather than one you locally use. The local php script you install is more about running the remote service. There is only 1 php file and it looks pretty simple to me (IMHO).

Maybe give converting it a go. If you know C or Java then PHP wont be too foreign.

Hope that helps..

If you do manage to convert it.. maybe you could post a link or the code here for all to use.. ?

A smile is worth a thousand kind words. So smile, it's easy! :)
 
this looks good - any chance it exists in asp/jscript anywhere? [bigsmile]

[conehead]
 
this is what i read on that link:
Code:
The Poor Man's Spell Checker (PMSC) is a simple, lightweight spell-checking script.
[blue][b]The source code is written in VBScript, but you could port it to the language of your choice without too much trouble.[/b][/blue]

-DNG
 
Yeah - I saw that and am trying that, but I am having more trouble than I expected doing that...

[conehead]
 
I am using it in an asp app at the moment. Just put it in as it was and used the example source code for the test page the have on line.

What seems to be the problem?

}...the bane of my life!
 
I need to incorprate it into a page that is asp/jscript - not asp/vbscript....

[conehead]
 
Converting it from VBScript to JScript shouldn't be that hard - just look for comparable functions:

Loading the dictionary file:
Here is some info on the JScript version of dealing with files:
(there are probably better examples if you google passed the first couple)

BTW.. You may want to store it in an Application Variable for quick access if you use it frequently.

Splitting Data into an array:
vbs: aMyArray = split("Some Data here", vbNewLine)
js: var vData = 'Some Data here'; aMyArray = vData.split('\n');

Looping:
vbs: for i = 0 to 12345 .... next
js: for(i=0;i<=12345;i++) { ..do something.. };

Locate String in String:
vbs: instr(1,"123 here 456", "here")
js: var vData = '123 here 456'; iLoc = vData.indexOf('here');

Option based conditional:
vbs: Select sSomeValue .... End Select
js: Switch (vSomeValue) { ..... }

string manipulation:
vbs: left(sData,1)
js: vData.substring(0,1);
(same used for mid & right functions)

string lengths:
vbs: len(myString)
js: myString.length;

and so on...

I've not got time to go through every function in the script, but if you have a particular function / concept you are having difficulty converting then post details and we should be able to give you the answer.

If you do convert it to Jscript - it would be nice to send a copy of the conversion to the originator so that it can be re-used by others, as you have used the original, and post a link here too. Just a thought..

Hope that helps..

p.s. watch out for typo's in the above..

A smile is worth a thousand kind words. So smile, it's easy! :)
 
hey guitardave -

I do not see the functions being called anywhere? How are you getting the functions called using the submitted word?

[conehead]
 
Using the functions in the vbscript, you would do the following:

(assuming that sWordToCheck has been populated somehow.. e.g. through the request.querystring etc.)

1. Call the LoadDictArray function (if this is used a lot cache it in the application object.)
2. Then check to see if the word is spelled correctly:
Code:
   bOK = SpellCheck(PrepForSpellCheck(sWordToCheck))
3. If not, look for a suggestion:
Code:
if not(bOK) then
   aMySuggestionArray = Suggest(PrepForSpellCheck(sWordToCheck))
end if

You can then show the suggestions to the user by iterating through the resulting array.

If you're doing an entire text, not just one word, you should prepare the entire text by removing punctuation and removing double spaces then splitting into an array (using the space char) before processing through the same steps above. (either use the replace function or iterate through each char like the PrepForSpellCheck function in the example script)

To be really effective you will need to present the suggested corrections in a way the user can select whether to accept or reject them - or correct themselves etc. So the array's are probably best passed to the client side (maybe in a javascript array written on the server in the response), and highlighting the word in the text with a link or similar.

A smile is worth a thousand kind words. So smile, it's easy! :)
 
from the site

Code:
<!-- #include file="spell.asp" -->

<form action="tryit.asp" method="get">
<input type="text" name="word" value="<%=Request("word")%>" />
<input type="submit" value="Check" />
</form>

<%
Dim strHaha
Dim strWord

if Request("word") & "" <> "" then
    LoadDictArray

    strHaha = Request("word")

    if SpellCheck(strHaha) then
        Response.Write strHaha & " is spelled correctly.<p />" & vbNewLine
    else
        Response.Write strHaha & " is misspelled.<p />" & vbNewLine
    end if

    Response.Write "Suggestions:<p />" & vbNewLine
    for each strWord in Suggest(strHaha)
        Response.Write strWord & "<br />" & vbNewLine
    next
end if
%>

}...the bane of my life!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top