1
$\begingroup$

Question1: Get the list of pairs of the form {language,number of words in dictionary}. Call this list langlength

What I did was this:

langlength = 
  {{Arabic, Length[DictionaryLookup[{"Arabic", All}]]}, 
   {BrazilianPortuguese, Length[DictionaryLookup[{"BrazilianPortuguese", All}]]}, 
   {Breton, Length[DictionaryLookup[{"Breton", All}]]},......}

And so on. What's a shorter way of doing this?


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

I had:

Max[StringLength[lang]]

But that's not working and not sure what's missing.

Please help me with either or both questions.


I set lang = DictionaryLookup[All]

$\endgroup$
3
  • 3
    $\begingroup$ Is it homework? $\endgroup$ Commented Oct 12, 2013 at 3:42
  • $\begingroup$ What did you use for lang? $\endgroup$
    – rm -rf
    Commented Oct 12, 2013 at 4:10
  • $\begingroup$ I have the first question, I just need the second question now. I need to find a way to show the longest word of each language. So if I know the longest word in English was 23, I have to find a way to see what THAT word is. $\endgroup$
    – Sam
    Commented Oct 12, 2013 at 16:38

1 Answer 1

3
$\begingroup$

This could be automated:

languages = DictionaryLookup[All];
leng = Length /@ (DictionaryLookup[{#, All}] & /@ languages)

The longest words could be extracted:

longw = 
  Last /@ (SortBy[#, StringLength[#] &] & /@ (DictionaryLookup[{#, All}] & /@ languages))

(noting that there may be more than one word of equal maximal length). You can adapt to sut your goal, e.g tabulate language and dictionary length:

Thread[{languages, leng}] // TableForm
$\endgroup$
3
  • $\begingroup$ I have the max length of each language, I just need a way to find what words they are exactly. $\endgroup$
    – Sam
    Commented Oct 12, 2013 at 16:38
  • $\begingroup$ For the second question, I need to find a way to show the longest word of each language. So for example, if I know the longest word in English was 23, I have to find a way to see what that 23 letter word is. $\endgroup$
    – Sam
    Commented Oct 12, 2013 at 16:40
  • $\begingroup$ @Sam longw in the code above is a list of the longest words. You could tabulate language, longest word and length as follows: Thread[{languages,longw,StringLength/@longw}]//TableForm $\endgroup$
    – ubpdqn
    Commented Oct 13, 2013 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.