Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

Students also viewed these Databases questions

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Discuss the states of accounting

Answered: 1 week ago

Question

LO1 Summarize the organizations strategic planning process.

Answered: 1 week ago