Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'DictionaryLookup for a pair of words' topicStudent Support Forum > General > "DictionaryLookup for a pair of words"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
09/26/12 7:57pm

In Response To 'Re: Re: Re: DictionaryLookup for a pair of words'
---------
Unfortunately I can't test that at the moment here and I did all this by reading the documentation, using a little Mathematica experience and constructing some sample data to test it on. That appeard to work on the test cases that I built in a few minutes.

I recommend you use the usual method of diagnosing Mathematica code, take it apart and see what you get.

Does this work for you as expected?
DictionaryLookup["English", RegularExpression["b......"]

If that doesn't work then you have a small problem to focus on and the help pages should point you in the right direction.

Does this then build up an idex of pairs, where the first item is a list of characters in order and the second item is the word?
bindex = Map[{Union[Rest[Characters[#]]], #} &, DictionaryLookup["English", RegularExpression["b......"]]]

Ah... I see a bug in that now. It worked with my little test cases but I realize that will discard duplicate characters and that would generate more and incorrect matches, not less. Union should have been Sort. Sorry. My test cases didn't think to catch that.

But, do you correctly get two indexes with the appropriate words in them?

Then look at the result of
matches = Intersection[Map[First, bindex], Map[First, mindex]]

Do you see a list of lists of single character strings which should be the target you are looking for.

Then look at the result of
Map[{Cases[bindex, {#, _}], Cases[mindex, {#, _}]} &, matches]

and see if it is pulling the correct index entries. Since you say it is returning nothing there must be at least one step in this fairly short chain that was working with my hand constructed test data and isn't working with your system. You just need to pinpoint where the error is.

Sorry, perhaps I should have let you figure this one out.

URL: ,

Subject (listing for 'DictionaryLookup for a pair of words')
Author Date Posted
DictionaryLookup for a pair of words Mark 09/26/12 07:53am
Re: DictionaryLookup for a pair of words Forum Modera... 09/26/12 11:47am
Re: Re: DictionaryLookup for a pair of words Bill Simpson 09/26/12 3:03pm
Re: Re: Re: DictionaryLookup for a pair of words Mark 09/26/12 4:35pm
Re: Re: Re: Re: DictionaryLookup for a pair of ... Bill Simpson 09/26/12 7:57pm
Re: Re: Re: Re: Re: DictionaryLookup for a pair... Mark 09/27/12 01:04am
Re: Re: Re: Re: DictionaryLookup for a pair of ... Bill Simpson 09/26/12 8:41pm
Re: Re: Re: Re: Re: DictionaryLookup for a pair... Mark 09/27/12 12:00pm
Re: DictionaryLookup for a pair of words Mark 09/26/12 2:09pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic