dlj204

Page 27

WordNet dictionary, and we need to be prepared. I’ll tie these together, as written, and here’s what we get as an output:

echo "((${word}:$pos))" else echo "<${word}:$pos>" fi

Note: {} = too short, [] = POS undefined

fi

((I:noun)) {am} {by} ((birth:noun)) {a} Genovese, and {my} family {is} one of the most ((distinguished:verb)) of that ((republic:noun))

As the header reminds us, at this point, we’re denoting words selected but skipped because they’re too short with {} and those that have an undefined part of speech with []. I’ve also changed the word replacement density factor to have more words tested. As you can see, most of the words in our sample input are now evaluated one way or the other. Now, let’s add a test so that only nouns or adjectives are eligible for substitution too:

I’ll give it that same first sentence to Mary Shelley’s Frankenstein, and let’s see what transpires: Note: {} = too short, [] = POS undefined, <> = uninteresting POS I {am} <by:adverb> birth {a} Genovese, [and] my family ((is:noun)) {one} {of} {the} ((most:adjective)) <distinguished:verb> {of} [that] ((republic:noun))

We’re definitely getting there, but I think we still need to add something to the selection criteria—something that will help us produce more interesting Mad Libs. But, let’s leave that for next month as we’ve already dug through a lot of code in this column.I

if [ ! -z "$(echo $pos | grep "not return")" ] ; then echo \[$word\]

# failed to figure POS

else if [ -n "$(echo $pos | grep -E '(noun|adjective)')" ] ; then

Dave Taylor has been hacking shell scripts for a really long time, 30 years. He’s the author of the popular Wicked Cool Shell Scripts and can be found on Twitter as @DaveTaylor and more generally at www.DaveTaylorOnline.com.

Small, Portable Devices with Ubuntu Linux Small Form Factor Intel® Atom™ Platform No fans, no moving parts. Just quiet, reliable operaƟon. Incredibly compact and full featured; no compromises.

VESA-Mountable NVIDIA® ION/ION2 System Compact, lightweight system with GeForce® Graphics. Flexible storage opƟons (dual HDD support) and WiFi.

Value only an Industry Leader can provide. SelecƟng a complete, dedicated plaƞorm from Logic Supply is simple: Pre-conĮgured systems perfect for both business & desktop use, Linux development services for greater system customizaƟon, and a wealth of online resources all within a few clicks.

Learn More > www.logicsupply.com/linux © 2010 Logic Supply, Inc. All products and company names listed are trademarks or trade names of their respective companies.

LogicSupply1-2horizLJ_Q4-10.indd 1

10/5/2010 4:02:59 PM


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.