Help with Mathematica? Find Dictionary Lengths & Longest Words

  • Mathematica
  • Thread starter fruitbygrace
  • Start date
  • Tags
    Mathematica
  • #1
Part A:
Get the list of pairs of the form {language,number of words in dictionary}. Call this list Alength.

What I did:
lang = DictionaryLookup[All] to get all the languages. Then,
Alength = {Length[DictionaryLookup[{"Finnish", All}]], Length[DictionaryLookup[{"Arabic", All}]]}...}

What is a shorter way of doing this?


-------------
Part B:

Get a list of the form {language, length longest word in the dictionary}. Call this list longestword.

I did:
longestword = Max[DictionaryLookup[All]]

But that's not coming out correctly.


--------------
Part C:
Look at all the words contained in all the dictionaries. What are the ones of maximum length?

I did:
Max[StringLength[lang]]

It comes out as 19, but I think there's something wrong here as well.


--------------
Part D:
What are all the words of length 20 in the Mathematica English dictionary.
This one I have no idea.
 
  • #2
Part A:
Get the list of pairs of the form {language,number of words in dictionary}. Call this list Alength.

What I did:
lang = DictionaryLookup[All] to get all the languages. Then,
Alength = {Length[DictionaryLookup[{"Finnish", All}]], Length[DictionaryLookup[{"Arabic", All}]]}...}

What is a shorter way of doing this?

Almost every time you "want to do the same thing to every element in a list" the solution is to use the Map function. Look in the help system for Map and see if you can see a way to use that.

There are two methods of using this, first to define a function like f and then use Map[f, lang], the second is to use a shortcut method of defining functions using # and &. That second method is probably difficult to understand initially, so using the first method might be best to start with.

Part B:

Get a list of the form {language, length longest word in the dictionary}. Call this list longestword.

I did:
longestword = Max[DictionaryLookup[All]]

But that's not coming out correctly.

Hint: What is DictionaryLookup[All] and what would Max of that be? Why would that not be what you want? It is also possible that you might have mis-quoted that question.


Part C:
Look at all the words contained in all the dictionaries. What are the ones of maximum length?

I did:
Max[StringLength[lang]]

It comes out as 19, but I think there's something wrong here as well.

Again, look at StringLength[lang] and see if that is exactly what Max will accept.

Part D:
What are all the words of length 20 in the Mathematica English dictionary.
This one I have no idea.

Study the hints. Try to understand the method they are suggesting for diagnosing when something doesn't work. Then see if you can apply those ideas to make progress on the last problem.
 

Suggested for: Help with Mathematica? Find Dictionary Lengths & Longest Words

Replies
1
Views
881
Replies
1
Views
436
Replies
2
Views
924
Replies
1
Views
685
Replies
2
Views
1K
Replies
1
Views
605
Replies
6
Views
901
Back
Top