Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: robert8192 on July 16, 2010
-
Hi everybody. ::)
I have this great small spell checker I am working on
I have come to a point where it is , almost done
and need just a bit of help. :buddies:
It is based a the JNK wordchecker from Blitz3d
I have below two zip files... ONE for FB and the original
in blitz.. If you run the blitz one, you will see it works fine.
You can even plug in a '?' for an empty letter.
It works extremely fast, and I though maybe some FB
GURU could help me fix it.
http://www.publicdomaindvds.com/zipps/BB_SPELLING_CHECK.zip (http://www.publicdomaindvds.com/zipps/BB_SPELLING_CHECK.zip)
and the FB one is
http://www.publicdomaindvds.com/zipps/FB_SPELLING_CHECK.zip (http://www.publicdomaindvds.com/zipps/FB_SPELLING_CHECK.zip)
Please help me fix it.. thanks
I have made a few modifications to the code. The most major one
is when taking data into and out of the ALLOCATED SPACE,
I did not use BYTE, but switched this to an INT, because I could not figure
a good way to do it as it was done originnaly.
Robert
-
This thread is resolved.
I fixed the problem.
Here is a repost of the completed code.
Use it as you will. A big thanks for JNK posting
it originally in the B3d forum.
LINK
http://www.publicdomaindvds.com/zipps/FB_SPELL_CHCK.zip (http://www.publicdomaindvds.com/zipps/FB_SPELL_CHCK.zip)
If anyone has a better one, or uses this is
any great games, or vrossword makers, I
would love to hear about thim in this thread.
Here are some general notes on the code.
---------------------------------------
generate code bank
---------------------------------------
function takes words directly from text files and
encodes then into one file.
The letters are coded into binary parts 5 bits long
and placed 5-at-a-time into an integer. Now, when an
INT gets read in from the bank, it will be converted
with the BIN$ function and the bin function leaves
off the starting "0"'s so a three bit code it
appended to the end of each INT as in here-->
'00000000000000000000000000000XXX'
Each letter is coded here-->
'11111222223333344444555550000XXX'
This three bit code tells the DECODETEXT function
how many bits to append at the start of the INT in the bank.
Thus, to test a word, you ENCODE it like the
encoded data, and compare the ENCODE against
the data in the bank.
---------------------------------------
setup code bank
---------------------------------------
all setup does is put the wordbank from the file into
an array. no conversion happens.
---------------------------------------
Check Word
---------------------------------------
This function takes a word you send it, makes it
upper case and encodes it the same way as
GENERATE code bank did.
If an '?' chars are found it does a recode of the
ENCODE with zeroes in that place, and when
comparing words, does the same to the
word it is comparing it to. Thus, it can find a word
using wildcards.
when a match is found, it ends and displays the
FOUND Word as a return code.
---------------------------------------
EncodeText
---------------------------------------
takes a 5-letter string and encodes it into
the 5 bit code representing that letter.
makes it 29 bits--
Then it adds the 3 bit code to the end
---------------------------------------
DecodeText
---------------------------------------
takes in a 32 bit binary. Sometime this binary
is less than 32 bits as the BIN$ function leaves
them off, the we use MakeIt32 to make it 32 bits
again.
Then it converts the 5-bit binary parts into ascii
characters again, and returns them as a string
---------------------------------------
bin2int
---------------------------------------
converts the binary number into as integer
---------------------------------------
MakeIt32
---------------------------------------
takes a binary number as a string
and remakes the 5 bit codes complete
by adding the addon 3-bit code from the end
positions, back onto the front of the code,
'then remakes the string to a perfect 32-bit
string .
---------------------------------------
wildcard
---------------------------------------
takes in the testword, and alternatively the search word,
and replaces a 5-bit portion with '00000' in the places
where a '?' is placed.
--------------------------
Later - everybody - have a great summer.
-
good to know that you fixed her.
welldone.