# Questions regarding DictionaryLookup of Mathematica

a. Make a function longest[lang_] that gives the length of the longest word in the dictionary of lang. You should get longest["French"]=25

For this part, I have lang = DictionaryLookup[All];
longest[lang_] := Max[StringLength[lang]]

But this isn't working.

b. Now give a list with entries {language,longest[language]}. Table[{lang[[i]], Length[DictionaryLookup[{lang[[i]], All}]]}, {i, 1, Length[lang]}] Again not working

c. Make a function lonegestwords[lang_] that gives the output {longest[lang],lang,longwords} where longwords is the list of the words of longest length in lang.

I tried longestwords[lang_] := {longest[lang], lang, Select[DictionaryLookup[{lang, All}], StringLength[#] == longest[lang] &]}

d. Now get the list with entries longestwords[lang] for all languages and sort it in descending order by the longest word. I know that I have to use Sort[longestwords[lang],#2[[1]]<#1[[1]]&] But since I don't have the function, I can't do it.

You might try the following

languages = DictionaryLookup[All]

longest[lang_] := longest[lang] = Max[StringLength[DictionaryLookup[{lang, All}]]]

SortBy[Table[{lang, longest[lang]}, {lang, languages}], Last]

longestwords[lang_] := longestwords[lang] =
{
lang, longest[lang],
Select[DictionaryLookup[{lang, All}],(StringLength[#] == longest[lang]) &]
}

SortBy[longestwords /@ languages, #[[2]] &]

• Thanks for your help, but do you know how to do part d? What I did is longestwords[lang_] := {longest[lang], lang, Select[DictionaryLookup[{lang, All}],StringLength[#] == longest[lang] &]} and then longestwords[All] but it is taking a long time to give me the answer. Apr 19, 2014 at 22:10
• This can take some time to run because DictionaryLookup downloads some data. Added function for longestwords which I missed first time responding Apr 20, 2014 at 0:02
• This takes less than a minute on my machine, and as little as 10 seconds once the dictionaries are downloaded. Apr 20, 2014 at 0:39