Random real word generator needed

Discussion in 'Mac Apps and Mac App Store' started by Yukon Jack, Apr 22, 2015.

  1. Yukon Jack macrumors member

    Joined:
    May 14, 2010
    #1
    I'm looking for an app or script that will generate lists of random real (i.e. are in the English dictionary) words. Ideally I'd like to be able to control the word length but otherwise there's no other criteria.

    I've checked the MAS and Macupdate as well as a general search of the Internet, but these turned up nothing but random text generators for creating passwords or gibberish filler text (such as lorem ipsum).

    Of course there are plenty of Windoze apps but I don't have Parallels or Boot Camp so those are out.

    thanks!

    -Tod
     
  2. dmi, Apr 22, 2015
    Last edited: Apr 22, 2015

    dmi macrumors regular

    Joined:
    Dec 21, 2010
    #2
    perl -ne 'rand($.)<1 and $word=$_;END{print $word}' /usr/share/dict/words

    perl -MList::Util=shuffle -e 'print ((shuffle grep{length==8}<>)[0..9])' /usr/share/dict/words
     
  3. Yukon Jack thread starter macrumors member

    Joined:
    May 14, 2010
    #3
    @ dmi: that's an unusual (but effective) solution. I'm familiar with Terminal but not with scripting. Is there a way to add to this script that will (a) select only words of a given length (say 5 characters) and (b) list more than one word at a time (say list 10 words)?

    Thanks!

    -Tod
     
  4. dmi macrumors regular

    Joined:
    Dec 21, 2010
    #4
    perl -MList::Util=shuffle -le 'print for (shuffle grep{chomp;length==5}<>)[0..9]' /usr/share/dict/words
     
  5. Yukon Jack thread starter macrumors member

    Joined:
    May 14, 2010
    #5
    @ dmi: I didn't see your edit when I asked about word length and # of words.

    Many thanks for creating this script. It is perfect for my use.

    I don't see any functional difference between these two but they both work fine.

    perl -MList::Util=shuffle -e 'print ((shuffle grep{length==6}<>)[0..9])' /usr/share/dict/words

    perl -MList::Util=shuffle -le 'print for (shuffle grep{chomp;length==5}<>)[0..9]' /usr/share/dict/words

    With best regards for a good weekend!

    -Tod
     

Share This Page