Annotation of researchv8dc/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 = "\nRREEAADDAABBIILLIITTYY\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   _M_o_r_e__I_n_f_o_r_m_a_t_i_o_n__o_n__S_e_n_t_e_n_c_e__S_t_r_u_c_t_u_r_e\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 _f_i_n_d_b_e 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 _s_t_y_l_e 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 *pas_nom ="\n   _P_a_s_s_i_v_e_s__a_n_d__N_o_m_i_n_a_l_i_z_a_t_i_o_n_s\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   _E_x_p_l_e_t_i_v_e_s\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:        int h,h0,fflag,sflag,ret;
                    102:        char save[81];
                    103:        int i,aud,npara,p,j;
                    104:        int numabst;
                    105:        float kindex, avw,snonf,  simple,complex, compound,  compdx;
                    106:        float ppron,padj, var[NVAR],array[NVAR][4],sc[NVAR];
                    107:        float passive,explet;
                    108:        int nomin,x;
                    109:        int numsent, maxsent, qcount, icount,ml,lsum,mg,gsum;
                    110:        long numwds,numnonf;
                    111:        int maxindex,minindex,minsent;
                    112:        float aindex,cindex,fgrad,findex,avl,fnumnonf,centlsum,centgsum;
                    113:        int nsimple,ncomplex,ncompound,ncompdx,ntobe;
                    114:        int npassive,pron,pos,adj,art,beg,begadv,begprep,begverb,begscon;
                    115:        int begconj, begexp,noun;
                    116:        float ptobe,paux,pinfin,padv,pconjc,pprepc,pnoun,pnomin,tot;
                    117:        float pbegprep,pbegadv,pbegverb,pbegscon,pbegconj,pbegexp;
                    118:        int tobe,aux,infin,prepc,conjc,adv;
                    119:        char path[80];
                    120:        fflag=0;
                    121:        sflag=0;
                    122:        aud=0;
                    123:        note = note0;
                    124:        readmsg = read0;
                    125:        strcpy(path,LIB");
                    126:        if(argc >= 2){
                    127:                i=0;
                    128:                if(*(argv[1]+i) =='f') {
                    129:                        fflag=1;
                    130:                        i++;
                    131:                }
                    132:                if(*(argv[1]+i) =='s') {
                    133:                        sflag=1;
                    134:                        i++;
                    135:                }
                    136:                switch (*(argv[1]+i)){
                    137:                case 'm':
                    138:                        aud=0;
                    139:                        note = note0;
                    140:                        readmsg = read0;
                    141:                        break;
                    142:                case 't':
                    143:                        aud=2;
                    144:                        note = note2;
                    145:                        readmsg = read2;
                    146:                        strds(LIB/train.st","training");
                    147:                        break;
                    148:                case 'c':
                    149:                        aud=1;
                    150:                        note = note1;
                    151:                        readmsg = read1;
                    152:                        strds(LIB/crft.st","Craft");
                    153:                        break;
                    154:                case 'x':
                    155:                        aud=3;
                    156:                        note = note3;
                    157:                        readmsg = read3;
                    158:                        if((fp=fopen(argv[2],"r"))==NULL){
                    159:                                fprintf(stderr,"Prose can't find your standards file \"%s,\" try specifying a more complete pathname.\n",argv[2]);
                    160:                                exit(1);
                    161:                        }
                    162:                        break;
                    163:                }
                    164:        }
                    165: 
                    166:        if(aud==0)
                    167:                strds(LIB/tm.st","TM");
                    168: findbeg:
                    169:        if(fgets(save,81,stdin)==NULL){
                    170:                fprintf(stderr,"The file named after  the -f flag doesn't seem\
                    171:  to contain a style table.\nOr else style cannot produce a table for your\
                    172:  file.\n  Try running style alone on your file.\n");
                    173:                                exit(1);
                    174:        }
                    175:        ret=sscanf(save,"%*s%f%*s%f%*s%f%*s%f (%f)",
                    176:                &kindex,&aindex,&cindex,&fgrad,&findex);
                    177:         if(ret !=5 ) goto findbeg;
                    178:        gets(path);
                    179:        scanf("%*s%*s%d%*s%*s%ld",&numsent,&numwds);
                    180:        scanf("%*s%*s%*s%f%*s%*s%*s%f",&avw,&avl);
                    181:        scanf("%*s%*s%d%*s%*s%d",&qcount,&icount);
                    182:        scanf("%*s%*s%*s%d%f%%%*s%*s%f",&numnonf,&fnumnonf,&snonf);
                    183:        scanf("%*s%*s (<%d) %f%% (%d) %*s%*s (>%d) %f%% (%d)",
                    184:                &ml,&centlsum,&lsum,&mg,&centgsum,&gsum);
                    185:        scanf("%*s%*s%d%*s%*s%*s%d;%*s%*s%d%*s%*s%*s%d\n",
                    186:                &maxsent,&maxindex,&minsent,&minindex);
                    187:        gets(path);
                    188:        scanf("%*s%f%% (%d) %*s %f%% (%d)",&simple,&nsimple,&complex,&ncomplex);
                    189:        scanf("%*s%f%% (%d) %*s%f%% (%d)\n",
                    190:                &compound,&ncompound,&compdx,&ncompdx);
                    191:        gets(path);
                    192:        gets(path);
                    193:        scanf("%*s%f%% (%d) %*s %f%% (%d)%*s%f%% (%d)",
                    194:                &ptobe,&tobe,&paux,&aux,&pinfin,&infin);
                    195:        scanf("%*s%*s %% %*s%*s%*s%f%% (%d)\n",&passive,&npassive);
                    196:        gets(path);
                    197:        scanf("%*s %f%% (%d)%*s%f%% (%d)%*s%f%% (%d)",
                    198:                &pprepc,&prepc,&pconjc,&conjc,&padv,&adv);
                    199:        scanf("%*s%f%% (%d)%*s %f%% (%d)%*s%f%% (%d)",
                    200:                &pnoun,&noun, &padj,&adj,&ppron,&pron);
                    201:        scanf("%*s%f %% (%d)\n",&pnomin,&nomin);
                    202:        gets(path);
                    203:        scanf("%*s%*s%*s (%d)%*s (%d)%*s (%d)%*s (%d)%*s (%d)%*s%f%%",
                    204:                &noun,&pron,&pos,&adj,&art,&tot);
                    205:        scanf("%*s%f%% (%d)%*s%f%% (%d) ",&pbegprep,&begprep,&pbegadv,&begadv);
                    206:        scanf("%*s%f%% (%d) ",&pbegverb,&begverb);
                    207:        scanf("%*s%f%% (%d)%*s%f%% (%d)",&pbegscon,&begscon,&pbegconj,&begconj);
                    208:        scanf("%*s%f%% (%d)",&pbegexp,&begexp);
                    209: 
                    210:        /*variables used by the prose program*/
                    211:        var[READAB]=kindex;
                    212:        var[NONF]=snonf;
                    213:        var[2]=centlsum;
                    214:        var[3]=centgsum;
                    215:        var[4]=simple;
                    216:        var[5]=complex;
                    217:        var[6]=compound;
                    218:        var[7]=compdx;
                    219:        var[PASS]=passive;
                    220:        var[NOM]=pnomin;
                    221:        var[AVW]=avw;
                    222:        var[EXPL]=pbegexp;
                    223:        var[S_CPX]=simple-complex;
                    224:        var[13]=compound+compdx;
                    225: 
                    226:        /*read criterion values for variables from appropriate file*/
                    227:        ret=0;
                    228:        for(i=0;i <NVAR; i++)
                    229:                for(j=0;j<4; j++){
                    230:                        ret+=fscanf(fp,"%f",&array[i][j]);
                    231:                }
                    232: 
                    233:        /* make sure values were read correctly*/
                    234:         if(ret!=(NVAR*4)){
                    235:                fprintf(stderr,"The standards file is not formatted\
                    236:  properly.\nIt should have %d lines, each with 4 floating point numbers.\n",
                    237:                NVAR);
                    238:                exit(1);
                    239:        }
                    240: 
                    241:        /* Compare criterion values against STYLE produced scores*/
                    242: 
                    243:        for(i=0; i< NVAR; i++){
                    244:                sc[i]=0;
                    245:                for(j=0; j < 4;j++){
                    246:                        if(var[i] > array[i][j]) sc[i]=j+1;
                    247:                }
                    248:        }
                    249: 
                    250:        /*  Read percent of abstract words  */
                    251: 
                    252: 
                    253:        if(numwds < 2000 && numsent <100)
                    254:                printf(disclm);
                    255:        if(sflag) goto shortans ;
                    256:        printf(note,argv[2]);
                    257:                        /*READABILITY*/
                    258:        printf(kincaid,kindex);
                    259:        if(sc[READAB]==0){
                    260:                printf("which is a low score for  this type of document.");
                    261:                if (aud==0)
                    262:                        printf("  If this is\nan instructional text\
                    263:  (in paragraph form), run prose -t  for\na more appropriate review.\n");
                    264:                else if(aud==2)putchar('\n');
                    265:        }
                    266:        else if(sc[READAB] < 3)
                    267:                printf("which is a  good score for documents like this.\n");
                    268:        else {          /* ==3 or 4*/
                    269:                if(sc[READAB] == 3)qual=rather;
                    270:                else qual=very;
                    271:                printf("which is %s high for this type of document.",qual);
                    272:                if(aud != 1)printf(readmsg,(array[READAB][1]+array[READAB][2])/2.0);
                    273:                if(sc[NONF] > 2)
                    274:                        prtfile(LIB/rd2.t");
                    275:                if(aud == 1)printf(readmsg);
                    276: 
                    277:        }
                    278: 
                    279: 
                    280:        printf("\nVVAARRIIAATTIIOONN\n");
                    281:        if(sc[S_CPX]==4 || sc[S_CPX]==0 || tot >MAXLENG)
                    282:                        prtfile(LIB/var.t");
                    283:        if(sc[S_CPX]==0||sc[S_CPX]==4)
                    284:                printf("\n     In this  text %2.0f%% of  the sentences are\
                    285:  simple, %2.0f%% are\ncomplex, giving a difference of %3.0f.  This\
                    286:  difference should\nrange  from %2.0f to %2.0f for good documents of this\
                    287:  type.\n",simple,complex, simple-complex,array[S_CPX][1],array[S_CPX][2]);
                    288:        if(sc[S_CPX]==4){
                    289:                if(sc[AVW] < 2)
                    290:                        prtfile(LIB/type.t");
                    291:                else 
                    292:                        prtfile(LIB/type2.t");
                    293:        }
                    294:        else if(sc[S_CPX]==0){
                    295:                if(sc[READAB] < 3)
                    296:                        prtfile(LIB/var4.t");
                    297:                else
                    298:                        prtfile(LIB/var6.t");
                    299:        }
                    300:        else printf("\n     You have an appropriate distribution of sentence\
                    301:  types.\n");
                    302:        if(maxsent >= 50){
                    303:                if(sc[S_CPX]==0 || sc[S_CPX]==4)
                    304:                        printf("\n     Additionally,  the  longest sentence is\
                    305:  %d  words long.\n",maxsent);
                    306:                else printf("\n     The   longest  sentence,\
                    307:   however,  is %d  words  long.\n",maxsent);
                    308:                prtfile(LIB/var5.t");
                    309:        }
                    310:        if(sc[AVW] > 2){
                    311:                if(sc[S_CPX]==4 || sc[S_CPX]==0)
                    312:                        printf("\n     Such  changes would  also  help  to\
                    313:  reduce the  average\n");
                    314:                else  printf("\n     You should,  however,  consider\
                    315:  shortening your average\n");
                    316:                printf("sentence length.  Your average is %2.0f words,\
                    317:   which  is ",var[AVW]);
                    318:                if(sc[AVW]==3)printf("high.\n");
                    319:                if(sc[AVW]==4) printf(" very\nhigh.  ");
                    320:                printf("A good average would be %2.0f to %2.0f words.\n",
                    321:                        array[AVW][1],array[AVW][2]);
                    322:        }
                    323:        if(tot >MAXLENG){
                    324:                printf(begmsg,tot);
                    325:        }
                    326:        printf("\nSSEENNTTEENNCCEE SSTTRRUUCCTTUURREE\n");
                    327:        if(sc[PASS]<=2 && sc[NOM] <=2) {
                    328:                printf(pas_nom);
                    329:        }
                    330:        else {
                    331:                printf("\n   _P_a_s_s_i_v_e_s\n");
                    332:                if(sc[PASS] > 2){
                    333:                        if(sc[PASS] == 3)qual=null;
                    334:                        else qual=much;
                    335:                        printf(badpas,qual,var[PASS],(array[PASS][1]+array[PASS][2])/2.0);
                    336:                        prtfile(LIB/pass.t");
                    337:                }
                    338:                else printf("\n     You have limited your passives appropriately.\n");
                    339:                printf("\n   _N_o_m_i_n_a_l_i_z_a_t_i_o_n_s\n");
                    340:                if(sc[NOM] > 2){
                    341:                        printf(badnom,var[NOM],(array[NOM][1]+array[NOM][2])/2.0);
                    342:                        prtfile(LIB/nom.t");
                    343:                }
                    344:                else printf("\n     You  have  appropriately limited  your\
                    345:   nominalizations\n\(nouns made from verbs, e.g., \"description\"\).\n");
                    346:        }
                    347:        if(sc[EXPL]==4){
                    348:                printf(badexp,var[EXPL],(array[EXPL][1]+array[EXPL][2])/2.0);
                    349:                prtfile(LIB/exp.t");
                    350:        }
                    351:        if(sc[PASS]>2 && sc[NOM]>2){
                    352:                printf(more_str);
                    353:        }
                    354:        if(!fflag){
                    355:                if(aud==0)
                    356:                        prtfile(LIB/popttm.t");
                    357:                else if(aud==2)
                    358:                        prtfile(LIB/poptt.t");
                    359:        }
                    360:        prtfile(LIB/fur.t");
                    361:        exit(0);
                    362: shortans : 
                    363:        if(aud==0) printf("Compared to TMs.\n\n");
                    364:        else if(aud==1) printf("Evaluated for Craft.\n\n");
                    365:        else if(aud==2) printf("Compared to training material.\n\n");
                    366:        else if(aud==3)printf("Compared to file \"%s\"\n",argv[2]);
                    367:        printf("Reading grade level--%2.0f: ",kindex);
                    368:        if(sc[READAB]==1 || sc[READAB]==2) printf("Good\n");
                    369:        else if(sc[READAB]==0) printf("Low\n");
                    370:        else if(sc[READAB]==3) printf("High\n");
                    371:        else if(sc[READAB]==4)printf("Very high\n");
                    372: 
                    373: 
                    374:        printf("Variation--");
                    375:        if(sc[S_CPX] == 4)
                    376:                 printf("Too many short, simple sentences--subordinate.\n");
                    377:        else if(sc[S_CPX]==0) printf("Too many complex sentences.\n");
                    378:        else printf("Good sentence type distribution.\n");
                    379:        if(sc[AVW] > 2){
                    380:                if(sc[AVW]==3)
                    381:                        qual = too;
                    382:                else qual = very;
                    383:                printf("             Sentences are %s long--avg\
                    384:  length=%2.1f words\n",qual,var[AVW]);
                    385:                printf("                                   --Good length\
                    386:  = %2.1f to %2.1f\n",array[AVW][1],array[AVW][2]);
                    387:        }
                    388:        if( maxsent >50)
                    389:                 printf("Longest sentence is %d words---perhaps it is a list\n"
                    390:                        ,maxsent);
                    391:        if(tot >MAXLENG)
                    392:                printf("             %2.0f%%= Too many sentences begin with\
                    393:  the subject.\n",tot);
                    394: 
                    395:        printf("Passives--%2.0f%%: ",passive);
                    396:        if(sc[PASS]<=2)printf("Good\n");
                    397:        else if(sc[PASS] ==3)printf("High\n");
                    398:        else if(sc[PASS]==4)printf("Very high\n");
                    399: 
                    400:        printf("Nominalizations--%2.0f%%: ",pnomin);
                    401:        if(sc[NOM]<=2)printf("Good\n");
                    402:        else if(sc[NOM]==3)printf("High\n");
                    403:        else if(sc[NOM]==4)printf("Very high\n");
                    404: 
                    405:        if(sc[EXPL]==4)printf("Expletive--%2.0f%%: Very high\n",pbegexp);
                    406:        if (!fflag) printf("Don't forget the styl.tmp file.\n");
                    407:        putchar('\n');
                    408: }
                    409: prtfile(s)
                    410: char *s;
                    411: {
                    412:        FILE *ff;
                    413:        char ch[512];
                    414:        int num;
                    415:        if((ff=fopen(s,"r"))==NULL){
                    416:                fprintf(stderr,"Prose can't find the file %s\n",s);
                    417:                exit(1);
                    418:        }
                    419:        while((num=fread(ch,sizeof(ch[0]),512,ff)))
                    420:                fwrite(ch,sizeof(ch[0]),num,stdout);
                    421:        fclose(ff);
                    422: }
                    423: strds(s1,s2)
                    424: char *s1, *s2;
                    425: {
                    426:        if((fp=fopen(s1,"r"))==NULL){
                    427:                fprintf(stderr,"Prose can't find the %s standards file %s\n",
                    428:                        s2,s1);
                    429:                exit(1);
                    430:        }
                    431: }

unix.superglobalmegacorp.com

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