90Views3Replies

Author Options:

Calling all VBScripters! Answered

I am trying to create a vbs script that will use vocabulary databases to randomly choose words according to sentence structure, then using a large database (that tells what words are relevant to the random word chosen) it creates a basic sentence. With more complicated sentence structures there are more complicated. I need some other vbscripters to help. Here is how it works

The program chose a statement sentence. The basic structure is

noun verb

Then the program choses a word

Cats verb

Finally using the matching database it creates a realisitic sentence

Cats meowed.

A more complex sentence would be

article noun verb preposition pronoun noun

article cat verb preposition pronoun noun

article cat called preposition her kittens

article cat called to her kittens

The cat called to her kittens 

Discussions

0
None
psyfect

7 years ago

Not at my computer right now but sounds like a simple example would include an inputbox (for the user to type their format), some string arrays (to store your databases) and a for/next loop to parse the input string one word at a time. During the loop you would include the rnd function to choose a word from your database (array[i&]) for the replacement. The quickest way would be to assemble the resulting sentence as a new string instead of replacing the user input. Pseudo code: Dim x as string, I as long, r as string, nouns[] as string x$ = inputbox("set your specifications" For Each word in x$ select case word Case "noun" r$=r$ & nouns[rnd(42)] Next It's been a while since I've coded, but that's the gist of it and should be able to get you started with a couple google searches. An external list would require reading and writing to files but there's probably plenty of resources on the web if you just search for that.

0
None
psyfect

7 years ago

You mean you want to have a database of nouns, verbs, adverbs and such, then have vb assemble a sentence based on what order the user dictates? Like telling it 'a noun, noun and noun verb into a noun.' and having it randomly select and replace 'noun' and 'verb' with a word from your database so it would say 'a kangaroo, building and net vault into a kitchen.?'

If so, you just need to use the 'inputbox' command for user input then use rnd() (i think) to generate a random number and use that number to select the word from your database. Finally, use 'regular expressions' to find/replace and a for/next loop to cycle through (using a new random number each time) each instance.

If you, want your database external/editable that's more coding. Personally, it sounds like vb.net would be nicer, if your going this route, for the gui.

Just theory but should get you started. Hope this helps, have fun!

0
None
Super_Nerdpsyfect

Reply 7 years ago

Almost, but by sentence structure I mean something like declaritive, exclamatory, interrogative, or imperitive. Also the program randomly decides sentece structure. For example...

The program chose a statement sentence. The basic structure is

noun verb

Then the program choses a word

Cats verb

Finally using the matching database it creates a realisitic sentence

Cats meowed.

A more complex sentence would be

article noun verb preposition pronoun noun

article cat verb preposition pronoun noun

article cat called preposition her kittens

article cat called to her kittens

The cat called to her kittens