Annotation of researchv10dc/cmd/wwb/prose.c, revision 1.1.1.1

1.1       root        1: /* NOTICE-NOT TO BE DISCLOSED OUTSIDE BELL SYS EXCEPT UNDER WRITTEN AGRMT */
                      2: /* Writer's Workbench version 2.3, April 7, 1981 */
                      3: #define NVAR 14
                      4: #define MAXLENG 79.0
                      5: #define READAB 0
                      6: #define NONF 1
                      7: #define PASS 8
                      8: #define NOM 9
                      9: #define AVW 10
                     10: #define EXPL 11
                     11: #define S_CPX 12
                     12: #include <stdio.h>
                     13: 
                     14: char *disclm ="BECAUSE YOUR TEXT IS SHORT \(< 2000 WORDS & < 100 SENTENCES\),\n\
                     15: THE FOLLOWING ANALYSIS MAY BE MISLEADING.\n\n";
                     16: 
                     17: char *note0 =
                     18: "NOTE: Your  document is being  compared   against  standards\n\
                     19: derived from 30 TMs, classified as  good by Department Heads\n\
                     20: in the Research Area.\n";
                     21: char *note2 =
                     22: "NOTE: Your text is being compared  against standards derived\n\
                     23: from 34 instructional texts produced by Department 45272.\n\n";
                     24: char *note1 =
                     25: "NOTE:    Your text is being compared to standards for Craft\n\
                     26: derived from the research of E. Coke.\n\n";
                     27: char *note3 =
                     28: "NOTE: Your text is being compared to standards given in file\n\"%s.\"\n";
                     29: 
                     30: char *kincaid = "\nREADABILITY\n\
                     31: \n     The Kincaid readability formula predicts that your text\n\
                     32: can be read by someone with %2.0f or more years  of  schooling,\n";
                     33: 
                     34: char *more_str =
                     35: "\n   More Information on Sentence Structure\n\
                     36: \n     Since passives,  nominalizations, as well as expletives\n\
                     37: all require  some form  of the verb \"to be,\"  an easy way to\n\
                     38: identify difficult paragraphs is to look for the overuse  of\n\
                     39: forms  of \"be.\"  The `findbe' program makes this easy; it for-\n\
                     40: mats a text and underlines and capitalizes all forms  of \"to\n\
                     41: be.\"  To use it type:\n\n\
                     42:                       findbe filename\n\n\
                     43: You can also use the `style' program  to print your sentences\n\
                     44: containing both a passive verb and a nominalization.  Type:\n\n\
                     45:                       style -n filename\n";
                     46: 
                     47: char *read0 =
                     48: "    Good TMs\n\
                     49: average close to 13th grade level, even  though the audience\n\
                     50: has more education than that.\n";
                     51: char *read2 =
                     52: " Good train-\n\
                     53: ing materials  average close  to the 10th grade level,  even\n\
                     54: though the audience has more education than that.\n";
                     55: char *read3 =
                     56: "  Your  good\n\
                     57: materials average close to grade %4.1f.\n";
                     58: char *read1 =
                     59: "  Since Coke\n\
                     60: found that 62%% of Bell System craft  have difficulty reading\n\
                     61: documents  with readability scores above 12.0,  the majority\n\
                     62: of the craft will probably not be able to read this.\n";
                     63: 
                     64: char *begmsg =
                     65: "\n     Writing teachers also stress  that  no  more  than   75\n\
                     66: percent   of  the  sentences in a text should begin with the\n\
                     67: subject  of  the  sentence;  these  start  with the  subject\n\
                     68: %2.0f%% of  the time.   Try starting more of your sentences with\n\
                     69: prepositions, adverbs, or  conjunctions.  This  change  will\n\
                     70: have  the added benefit of adding variety of sentence length\n\
                     71: and type.\n";
                     72: 
                     73: char *pasnom ="\n   Passives and Nominalizations\n\
                     74: \n     You have appropriately limited your use of passives and\n\
                     75: nominalizations \(nouns made from verbs, e.g. \"description\"\).\n";
                     76: 
                     77: char *badpas =
                     78: "\n     This text contains a %s higher percentage of passive verbs\n\
                     79: (%4.1f%%) than is common in good documents of this type (%2.0f%%).\n";
                     80: 
                     81: char *badnom ="\n     This text  has  a  higher percentage of nominalizations\n\
                     82: (%4.1f%%) than is common in good documents of this type (%2.0f%%).\n";
                     83: 
                     84: char *badexp ="\n   Expletives\n\
                     85: \n     This text  contains a  higher percentage  of expletives\n\
                     86: (%4.1f%%) than is common in good documents of this type (%2.0f%%).\n";
                     87: 
                     88: FILE *fp;
                     89: main(argc,argv)
                     90: int argc;
                     91: char *argv[];
                     92: {
                     93:        char *rather="rather";
                     94:        char *very="very";
                     95:        char *too="too";
                     96:        char *much="much";
                     97:        char *null="";
                     98:        char *qual;
                     99:        char *note;
                    100:        char *readmsg;
                    101:        FILE *fpath;
                    102:        int h,h0,fflag,sflag,ret;
                    103:        char save[81], buf[100];
                    104:        int i,aud,npara,p,j;
                    105:        int numabst;
                    106:        float kindex, avw,snonf,  simple,complex, compound,  compdx;
                    107:        float ppron,padj, var[NVAR],array[NVAR][4],sc[NVAR];
                    108:        float passive,explet;
                    109:        int nomin,x;
                    110:        int numsent, maxsent, qcount, icount,ml,lsum,mg,gsum;
                    111:        long numwds,numnonf;
                    112:        int maxindex,minindex,minsent;
                    113:        float aindex,cindex,fgrad,findex,avl,fnumnonf,centlsum,centgsum;
                    114:        int nsimple,ncomplex,ncompound,ncompdx,ntobe;
                    115:        int npassive,pron,pos,adj,art,beg,begadv,begprep,begverb,begscon;
                    116:        int begconj, begexp,noun;
                    117:        float ptobe,paux,pinfin,padv,pconjc,pprepc,pnoun,pnomin,tot;
                    118:        float pbegprep,pbegadv,pbegverb,pbegscon,pbegconj,pbegexp;
                    119:        int tobe,aux,infin,prepc,conjc,adv;
                    120:        char path[80];
                    121:        fflag=0;
                    122:        sflag=0;
                    123:        aud=0;
                    124:        note = note0;
                    125:        readmsg = read0;
                    126:        strcpy(path,LIB");
                    127:        if(argc >= 2){
                    128:                i=0;
                    129:                if(*(argv[1]+i) =='f') {
                    130:                        fflag=1;
                    131:                        i++;
                    132:                }
                    133:                if(*(argv[1]+i) =='s') {
                    134:                        sflag=1;
                    135:                        i++;
                    136:                }
                    137:                switch (*(argv[1]+i)){
                    138:                case 'm':
                    139:                        aud=0;
                    140:                        note = note0;
                    141:                        readmsg = read0;
                    142:                        break;
                    143:                case 't':
                    144:                        aud=2;
                    145:                        note = note2;
                    146:                        readmsg = read2;
                    147:                        strds(LIB/train.st","training");
                    148:                        break;
                    149:                case 'c':
                    150:                        aud=1;
                    151:                        note = note1;
                    152:                        readmsg = read1;
                    153:                        strds(LIB/crft.st","Craft");
                    154:                        break;
                    155:                case 'x':
                    156:                        aud=3;
                    157:                        note = note3;
                    158:                        readmsg = read3;
                    159:                        if((fp=fopen(argv[2],"r"))==NULL){
                    160:                                fprintf(stderr,"Prose can't find your standards file \"%s,\" try specifying a more complete pathname.\n",argv[2]);
                    161:                                exit(1);
                    162:                        }
                    163:                        break;
                    164:                }
                    165:        }
                    166: 
                    167:        if(aud==0)
                    168:                strds(LIB/tm.st","TM");
                    169: findbeg:
                    170:        if(fgets(save,81,stdin)==NULL){
                    171:                fprintf(stderr,"The file named after  the -f flag doesn't seem\
                    172:  to contain a style table.\nOr else style cannot produce a table for your\
                    173:  file.\n  Try running style alone on your file.\n");
                    174:                                exit(1);
                    175:        }
                    176:        ret=sscanf(save,"%*s%f%*s%f%*s%f%*s%f (%f)",
                    177:                &kindex,&aindex,&cindex,&fgrad,&findex);
                    178:         if(ret !=5 ) goto findbeg;
                    179:        fgets(buf,100,stdin);
                    180:        scanf("%*s%*s%d%*s%*s%ld",&numsent,&numwds);
                    181:        scanf("%*s%*s%*s%f%*s%*s%*s%f",&avw,&avl);
                    182:        scanf("%*s%*s%d%*s%*s%d",&qcount,&icount);
                    183:        scanf("%*s%*s%*s%d%f%%%*s%*s%f",&numnonf,&fnumnonf,&snonf);
                    184:        scanf("%*s%*s (<%d) %f%% (%d) %*s%*s (>%d) %f%% (%d)",
                    185:                &ml,&centlsum,&lsum,&mg,&centgsum,&gsum);
                    186:        scanf("%*s%*s%d%*s%*s%*s%d;%*s%*s%d%*s%*s%*s%d\n",
                    187:                &maxsent,&maxindex,&minsent,&minindex);
                    188:        fgets(buf,100,stdin);
                    189:        scanf("%*s%f%% (%d) %*s %f%% (%d)",&simple,&nsimple,&complex,&ncomplex);
                    190:        scanf("%*s%f%% (%d) %*s%f%% (%d)\n",
                    191:                &compound,&ncompound,&compdx,&ncompdx);
                    192:        fgets(buf,100,stdin);
                    193:        fgets(buf,100,stdin);
                    194:        scanf("%*s%f%% (%d) %*s %f%% (%d)%*s%f%% (%d)",
                    195:                &ptobe,&tobe,&paux,&aux,&pinfin,&infin);
                    196:        scanf("%*s%*s %% %*s%*s%*s%f%% (%d)\n",&passive,&npassive);
                    197:        fgets(buf,100,stdin);
                    198:        scanf("%*s %f%% (%d)%*s%f%% (%d)%*s%f%% (%d)",
                    199:                &pprepc,&prepc,&pconjc,&conjc,&padv,&adv);
                    200:        scanf("%*s%f%% (%d)%*s %f%% (%d)%*s%f%% (%d)",
                    201:                &pnoun,&noun, &padj,&adj,&ppron,&pron);
                    202:        scanf("%*s%f %% (%d)\n",&pnomin,&nomin);
                    203:        fgets(buf,100,stdin);
                    204:        scanf("%*s%*s%*s (%d)%*s (%d)%*s (%d)%*s (%d)%*s (%d)%*s%f%%",
                    205:                &noun,&pron,&pos,&adj,&art,&tot);
                    206:        scanf("%*s%f%% (%d)%*s%f%% (%d) ",&pbegprep,&begprep,&pbegadv,&begadv);
                    207:        scanf("%*s%f%% (%d) ",&pbegverb,&begverb);
                    208:        scanf("%*s%f%% (%d)%*s%f%% (%d)",&pbegscon,&begscon,&pbegconj,&begconj);
                    209:        scanf("%*s%f%% (%d)",&pbegexp,&begexp);
                    210: 
                    211:        /*variables used by the prose program*/
                    212:        var[READAB]=kindex;
                    213:        var[NONF]=snonf;
                    214:        var[2]=centlsum;
                    215:        var[3]=centgsum;
                    216:        var[4]=simple;
                    217:        var[5]=complex;
                    218:        var[6]=compound;
                    219:        var[7]=compdx;
                    220:        var[PASS]=passive;
                    221:        var[NOM]=pnomin;
                    222:        var[AVW]=avw;
                    223:        var[EXPL]=pbegexp;
                    224:        var[S_CPX]=simple-complex;
                    225:        var[13]=compound+compdx;
                    226: 
                    227:        /*read criterion values for variables from appropriate file*/
                    228:        ret=0;
                    229:        for(i=0;i <NVAR; i++)
                    230:                for(j=0;j<4; j++){
                    231:                        ret+=fscanf(fp,"%f",&array[i][j]);
                    232:                }
                    233: 
                    234:        /* make sure values were read correctly*/
                    235:         if(ret!=(NVAR*4)){
                    236:                fprintf(stderr,"The standards file is not formatted\
                    237:  properly.\nIt should have %d lines, each with 4 floating point numbers.\n",
                    238:                NVAR);
                    239:                exit(1);
                    240:        }
                    241: 
                    242:        /* Compare criterion values against STYLE produced scores*/
                    243: 
                    244:        for(i=0; i< NVAR; i++){
                    245:                sc[i]=0;
                    246:                for(j=0; j < 4;j++){
                    247:                        if(var[i] > array[i][j]) sc[i]=j+1;
                    248:                }
                    249:        }
                    250: 
                    251:        /*  Read percent of abstract words  */
                    252: 
                    253: 
                    254:        if(numwds < 2000 && numsent <100)
                    255:                printf(disclm);
                    256:        if(sflag) goto shortans ;
                    257:        printf(note,argv[2]);
                    258:                        /*READABILITY*/
                    259:        printf(kincaid,kindex);
                    260:        if(sc[READAB]==0){
                    261:                printf("which is a low score for  this type of document.");
                    262:                if (aud==0)
                    263:                        printf("  If this is\nan instructional text\
                    264:  (in paragraph form), run prose -t  for\na more appropriate review.\n");
                    265:                else if(aud==2)putchar('\n');
                    266:        }
                    267:        else if(sc[READAB] < 3)
                    268:                printf("which is a  good score for documents like this.\n");
                    269:        else {          /* ==3 or 4*/
                    270:                if(sc[READAB] == 3)qual=rather;
                    271:                else qual=very;
                    272:                printf("which is %s high for this type of document.",qual);
                    273:                if(aud != 1)printf(readmsg,(array[READAB][1]+array[READAB][2])/2.0);
                    274:                if(sc[NONF] > 2)
                    275:                        prtfile(LIB/rd2.t");
                    276:                if(aud == 1)printf(readmsg);
                    277: 
                    278:        }
                    279: 
                    280: 
                    281:        printf("\nVARIATION\n");
                    282:        if(sc[S_CPX]==4 || sc[S_CPX]==0 || tot >MAXLENG)
                    283:                        prtfile(LIB/var.t");
                    284:        if(sc[S_CPX]==0||sc[S_CPX]==4)
                    285:                printf("\n     In this  text %2.0f%% of  the sentences are\
                    286:  simple, %2.0f%% are\ncomplex, giving a difference of %3.0f.  This\
                    287:  difference should\nrange  from %2.0f to %2.0f for good documents of this\
                    288:  type.\n",simple,complex, simple-complex,array[S_CPX][1],array[S_CPX][2]);
                    289:        if(sc[S_CPX]==4){
                    290:                if(sc[AVW] < 2)
                    291:                        prtfile(LIB/type.t");
                    292:                else 
                    293:                        prtfile(LIB/type2.t");
                    294:        }
                    295:        else if(sc[S_CPX]==0){
                    296:                if(sc[READAB] < 3)
                    297:                        prtfile(LIB/var4.t");
                    298:                else
                    299:                        prtfile(LIB/var6.t");
                    300:        }
                    301:        else printf("\n     You have an appropriate distribution of sentence\
                    302:  types.\n");
                    303:        if(maxsent >= 50){
                    304:                if(sc[S_CPX]==0 || sc[S_CPX]==4)
                    305:                        printf("\n     Additionally,  the  longest sentence is\
                    306:  %d  words long.\n",maxsent);
                    307:                else printf("\n     The   longest  sentence,\
                    308:   however,  is %d  words  long.\n",maxsent);
                    309:                prtfile(LIB/var5.t");
                    310:        }
                    311:        if(sc[AVW] > 2){
                    312:                if(sc[S_CPX]==4 || sc[S_CPX]==0)
                    313:                        printf("\n     Such  changes would  also  help  to\
                    314:  reduce the  average\n");
                    315:                else  printf("\n     You should,  however,  consider\
                    316:  shortening your average\n");
                    317:                printf("sentence length.  Your average is %2.0f words,\
                    318:   which  is ",var[AVW]);
                    319:                if(sc[AVW]==3)printf("high.\n");
                    320:                if(sc[AVW]==4) printf(" very\nhigh.  ");
                    321:                printf("A good average would be %2.0f to %2.0f words.\n",
                    322:                        array[AVW][1],array[AVW][2]);
                    323:        }
                    324:        if(tot >MAXLENG){
                    325:                printf(begmsg,tot);
                    326:        }
                    327:        printf("\nSENTENCE STRUCTURE\n");
                    328:        if(sc[PASS]<=2 && sc[NOM] <=2) {
                    329:                printf(pasnom);
                    330:        }
                    331:        else {
                    332:                printf("\n   Passives\n");
                    333:                if(sc[PASS] > 2){
                    334:                        if(sc[PASS] == 3)qual=null;
                    335:                        else qual=much;
                    336:                        printf(badpas,qual,var[PASS],(array[PASS][1]+array[PASS][2])/2.0);
                    337:                        prtfile(LIB/pass.t");
                    338:                }
                    339:                else printf("\n     You have limited your passives appropriately.\n");
                    340:                printf("\n   Nominalizations\n");
                    341:                if(sc[NOM] > 2){
                    342:                        printf(badnom,var[NOM],(array[NOM][1]+array[NOM][2])/2.0);
                    343:                        prtfile(LIB/nom.t");
                    344:                }
                    345:                else printf("\n     You  have  appropriately limited  your\
                    346:   nominalizations\n\(nouns made from verbs, e.g., \"description\"\).\n");
                    347:        }
                    348:        if(sc[EXPL]==4){
                    349:                printf(badexp,var[EXPL],(array[EXPL][1]+array[EXPL][2])/2.0);
                    350:                prtfile(LIB/exp.t");
                    351:        }
                    352:        if(sc[PASS]>2 && sc[NOM]>2){
                    353:                printf(more_str);
                    354:        }
                    355:        if(!fflag){
                    356:                if(aud==0)
                    357:                        prtfile(LIB/popttm.t");
                    358:                else if(aud==2)
                    359:                        prtfile(LIB/poptt.t");
                    360:        }
                    361:        prtfile(LIB/fur.t");
                    362:        exit(0);
                    363: shortans : 
                    364:        if(aud==0) printf("Compared to TMs.\n\n");
                    365:        else if(aud==1) printf("Evaluated for Craft.\n\n");
                    366:        else if(aud==2) printf("Compared to training material.\n\n");
                    367:        else if(aud==3)printf("Compared to file \"%s\"\n",argv[2]);
                    368:        printf("Reading grade level--%2.0f: ",kindex);
                    369:        if(sc[READAB]==1 || sc[READAB]==2) printf("Good\n");
                    370:        else if(sc[READAB]==0) printf("Low\n");
                    371:        else if(sc[READAB]==3) printf("High\n");
                    372:        else if(sc[READAB]==4)printf("Very high\n");
                    373: 
                    374: 
                    375:        printf("Variation--");
                    376:        if(sc[S_CPX] == 4)
                    377:                 printf("Too many short, simple sentences--subordinate.\n");
                    378:        else if(sc[S_CPX]==0) printf("Too many complex sentences.\n");
                    379:        else printf("Good sentence type distribution.\n");
                    380:        if(sc[AVW] > 2){
                    381:                if(sc[AVW]==3)
                    382:                        qual = too;
                    383:                else qual = very;
                    384:                printf("             Sentences are %s long--avg\
                    385:  length=%2.1f words\n",qual,var[AVW]);
                    386:                printf("                                   --Good length\
                    387:  = %2.1f to %2.1f\n",array[AVW][1],array[AVW][2]);
                    388:        }
                    389:        if( maxsent >50)
                    390:                 printf("Longest sentence is %d words---perhaps it is a list\n"
                    391:                        ,maxsent);
                    392:        if(tot >MAXLENG)
                    393:                printf("             %2.0f%%= Too many sentences begin with\
                    394:  the subject.\n",tot);
                    395: 
                    396:        printf("Passives--%2.0f%%: ",passive);
                    397:        if(sc[PASS]<=2)printf("Good\n");
                    398:        else if(sc[PASS] ==3)printf("High\n");
                    399:        else if(sc[PASS]==4)printf("Very high\n");
                    400: 
                    401:        printf("Nominalizations--%2.0f%%: ",pnomin);
                    402:        if(sc[NOM]<=2)printf("Good\n");
                    403:        else if(sc[NOM]==3)printf("High\n");
                    404:        else if(sc[NOM]==4)printf("Very high\n");
                    405: 
                    406:        if(sc[EXPL]==4)printf("Expletive--%2.0f%%: Very high\n",pbegexp);
                    407:        if (!fflag) printf("Don't forget the styl.tmp file.\n");
                    408:        putchar('\n');
                    409: }
                    410: prtfile(s)
                    411: char *s;
                    412: {
                    413:        FILE *ff;
                    414:        char ch[512];
                    415:        int num;
                    416:        if((ff=fopen(s,"r"))==NULL){
                    417:                fprintf(stderr,"Prose can't find the file %s\n",s);
                    418:                exit(1);
                    419:        }
                    420:        while((num=fread(ch,sizeof(ch[0]),512,ff)))
                    421:                fwrite(ch,sizeof(ch[0]),num,stdout);
                    422:        fclose(ff);
                    423: }
                    424: strds(s1,s2)
                    425: char *s1, *s2;
                    426: {
                    427:        if((fp=fopen(s1,"r"))==NULL){
                    428:                fprintf(stderr,"Prose can't find the %s standards file %s\n",
                    429:                        s2,s1);
                    430:                exit(1);
                    431:        }
                    432: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.