Function GetSentence() As String
Dim Data As String, i As Integer
Data = RandOf(GStart) & " " & RandOf(GSplit) & " " & RandOf(GThing)
i = Int(Rnd * 3)
Select Case i
Case 1
Data = Data & " because " & RandOf(GXTra) & " " & RandOf(GStart) & " " & RandOf(GSplit) & " " & RandOf(GThing)
Case 2
Data = Data & " because " & RandOf(GStuck)
Case 3
Case 4
End Select
GetSentence = Data
End Function
Function RandOf(ByVal v As Variant) As String
Randomize
Dim i As Integer
i = Int(Rnd * (UBound(v) + 1))
RandOf = v(i)
End Function
Function GStart() As Variant
GStart = Array("Found", "Saw", "Caught", "Kicked", "Touched", "Played with", "Trained", "Detonated", "Smoked")
End Function
Function GSplit() As Variant
GSplit = Array("My", "His", "Her", "Someone's", "Somebody's", "Everyones'")
End Function
Function GThing() As Variant
GThing = Array("Dog", "Cat", "Person", "Toy", "Bomb", "Bong")
End Function
Function GXTra() As Variant
GXTra = Array("He", "She", "They", "That animal", "That thing")
End Function
Function GStuck() As Variant
GStuck = Array("I said so", "I think so", "I reckon it is right")
End Function
Info
The getsentence function returns a string, which gives some funny results. eg. Touched Somebody's Dog because He Trained Somebody's Cat--Doomguy0505 09:14, 27 November 2006 (UTC)
Rather simple
I think this should be extended to include any grammatically correct sentence. For example, start the sentence by calling a Verb() function. Verb() returns the verb with a subject and an object if it needs one, each of which is a call to Noun() or Pronoun(Boolean subject). Some verbs might call Preposition(), which forms a whole prepositional phrase - and Noun() might call back to Verb for a gerund.
Functions:http://files.filefront.com/Non_GUI_Random_Idea_Generator/;7462409;/fileinfo.html
- Sentence(): Calls Verb(false) and possibly Contraction()
- Contraction(): Returns a word, and tacks on either "of " + Noun() or Verb(false)
- Verb(Boolean gerund): Returns IFF(gerund,vbNullString,IFF(rand()<.5,Pronoun(true),Noun()) + IFF(rand()<.5,Adverb(),vbNullString) + a random verb + calls to other functions depending on the verb chosen.
- Pronoun(Boolean subject): Returns a randomly selected pronoun, or a possessive plus a call to Noun().
- Noun(): May return a randomly selected common noun, the result of a call to ProperNoun() or the result of a call to Verb(true). May tack a call to Adjective() onto the beginning. May tack a call to Preposition(false) onto the end.
- Preposition(Boolean action): Returns a preposition and a call to Noun().
- Adjective: Returns a random adjective. 50% chance of tacking on a call to Adverb(). 50% chance of tacking on a recursive call with a comma separator.
- Adverb: Returns a random adverb. 50% chance of tacking on a recursive call with a comma separator.
- ProperNoun(): Randomly generates a pronounceable nonsense word or series of nonsense words, puts it in proper case and returns it.
The pronounceable-word algorithm would alternate between consonants and vowels, randomly tacking either one letter or two letters of that type onto the word, with a small chance of stopping and adding a space, and an equally small chance of stopping and returning the word. Double-consonant sets will need some restrictions, and more-than-two-consonant sets might be permitted by treating more than one letter together as a single consonant (for example, ch would be one consonant). --Brilliand 16:53, 14 April 2007 (UTC)
New Version
The new version features
- External pattern files (the word lists and random sentences are not built into the exe)
- Users create their own
- Less mucking with VB code
- Distributable pattern files
- Decision precalculating (whether or not {{3}} should be processed is decided at the compiler)
- Faster sentence generating
See the source code for an English explanation :D --Doomguy0505 05:14, 21 April 2007 (UTC)
Of all the insanity... I have Visual Studio .NET but no MSVBVM60. Well, I glanced at the source, and I really don't think it's random enough. I think it might be better implemented in Microsoft Word VBA than VB6 because of the large dictionary, or you could steal a dictionary from some free source. For extra randomization, the sentence should be generated on the fly and have a chance of becoming very long and extended like this one.
Installing an earlier version of Visual Studio will take another gigabyte... maybe I should look into that other compiler mentioned here. --Brilliand 15:56, 28 April 2007 (UTC)
- Visual Studio 6 doesn't take a gig, VB6 would be far less than that I presume. What do you mean it isn't generated on the fly? It is loaded into memory and then the sentences are generated from a list of sentences and then words. There is a docs for an yet unfinished gui-free compiler here --Doomguy0505 10:44, 8 May 2007 (UTC)