Area: Quik_Bas Msg: #166 Date: 05-25-92 08:23 (Public) From: Quinn Tyler Jackson To: Mike Kruppenbacher Subject: Re: Phonetic Lookups
MK> hehe.. I never said mine was the BEST approach.. thats
MK> why I am on this echo, anything ONE programmer can
MK> think of, ANOTHER programmer can make better.. hehe..
Mine wasn't the BEST either. Perhaps faster, but only an alternative. BTW,
I took the liberty of downloading a 240,000 word dictionary
from a local BBS. This I then converted into 18 random
access files. I then construed a program that can find
words related to any 4 to 18 letter word, based on your
algo. It is quite fast on a 12 MHZ, with no one word
taking more than a minute to be broken down. It searches
first ?ELLO, then H?LLO, then HEL?O, etc.
I shall post the code, which, as I said, requires dictionaries entitled:
OMNI.3 through OMNI.17
(Omni.3 is a list of 3 letter words, omni.4 is a list of
four letter words....)
Here is the full, functional code, which can be modified
and improved upon, especially the WORD function, which has
to use SELECT CASE in a horrible fashion, due to field
length restrictions....
----CUT HERE-----
' Phonetic Associative Search, as Inspired by Drask
DECLARE SUB assoc (key$)
DECLARE FUNCTION bisearch& (key$)
DECLARE FUNCTION word$ (ptr&, length&)
'DEFLNG is required only if any of the dictionary files has more than
' an INTeger number of entries. Mine do....
DEFLNG A-Z
FOR q = 3 TO 17
file = q - 2
OPEN "c:\test\omni." + RTRIM$(LTRIM$(STR$(q))) FOR RANDOM AS (file) LEN = q
NEXT q
DO
CLS
INPUT key$
assoc key$
LOOP
SUB assoc (key$)
' This is the meat of it
' For every letter in HELLO, cycle through, change from AELLO to ZELLO
' then, next letter, from HALLO to HZLLO, etc....
FOR y = 1 TO LEN(key$)
test$ = key$
FOR x = 1 TO 26
MID$(test$, y) = CHR$(96 + x)
SELECT CASE test$
CASE IS <> key$
'we found a word, so print it out!
IF (bisearch(test$)) <> 0 THEN PRINT test$
END SELECT
NEXT
NEXT
END SUB
FUNCTION bisearch (key$)
length = LEN(key$)
hi = LOF(length - 2) \ length
DO
ptr = (hi + lo) \ 2
comparator$ = (word(ptr, length))
SELECT CASE key$
CASE IS < comparator$
hi = ptr
CASE IS > comparator$
lo = ptr
CASE IS = comparator$
flag = 1
EXIT DO
END SELECT
ctr = ctr + 1
LOOP UNTIL ctr = 30
IF flag = 1 THEN bisearch = ptr
END FUNCTION
FUNCTION word$ (ptr, length)
SELECT CASE length
CASE 3
DIM buf03 AS STRING * 3
GET 1, ptr, buf03
temp$ = buf03
CASE 4
DIM buf04 AS STRING * 4
GET 2, ptr, buf04
temp$ = buf04
CASE 5
DIM buf05 AS STRING * 5
GET 3, ptr, buf05
temp$ = buf05
CASE 6
DIM buf06 AS STRING * 6
GET 4, ptr, buf06
temp$ = buf06
CASE 7
DIM buf07 AS STRING * 7
GET 5, ptr, buf07
temp$ = buf07
CASE 8
DIM buf08 AS STRING * 8
GET 6, ptr, buf08
temp$ = buf08
CASE 9
DIM buf09 AS STRING * 9
GET 7, ptr, buf09
temp$ = buf09
CASE 10
DIM buf10 AS STRING * 10
GET 8, ptr, buf10
temp$ = buf10
CASE 11
DIM buf11 AS STRING * 11
GET 9, ptr, buf11
temp$ = buf11
CASE 12
DIM buf12 AS STRING * 12
GET 10, ptr, buf12
temp$ = buf12
CASE 13
DIM buf13 AS STRING * 13
GET 11, ptr, buf13
temp$ = buf13
CASE 14
DIM buf14 AS STRING * 14
GET 12, ptr, buf14
temp$ = buf14
CASE 15
DIM buf15 AS STRING * 15
GET 13, ptr, buf15
temp$ = buf15
CASE 16
DIM buf16 AS STRING * 16
GET 14, ptr, buf16
temp$ = buf16
CASE 17
DIM buf17 AS STRING * 17
GET 15, ptr, buf17
temp$ = buf17
CASE 18
DIM buf18 AS STRING * 18
GET 16, ptr, buf18
temp$ = buf18
CASE 19
DIM buf19 AS STRING * 19
GET 17, ptr, buf19
temp$ = buf19
CASE 20
DIM buf20 AS STRING * 20
GET 18, ptr, buf20
temp$ = buf20
END SELECT
word$ = temp$
END FUNCTION
---CUT HERE---
Though not perfect, this program gets the job done, and can
be modified, I am sure....
Quinn
--- Maximus/2 2.01wb
* Origin: The Nibble's Roost, Richmond BC Canada 604-244-8009 (1:153/918)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET