Question: Hello. I'm trying to write a random word sentence using words from this site: http://wordnet.princeton.edu/ Example : The abducent organism barely respire your reticent docking

Hello. I'm trying to write a random word sentence using words from this site: http://wordnet.princeton.edu/

Example:

The abducent organism barely respire your reticent docking

Where:

abducent and reticent are random words from the adj.txt file,

organism is a noun from noun.txt,

barely is an adverb from adv.txt,

respire is from verb.txt, and

docking is also from noun.txt.

Directions:

1. Load the text files containing the much longer word lists into your sketch so you can create many different sentences.

2. The size of each String array is known it is 2. When your code runs and loads thousands of words from the files into your String arrays, you will not know in advance exactly how many elements each array will end up containing.

3. This preliminary model just generates a random number between 0 and 1 to access each of the two elements in the String arrays for each part of speech. The sketch will need to generate a much wider range of random numbers, from 0 to the number of words in each String array. However, the model sketch does show how you can concatenate the various strings, with spaces separating them, into one pseudo-sentence. Your code here can be very similar.

4. In setup ( ), use loadStrings to read the text file for each part of speech into the relevant String array.

5. Modify the existing println ( ) as you want. You can add a couple of articles (The and A) or a couple of possessive pronouns (His, Her, My, Your, etc.) to make the sentences sound a bit more realistic although they will still be weird, believe me.

Here's what I have so far:

String [] articles ; String [] adjectives ; String [] nouns ; String [] adverbs ; String [] verbs ;

void setup ( ) { articles = new String [2] ; adjectives = new String [2] ; adverbs = new String [2] ; nouns = new String [2] ; verbs = new String [2] ;

articles[0] = "The" ; articles[1] = "That" ; adjectives[0] = "ridiculous" ; adjectives[1] = "over-stimulated" ; adverbs[0] = "really" ; adverbs[1] = "longingly" ; verbs[0] = "hiked" ; verbs[1] = "ingested" ; nouns[0] = "dog" ; nouns[1] = "aardvark" ; int randomAdj = int ( random ( 2 ) ); int randomNoun = int ( random ( 2 ) ); int randomAdverb = int ( random ( 2 ) ); int randomArticle = int ( random ( 2 ) ); int randomVerb = int ( random ( 2 ) ); println ( articles[randomArticle] + " " + adjectives[randomAdj] + " " + nouns[randomNoun] + " " + adverbs[randomAdverb] + " " + verbs[randomVerb] + " " + adjectives[randomAdj] + " " + nouns[randomNoun] ) ; }

void draw ( ) { }

Wondering if you can help me out.

Thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!