 |
|
 |
1
Set up a translation table. You only have to do this once.
For every word in the dictionary, list that word with all its letters in alphabetcal order:
For example, moat becomes amot, rain becomes ainr, needle becomes deeeln
Think of this as left column real word, right column alpha-ordered word
2
Then the utility just has to alpha-order the jumbled word, look it up in the right column of the translation table, and then display the word that is in the left column.
tmoa becomes amot, and when you look that up in the right column you see that moat is in the left column.
I use the word "column" because it's easy to visualize.
|
|
|
|
 |
|
 |
Great work..hats off to u buddy
|
|
|
|
 |
|
 |
hello people ....
i'd want this jumble program..for my engineering mini project..it would be helpful if you can send it as soon as possible...
the program isnt running...i ment the jumble solver..its giving me as many as 25 errors..
if u have any code(which is running). ..a beginner level code..in c/c++..please send it to my mail....mgirish_87@yahoo.com
regards,
girish
seriously in need of it...plz help
|
|
|
|
 |
|
 |
I downloaded the demo project, and using the .net version of the project, I had to convert the project to the latest version of Visual Studio. I then had to remove the tree.h and tree.cpp files, and add-in the trie.h and trie.cpp files. It then built fine.
|
|
|
|
 |
|
 |
seriously thanks a lot for ur concern.......
but plz can u just give the changed program,if u can fuse everything in one module and send it to me..(hope that is possible)...mgirish_87@yahoo.com... so that i can take the print out of it as one source file and run the file and get the output......i m very new 2 programming...just that DA VINCI CODE..inspired me...i thought of learning this...
...so plz it would be nice if u do the needfull.......
thanks a lot again.....
|
|
|
|
 |
|
 |
Very nice.
How about a port to C#?
Don
|
|
|
|
 |
|
 |
Never mind - it was easier than I thought.
Fun algorithm!
Don
|
|
|
|
 |
|
 |
I had code for something like this years ago, that has long since been lost to the "great bit bucket in the sky"--or more likely, the box of dead hard drives in my basement. But, I remember the basic concepts: improve your anagram-solver by using the frequency with which pairs of letters (digraphs) occur in a language. For example, in English the letter pair 'th' will occur way more often than 'kx'. So how do you take advantage of this?
Step #1: build a table of letter pair frequencies by reading in some text--I like to use ASCII text files of long-winded newspaper or magazine articles--and count how many times each possible letter pair occurs. Setting up a 256 x 256 matrix is easiest, but if you want to use UNICODE, be prepared for some headaches.
Step #2: for each permutation of the letters, i.e., each possible solution, total up the net frequency of each pair of letters. (Watch out for overflow if you read in LOTS of source text.) In theory (and pretty consistently in practice) the higher scoring permutations are more likely to be 'real' words.
One neat side effect of this technique is that if you feed your frequency table Italian, it will suggest 'Italian' solutions. You can also use 3, 4, or even 5 letter combinations, but this quickly increases the memory and processing requirements.
Cheers!
Humble Programmer
,,,^..^,,,
|
|
|
|
 |
|
 |
hey. i think you forgot to upload the new version of your program. the main files are still named "tree.*" and not "trie.*".
just an advice
|
|
|
|
 |
|
 |
This should be fixed, as I've sent off new zips to be put in the old zips place. Sorry about that, no idea how it happened.
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
 |
|
 |
ecaxtly what i wanted. an anagram solver.
good job.
|
|
|
|
 |
|
 |
for my beloved Mac You can get interesting results using these kinds of programs, for instance
bill gates -> legal bits
margaret thatcher -> the great charm rat
Fredrik
|
|
|
|
 |
|
 |
Actually, Such code take more time than designing GUI, Its worth for 5 stars,
I was successful only with max 7 character in Turboc 3.0, Thats cool, You made my day and solved all my unsolved puzzels
Cheers
Balkrishna Talele
|
|
|
|
 |
|
 |
There is a compile error C2664 in function:
vector CTree::GiveWords(const char* word)
{
...
}
with the two statements returning NULL. NULL is not of the correct data type of your function prototype.
Art
|
|
|
|
 |
|
 |
Forgot about that, I've modified the source to return a pointer to the vector like I originally planned. In my update I will also include a demo project for .NET.
Greba
|
|
|
|
 |
|
 |
