Jump to content

Anagram Solver


maeliawilson
 Share

Recommended Posts

Hiya all!I am trying to build a basic anagram solver that looks through all possibilities for words, check weather they are true, and acts accordingly.Imput = "TAE"Word(1) = "TEA"Word(2) = "ATE"Word(3) = "AET"Word(4) = "ETA"Word(5) = "EAT"For i = 1 to 5If isRealWord(Word(i)) Then Ans(i) = TrueElse Ans(i) = FalseEnd IfNext' RESULTAns(1) = True 'Tea is a real wordAns(2) = True 'Ate is a real wordAns(3) = False 'Aet is NOT a real wordAns(4) = False 'Eta is NOT a real wordAns(5) = True 'Eat is a real word' OUTPUTAnagrams:TeaAteEatI need to have a function (isRealWord) that can check a wrod inside an external dictionary.If there is a downloadable dictionar DLL I can get hold of, please tell me, or how I could contenct to a Microsoft Word dictionary WITHOUT opening Word.

Link to comment
Share on other sites

You can find word lists via Google. I downloaded one of 350,000 words into a MySQL table. To make it useful for anagrams I would have to add the word root for each one. (another one for the "ToDo" list)

FYI - word root is the letters of the word in alphabetical order (eg root of anagram is aaagmnr). Words with the same root are anagrams of one another.

Once that is done, it would be simple to search for the root and get all the anagrams.

The bad news for your app is that my list contains both

  • aet - after extra time
  • eta - estimated time of arrival

example

mysql> select word from wordlist
    -> where word like 'aet%'
    -> limit 25;
+----------------+
| word           |
+----------------+
| aet            |
| aetat          |
| aethalia       |
| aethalioid     |
| aethalium      |
| aetheling      |
| aetheogam      |
| aetheogamic    |
| aetheogamous   |
| aether         |
| aethereal      |
| aethered       |
| aetheric       |
| aethers        |
| aethogen       |
| aethon         |
| aethrioscope   |
| aetiogenic     |
| aetiological   |
| aetiologically |
| aetiologies    |
| aetiologist    |
| aetiologue     |
| aetiology      |
| aetiophyllin   |
+----------------+
25 rows in set (0.04 sec)

 

Link to comment
Share on other sites

59 minutes ago, NotionCommotion said:

What about a many-to-one between the words and the root?

No problem

TABLE wordlist
+--------------+-------------+
|  word        |   root      |
+--------------+-------------+
| ate          | aet         | 
| eat          | aet         | 
| eta          | aet         | 
| tea          | aet         |
+--------------+-------------+ 
  • PK on word
  • INDEX on root.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.