|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T r
Length: 2368 (0x940)
Types: TextFile
Names: »report.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Festoon/report.c«
/*
* Stupid Report Generator. (possibly a VSRG; very SRG)
* This is a very simplified report generating program based on
* a visual experience with "festoon". The vocabulary was "strings"
* (or strung) from the binary of festoon and some words were added.
*/
#include <ctype.h>
#define PICK1(list) list[random()%(sizeof (list) / sizeof (char *))]
#define isvowel(c) ((c)=='a'||(c)=='e'||(c)=='i'||(c)=='o'||(c)=='u')
char *adjectives[], *nouns[];
char *hedge[], *clause[];
char *prep[], *adverbs[];
#include "words.h"
char sent_buf [ 1000 ];
main(argc, argv)
char **argv;
{
int i, nsentences;
if(argc < 2)
printf("usage: %s number_of_sentences\n", argv[0]), exit(1);
nsentences = atoi(argv[1]);
srandom (getpid());
while (nsentences--) {
for (i=0; i<1000; ++i)
sent_buf[i] = '\0';
sentence(sent_buf);
punctuate(sent_buf);
printf ("%s\n", sent_buf);
}
}
sentence (string) /* compose a sentence into string */
char *string;
{
if (random() % 3)
put_clause (string);
nounphr (string);
strcat (string, " ");
be (string);
strcat (string, " ");
adjphr (string);
}
nounphr (string)
char *string;
{
char *nountmp = PICK1(nouns);
/* Note: the a/an differentiation does not work because it does not depend
* on the noun, but rather the word immediately following the article
*/
strcat (string, (isvowel(*nountmp)) ? "an " : "a ");
/* should be a random determiner */
if (!(random() % 4))
adjphr (string), strcat (string, " ");
strcat (string, nountmp);
if (!(random() % 6)) {
strcat (string, " ");
strcat (string, PICK1(prep));
strcat (string, " ");
nounphr (string);
}
}
adjphr (string)
char *string;
{
while (!(random() % 5)) {
strcat (string, PICK1(adverbs));
strcat (string, " ");
}
strcat (string, PICK1(adjectives));
}
be (string) /* this should be beefed up considerably */
char *string;
{
strcat (string, (random() % 3) ? "is" : "was");
}
put_clause (string) /* a clause to preceed the sentence */
char *string;
{
if (random() % 3)
strcat (string, PICK1(hedge)), strcat (string, " ");
else {
strcat (string, PICK1(clause));
strcat (string, " ");
sentence (string);
strcat (string, ", ");
}
}
punctuate (string) /* punctuate a sentence */
char *string;
{
*string = toupper (*string);
strcat (string, ".");
}