I while back I threw together a simple single word anagram solver in PERL.
What I did was to first sort the letters in the jumbled word.
Then I'd iterate over a word list, taking each word of the same length as the jumbled word, sorting the letters in it, and comparing it to the (now sorted) jumbled word.
Then printing out each match.
Not a very complex algorithm but it gets the job done pretty quickly.
Searching the web without Google is like straining sewage with your teeth. Userfriendly, 2003/06/07
|
|
|
|
 |
|
 |
Using all the letters makes this into an anagram.
Getting all the possible words using one or more of the letters in your initial word is a jumble.
Not that this changes the validity of your code...
Iain.
|
|
|
|
 |
|
 |
I don't know about a jumble being "all the possible words using one or more of the letters in your initial word".
I always thought an anagram was to create a phrase but looking up the definition of anagram makes me realize it can be both a single word and a phrase.
The reason I named it "Jumble Solving Utility" because the utility solves the problem called Jumble. When I do an update I'll include anagram in the problem definition though.
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
 |
|
 |
A Jumble is a set number of letters that must be rearranged to make one word (or sometimes a phrase.) An anagram is simply a word that can be made into other words using exactly the same letters. Example:meat mate team tame meta
A jumble could form more than one word using all the letters. As the number of letters increases the number of valid words decreases (probably on some exponential like scale).
|
|
|
|
 |
|
 |
Lately I have been researching Scrabble bots. Boggle is also a similar game. Given a jumble of letters (the rack of Scrabble tiles each player has) and a dictionary, what words can be made. Scrabble bots go step further because only a subset of qualified words will fit on the board with the other previously played words.
Anyway, setting up the dictionary as a tree is the preferred method only the correct term is 'trie'. A trie is specifically a tree for storing strings in which there is one node for every common prefix. The strings are stored in extra leaf nodes. But it doesn't stop there. The dictionary for use with Jumble,Scrabble or Boggle creates a huge trie. These trie can be further compacted in to something called a DAWG or Directed Acyclic Word Graph which reduces its size significantly. Almost all Scrabble bots employ some form of DAWG.
For more info on this stuff see http://www.gtoal.com/wordgames/scrabble.html.
Additionally, a nice explaination of how the trie and dawg are used is here: http://www.gtoal.com/wordgames/jacobson+appel/aj.pdf
|
|
|
|
 |
|
 |
Thanks for the links.
Will definetly look into this DAWG data structure.
I will correct my terminology when I do an update.
Never thought about creating a scrabble bot; is a neat idea and might let me win all those games I play againest my family
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
 |
|
 |
All your work seems very complex. Using tree nodes to go about the difficult task of finding other words within a jumbled set?
However, your idea of using a letter frequency count program is of course the solution to your problem to find smaller words contained within a jumbled set.
Below is my code for a jumble solving utility: It's fast and efficient and doesn't include any nonsense with classes or NODAL analysis.
*****************************************************
#include
#include
#include
#include
int main()
{
fstream file_pointer_in;
fstream file_pointer_out;
file_pointer_in.open("dict.txt",ios::in);
file_pointer_out.open("contain.txt",ios::out);
int a,b;
char array[81];
cout<<"Enter word:"<<endl;
cin>>array;
cout<<"Calculating possibilities..."<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
int mass;
mass = strlen(array);
char alphabet[28]={"/abcdefghijklmnopqrstuvwxyz"};
int alphacount[26];
int betacount[26];
//initialise
for (int i=1; i<27; i++)
{
alphacount[i]=0;
}
for(a=0; a>
char x[81];
do{
file_pointer_in>>x;
int size;
size = strlen(x);
for (int i=1; i<27; i++)
{
betacount[i]=0;
}
for (int i=0; i>stop;
file_pointer_in.close();
file_pointer_out.close();
}
*******************************************************
ALL YOU NEED TO DO IS INCLUDE A DICTIONARY FILE IN C:
call the notepad file "dict.txt"
Enjoy!
|
|
|
|
 |
|
 |
#include < stdio.h >
#include < iostream.h >
#include < string.h >
#include < fstream.h >
Strangely these were omitted. No idea why but there u go!
|
|
|
|
 |
|
 |
I haven't run your code but it looks like it works. The reason that I put my code into a class was to make it easier to use from other code. For someone to use your code they would have to modify your code, while with my code all you should have to do is add the .cpp and .h files to there project, and then just use the class for a specific use.
A comment about your code: it only allows one word to be found for each run. I'm sure it could be modified to find several words but my code has a initial startup (reading in the dictionary) and then a very small cost for all searches, and a cost for a final deletion (memory freeing).
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
 |