Post Reply 
How much memory may a HPPL program use on a G2?
09-13-2023, 10:23 PM (This post was last modified: 09-14-2023 06:16 AM by komame.)
Post: #57
RE: How much memory may a HPPL program use on a G2?
This is the moment when I reveal the details of my solution Smile
Although it might seem very complex, in reality, the algorithm is straightforward, and, moreover, really fast.

The program is named CROSSWORDS.
It performs word matching to a pattern - crossword search, where we input only known letters, and we use '?' in place of unknown ones.
Here, diacritics are ignored, meaning their Latin equivalents are considered for the search. However, if we were to abandon this by implementing an exact word matching, it would further speed up the search because conversion would not be necessary.
During searches, letter case doesn't matter; the program converts everything to uppercase.

Usage examples:
CROSSWORDS("ROTI?") => {"ROTIN","RÔTIE","RÔTIR","RÔTIS","RÔTIT","RÔTÎT"}
CROSSWORDS("?A?TS") => {"FAITS","FARTS","GANTS","HARTS","HASTS","HAUTS","KARTS","LAITS","MALTS","PARTS","RAPTS","SAUTS","TACTS","WATTS"}
CROSSWORDS("P?T")   => {"PAT","POT","PST","PUT","PÛT"}
CROSSWORDS("P?AT")  => {"PLAT","PUÂT"}


If at least one letter at the beginning of the word is specified (meaning the pattern doesn't start with '?'), a binary search is activated, significantly reducing the time to obtain results. If there is a '?' at the beginning, this binary search cannot be used, and then the dictionary is scanned, which takes considerably longer.

Unfortunately, I overlooked one thing, and my spell-checking didn't work completely correctly (in some cases). That's why I removed that part from my solution for now, and I'll add it later.
EDIT: I finally concluded that spell-checking functionality is unnecessary because by explicitly providing all the letters of the word, all permissible forms of that word will appear in the result. There will be few of them, as they may differ only in accents, if the language uses them at all.

CROSSWORDS("dEs")   => {"DES","DÈS","DÉS"}
CROSSWORDS("Age")   => {"ÂGE","ÂGÉ"}



Congratulations to everyone who made it this far in this thread.
Attached is the complete solution with a dictionary from 2 to 9-letter words (currently French). If you want longer words, you'll need to add them to the 'WordDict' file in the same way it's done for other word lengths.
You can replace the dictionary with a different language, but it's important that the words are sorted alphabetically. If you change the language, adjust the function for converting diacritics: 'convAccents'.

If anyone wants to delve deeper into how it works, I'd be happy to explain (if someone asks).

Best wishes,
Piotr Kowalewski


Attached File(s)
.zip  CROSSWORDS.zip (Size: 990.99 KB / Downloads: 12)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How much memory may a HPPL program use on a G2? - komame - 09-13-2023 10:23 PM



User(s) browsing this thread: 2 Guest(s)