1
Freebasic / Re: FB Spelling Check Include
« on: July 20, 2010 »
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
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.
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
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.

