'*******************************************************************************
'*** Poem Generator
'*** By George McGinn - May 27, 2021
'***
'***
'*** About the AI system
'*** Since writing poems has specific rules, which can easily break grammar
'*** rules, the AI will impose just the basic grammar syntax, like adding a
'*** "an" when required, and not ending sentences with words such as
'*** "like" which happens now. They will have a special modifier tag as with
'*** the tables in use, one of them can be used to finish the sentence.
'***
'*** However, poems do not follow strict sentence structure either, and like
'*** at the end of a line, since there is no period, it may be a pause where
'*** the first words on the next continues the thought. This will be
'*** built into the modifier tag. It will also check the words ahead of it to
'*** see if they are on the modifier list for the word "like" and others like
'*** it.
'***
'*** So due to the special circumstances on meter and rhyme and even the
'*** structure of the poem, the AI system will rely heavily on rule and word
'*** tables that will provide it the words, apply modifiers, check for any
'*** grammar changes, and will have a way to keep the poem on one theme.
'***
'*** And for this system to work properly, the vocabulary must grow to
'*** proportions where each word has associated tags for use with other words
'*** to help the AI engine to keep the poem on target.
'***
'*******************************************************************************
'SCREEN 12
'***************************************************************
'*** Initialize variables/arrays (comments to prevent confusion)
'***
x = 0 '* Index to poem length (# lines)
i = 0 '* Index to loading Arrays
cr$
= CHR$(10) '* Add a Carriage-Return character
Author$ = "By QB64 Program" '* Name of Programmer running code
DIM article$
(35), noun$
(60), verb$
(46), adjective$
(46) DIM colormodifier$
(28), colortable$
(8), nounmodifiers$
(14) DIM connectives$
(151), conective_extended$
(34)
'**************************************************
'*** Load Arrays from Data Statements
'***
'**************************************************
'*** Pick a 2- to 3-word title
'***
ta$
= article$
(INT(RND * 35) + 1)b$
= LCASE$(noun$
(INT(RND * 60) + 1)) '** Pick a primary nounb1$
= LCASE$(noun$
(INT(RND * 60) + 1)) '** Pick a noun-color modifierc$
= LCASE$(verb$
(INT(RND * 46) + 1)) '** Pick a primary verbc1$
= LCASE$(verb$
(INT(RND * 46) + 1)) '** Pick a verb modifierd$
= LCASE$(adjective$
(INT(RND * 46) + 1)) '** Pick an adjectivebc$
= LCASE$(colormodifier$
(INT(RND * 28) + 1)) '** Pick a modifier for a colornounmod$
= LCASE$(nounmodifiers$
(INT(RND * 14) + 1)) '** Pick a non-color noun modifier
tb$ = b$
Title$ = ta$ + " " + tb$
'**************************************************
'*** Create the poem, 16 lines in 4 4-line stanzas
'***
'*** NOTE: b1 & c1 placeholders for future use as modifiers, or
'*** to initially use b1 & c1 as modifiers themselves.
a$
= LCASE$(article$
(INT(RND * 35) + 1)) '** Pick an Article b$
= LCASE$(noun$
(INT(RND * 60) + 1)) '** Pick a primary noun b1$
= LCASE$(noun$
(INT(RND * 60) + 1)) '** Pick a noun-color modifier c$
= LCASE$(verb$
(INT(RND * 46) + 1)) '** Pick a primary verb c1$
= LCASE$(verb$
(INT(RND * 46) + 1)) '** Pick a verb modifier d$
= LCASE$(adjective$
(INT(RND * 46) + 1)) '** Pick an adjective bc$
= LCASE$(colormodifier$
(INT(RND * 28) + 1)) '** Pick a modifier for a color nounmod$
= LCASE$(nounmodifiers$
(INT(RND * 14) + 1)) '** Pick a non-color noun modifier
'*** Check for modifiers to nouns
'*** Capitalize the first word of each sentence or stanza (whether noun or verb)
Line$
= a$
+ " " + b$
+ " " + c$
+ " " + d$
Line$
= c$
+ " " + b$
+ " " + d$
endPROG:
'**************************************************
'*** Print Copyright and Date/Time Stamp and END
'***
day$
= STR$(D
) ' eliminate any leading zeros
CASE 1: Month$
= "January" CASE 2: Month$
= "February" CASE 8: Month$
= "August" CASE 9: Month$
= "September" CASE 10: Month$
= "October" CASE 11: Month$
= "November" CASE 12: Month$
= "December"
'*** Copyright Sign (Character, Unicode, UTF-8 Values
'***
PRINT SPACE$(3) + "Created " + WeekDay$
(M
, D
, Y
) + ", " + Month$
+ day$
+ ", " + year$
+ " at " + Clock$
'***
'*** END OF MAIN PROGRAM
'*******************************************************************
'*******************************************************************
'*** FUNCTIONS/SUB ROUTINES
'***
LoadWordArrays:
'**************************************************
'*** Load Arrays from Data Statements
'***
'*** Load Articles
'*** Load Nouns
'*** Load Verbs
'*** Load Adjectives
'*** Load Color Modifiers
'*** Load Color Table
'*** Load Noun Modifiers
'*** Load Connectives
'*** Load Contective Extended
CheckForCapitalization:
'*** Check for modifiers (@=Capitalize Word)
CheckForModifierBefore:
'*** Check for modifiers Before
'*** "*" the noun needs a color before it
'*** "+" the noun needs another noun to follow it (selection from noun modifier)
b$ = nounmod$ + " " + b$
CheckForModifierAfter:
'*** Check for modifiers after
'*** "*" the noun is a color and only color-friendly nouns considered
b$ = b$ + " " + bc$
'*** "+" the noun needs another noun to follow it (selection from noun modifier)
b$ = b$ + " " + nounmod$
'**************************************************
'*** DATA Statements for Poem Generator
'***
'*** 35 Articles
articles:
DATA "The","All of the","Most of the","Some of the" DATA "My","Your","His","Her","Their","Our","Everybody's","Almost all of the" DATA "That","I knew that the","We knew that the","She knew that the","He knew that the","They knew that the","And the coming","Oh, the","A spring of","Beyond the","Within the","And the","Alone, alone,","I fear","I looked upon","A","But where the","Like","A still and","Alone","All alone, a","The moving","It is"
'*** 60 Nouns
nouns:
DATA "darkness","morning","morning+","light","feeling","feeling+","beauty","love","hatred","happiness","sadness","anger","frustration","expression","message","ship","lips","mouth","voice","garment","saint","snake","snakes","water","fire","lead","dreams","air","ghost","sails","sleep","river","cloud","@moon","@sun","waters","life","stars","the stars","lightning","beams","beams+","*beard","fool","white*","black*","green*","blue*","yellow*","red*","light beams","*river","*garment","*ship","*snake","*snakes","*sails","voice+","ship+","ocean blue"
'*** 46 Verbs (lv)
verbs:
DATA "was","had been","will be","could be","might be","should have been","would have been","could have been","drunk","drank","was heavenly","a heavy","blessed","glossy","velvet","flash","kind","coiled","swarm","swarmed","fire","pity","filled","fill","moved","wind","danced","steep","wide","steep and wide","thick","light","roar","loud","more loud","lightning","struck","fell","more horrible","horrible","awful","hit","huge","holds","long","surrounds"
'*** 46 Adjectives/adverbs
adjectives:
DATA "abstract","mysterious","permanent","unfortunate","was unfortunate" DATA "intricate","confusing","serene","confusing" DATA "true","false","fake","a lie","burden" DATA "a stranger","a friend","an enemy" DATA "terrible","enchanting","is mine","was yours","is his","is hers","was theirs","was ours" DATA "fortunate","was understood","mine","is mutual","with an artistic flair","was musical" DATA "golden pond","blessed","moment","unaware","no","yes","sure" DATA "like","dreams","between","inbetween","alone","than that","interesting","glossy lake"
'*** 28 Color modifiers
colormodifiers:
DATA "morning","light","beauty","love","ship","lips","garment","knight","saint","snake","snakes","water","fire","ghost","sails" DATA "river","cloud","@moon","@sun","waters","stars","lightning","beams","beard","velvet","flash","grass","book"
'*** 8 Color table entries
colortable:
DATA "red","yellow","blue","green","white","black","orange","purple"
'*** 14 Noun Modifier Table (Nouns, Verbs/Adverbs, Adjectives)
nounmodifier:
DATA "sunshine","light","glow","fog","of peace","of love","blue","great","unloved","sad","happy","loved","of light","of love"
'*** 151 Connectives
connectives:
DATA "I","the","of","and","to","a","in","that","is","was","he","for","it" DATA "with","as","his","on","be","at","by","i","this","had","not" DATA "are","but","from","or","have","an","they","which","one","you","were" DATA "her","all","she","there","would","their","we","him","been","has" DATA "when","who","will","more","no","if","out","so","said","what","u","its","about" DATA "into","than","them","can","only","other","new","some","could","time","these" DATA "two","may","then","do","first","any","my","now","such","like","our" DATA "over","man","me","even","most","made","after","also","did","many","before","must" DATA "through","back","years","where","much","your","way","well","down","should" DATA "because","each","just","those","people","mr","how","too","little" DATA "state","good","very","make","world","still","own","see","men","work","long" DATA "get","here","between","both","life","being","under","never","day","same" DATA "another","know","while","last","might","us","great","old","year","off" DATA "come","since","against","go","came","right","used","take","three"
'*** 34 Extened Connectives:
connectives_extend:
DATA "whoever","nonetheless","therefore","although","consequently","furthermore" DATA "whereas","nevertheless","whatever","however","besides","henceforward","yet" DATA "until","alternatively","meanwhile","notwithstanding","whenever" DATA "moreover","despite","similarly","firstly","secondly","lastly","eventually" DATA "gradually","finally","thus","hence","accordingly","otherwise","indeed"
'*******************************************************************
'*** FUNCTIONS (FORMAT DATE AND TIME FIELDS)
'***
IF M
< 3 THEN M
= M
+ 12: Y
= Y
- 1 'add 12 to Jan - Feb month, -1 year C
= Y \
100: Y
= Y
MOD 100 'split century and year number S1 = (C \ 4) - (2 * C) - 1 'century leap
S2 = (5 * Y) \ 4 '4 year leap
S3 = 26 * (M + 1) \ 10 'days in months
WkDay
= (S1
+ S2
+ S3
+ D
) MOD 7 'weekday total remainder IF WkDay
< 0 THEN WkDay
= WkDay
+ 7 'Adjust negative results to 0 to 6 CASE 3: day$
= "Wednesday" CASE 4: day$
= "Thursday" CASE 6: day$
= "Saturday" WeekDay$ = day$
Clock$ = hour$ + min$ + ampm$