1*9075Srrh #ifndef lint 2*9075Srrh static char sccsid[] = "@(#)outp.c 4.1 (Berkeley) 82/11/06"; 3*9075Srrh #endif not lint 4*9075Srrh 5*9075Srrh #include "style.h" 6*9075Srrh #include "names.h" 7*9075Srrh #include "conp.h" 8*9075Srrh char *names[] = { 9*9075Srrh "noun", "verb", "interjection", "adjective", "adverb", "conjunction", "possessive", 10*9075Srrh "pronoun", "article", "preposition", "auxiliary", "tobe", "subordinate conjunction", "", "expletive" 11*9075Srrh }; 12*9075Srrh outp(){ 13*9075Srrh struct ss *st; 14*9075Srrh char *ssp; 15*9075Srrh char *spart, ff; 16*9075Srrh int index, lverbc; 17*9075Srrh int nn, sc, f, kk,comp, begsc; 18*9075Srrh int conjf, verbf,lpas,bflg,lexp,olvb; 19*9075Srrh int infinf, ovflg; 20*9075Srrh int lvowel,nlet; 21*9075Srrh int imper; 22*9075Srrh float rd; 23*9075Srrh 24*9075Srrh if(style){ 25*9075Srrh nn = kk = 0; 26*9075Srrh for(sentp=sent;sentp->cc != END;sentp++){ 27*9075Srrh if(sentp->cc != ',' && sentp->cc != '"')nn++; 28*9075Srrh if(sentp->cc == VERB || sentp->cc == BE || sentp->cc == AUX)kk++; 29*9075Srrh } 30*9075Srrh if(nn < 4 && kk == 0)return; 31*9075Srrh } 32*9075Srrh 33*9075Srrh imper = lexp = lpas = index = lverbc = 0; 34*9075Srrh conjf = verbf = kk = nn = sc = comp = begsc = 0; 35*9075Srrh bflg = olvb = infinf = ovflg = 0; 36*9075Srrh nlet = 0; 37*9075Srrh f = 1; 38*9075Srrh sentp=sent; 39*9075Srrh while(sentp->cc != END){ 40*9075Srrh /* printf("%c:",sentp->ic); */ 41*9075Srrh if(sentp->cc == ';')comp++; 42*9075Srrh else { 43*9075Srrh if((sentp->cc != ',') && (sentp->cc != '"')){ 44*9075Srrh if(*sentp->sp != 'x'){ 45*9075Srrh nn++; 46*9075Srrh nlet += sentp->leng; 47*9075Srrh } 48*9075Srrh kk++; 49*9075Srrh } 50*9075Srrh } 51*9075Srrh switch(sentp->cc){ 52*9075Srrh case NOUN: 53*9075Srrh spart ="noun"; 54*9075Srrh if(f)index=0; 55*9075Srrh if(*sentp->sp != 'x'){ 56*9075Srrh noun++; 57*9075Srrh numnonf++; 58*9075Srrh letnonf += sentp->leng; 59*9075Srrh } 60*9075Srrh bflg = infinf = ovflg = 0; 61*9075Srrh break; 62*9075Srrh case VERB: 63*9075Srrh spart = "verb"; 64*9075Srrh if(f)index=1; 65*9075Srrh if(sentp->ic==TO){ 66*9075Srrh infin++; 67*9075Srrh infinf=1; 68*9075Srrh lverbc++; 69*9075Srrh } 70*9075Srrh else { 71*9075Srrh if(f)imper=1; 72*9075Srrh if(ovflg == 0 && infinf == 0){ 73*9075Srrh ovflg = 1; 74*9075Srrh lverbc++; 75*9075Srrh olvb++; 76*9075Srrh } 77*9075Srrh numnonf++; 78*9075Srrh letnonf += sentp->leng; 79*9075Srrh if(infinf == 0){ 80*9075Srrh if(verbf == 0)verbf++; 81*9075Srrh else if(conjf)comp++; 82*9075Srrh } 83*9075Srrh if(bflg && sentp->ic == ED)lpas = ++passive; 84*9075Srrh } 85*9075Srrh break; 86*9075Srrh case INTER: 87*9075Srrh spart = "interj"; 88*9075Srrh if(f)index=2; 89*9075Srrh bflg = infinf = ovflg = 0; 90*9075Srrh break; 91*9075Srrh case ADJ: 92*9075Srrh spart = "adj"; 93*9075Srrh if(f)index=3; 94*9075Srrh adj++; 95*9075Srrh numnonf++; 96*9075Srrh letnonf += sentp->leng; 97*9075Srrh bflg = infinf = ovflg = 0; 98*9075Srrh break; 99*9075Srrh case ADV: 100*9075Srrh spart = "adv"; 101*9075Srrh if(f)index=4; 102*9075Srrh adv++; 103*9075Srrh numnonf++; 104*9075Srrh letnonf += sentp->leng; 105*9075Srrh break; 106*9075Srrh case CONJ: 107*9075Srrh spart = "conj"; 108*9075Srrh conjc++; 109*9075Srrh if(f)index=5; 110*9075Srrh if(infinf && (sentp+1)->cc == VERB); 111*9075Srrh else { 112*9075Srrh if(verbf)conjf++; 113*9075Srrh bflg = infinf = ovflg = 0; 114*9075Srrh } 115*9075Srrh break; 116*9075Srrh case POS: 117*9075Srrh spart = "pos"; 118*9075Srrh if(f)index=6; 119*9075Srrh bflg = infinf = ovflg = 0; 120*9075Srrh break; 121*9075Srrh case PRONS: 122*9075Srrh case PRONP: 123*9075Srrh spart = "pron"; 124*9075Srrh pron++; 125*9075Srrh if(f){ 126*9075Srrh index=7; 127*9075Srrh if((sentp+1)->cc == BE){ 128*9075Srrh if(sentp->leng == 5 && *(sentp->sp) == 't' && *((sentp->sp)+3)=='r'){index=14;lexp=1;} 129*9075Srrh else if(sentp->leng ==2&& *(sentp->sp) == 'i' ){index=14;lexp=1;} 130*9075Srrh } 131*9075Srrh } 132*9075Srrh bflg = infinf = ovflg = 0; 133*9075Srrh if(sentp->ic == THAT || sentp->ic == WHO)sc++; 134*9075Srrh break; 135*9075Srrh case ART: 136*9075Srrh spart = "art"; 137*9075Srrh if(f)index=8; 138*9075Srrh bflg = infinf = ovflg = 0; 139*9075Srrh break; 140*9075Srrh case PREP: 141*9075Srrh spart = "prep"; 142*9075Srrh if(f)index=9; 143*9075Srrh prepc++; 144*9075Srrh bflg = infinf = ovflg = 0; 145*9075Srrh break; 146*9075Srrh case AUXX: 147*9075Srrh spart = "aux"; 148*9075Srrh if(ovflg == 0 && infinf == 0){ 149*9075Srrh ovflg = 1; 150*9075Srrh lverbc++; 151*9075Srrh olvb++; 152*9075Srrh aux++; 153*9075Srrh } 154*9075Srrh if(f)index=10; 155*9075Srrh break; 156*9075Srrh case BE: 157*9075Srrh if(ovflg == 0 && infinf == 0){ 158*9075Srrh ovflg = 1; 159*9075Srrh lverbc++; 160*9075Srrh olvb++; 161*9075Srrh } 162*9075Srrh spart = "be"; 163*9075Srrh if(f)index=11; 164*9075Srrh tobe++; 165*9075Srrh bflg = 1; 166*9075Srrh if(verbf == 0)verbf++; 167*9075Srrh else if(conjf)comp++; 168*9075Srrh break; 169*9075Srrh case SUBCONJ: 170*9075Srrh spart = "subcj"; 171*9075Srrh if(f){ 172*9075Srrh index=13; 173*9075Srrh begsc++; 174*9075Srrh } 175*9075Srrh sc++; 176*9075Srrh if((sentp-1)->cc != CONJ) 177*9075Srrh verbf = conjf = 0; 178*9075Srrh bflg = infinf = ovflg = 0; 179*9075Srrh break; 180*9075Srrh default: 181*9075Srrh if(sentp->cc == ','){ 182*9075Srrh if(begsc)conjf=verbf=0; 183*9075Srrh } 184*9075Srrh spart = sentp->sp; 185*9075Srrh } 186*9075Srrh if(part){ 187*9075Srrh printf("%s %s\n",spart,sentp->sp); 188*9075Srrh } 189*9075Srrh else if(pstyle){ 190*9075Srrh printf("%s ",sentp->sp); 191*9075Srrh if(kk == 15){ 192*9075Srrh printf("\n"); 193*9075Srrh kk=0; 194*9075Srrh } 195*9075Srrh } 196*9075Srrh if(style){ 197*9075Srrh ssp=sentp->sp; 198*9075Srrh lvowel = 0; 199*9075Srrh while(*ssp != '\0'){ 200*9075Srrh if(*ssp >= '0' && *ssp <= '9'){ 201*9075Srrh lvowel=0; 202*9075Srrh break; 203*9075Srrh } 204*9075Srrh switch(*(ssp++)){ 205*9075Srrh case 'a': 206*9075Srrh case 'e': 207*9075Srrh case 'i': 208*9075Srrh case 'o': 209*9075Srrh case 'u': 210*9075Srrh case 'y': 211*9075Srrh case 'A': 212*9075Srrh case 'E': 213*9075Srrh case 'I': 214*9075Srrh case 'O': 215*9075Srrh case 'U': 216*9075Srrh case 'Y': 217*9075Srrh lvowel++; 218*9075Srrh continue; 219*9075Srrh } 220*9075Srrh } 221*9075Srrh if(lvowel != 0){ 222*9075Srrh vowel += lvowel; 223*9075Srrh twds++; 224*9075Srrh } 225*9075Srrh } 226*9075Srrh if(f){ 227*9075Srrh ff=sentp->cc; 228*9075Srrh f=0; 229*9075Srrh } 230*9075Srrh sentp++; 231*9075Srrh } 232*9075Srrh if(part){ 233*9075Srrh printf(". %s\n",sentp->sp); 234*9075Srrh } 235*9075Srrh numsent++; 236*9075Srrh numlet += nlet; 237*9075Srrh tverbc += lverbc; 238*9075Srrh verbc += olvb; 239*9075Srrh if(*(sentp->sp) == '?'){ 240*9075Srrh if(sc > 0)sc -= 1; 241*9075Srrh qcount++; 242*9075Srrh } 243*9075Srrh else if(*(sentp->sp) == '/')icount++; 244*9075Srrh else if(imper)icount++; 245*9075Srrh if(rstyle||pstyle)rd = 4.71*((float)(nlet)/(float)(nn))+.5*(float)(nn)-21.43; 246*9075Srrh if((rstyle&& rd>=rthresh)||(lstyle&&nn >= lthresh)||(pastyle&&lpas)||(estyle&&lexp)){ 247*9075Srrh if(!part){ 248*9075Srrh for(st=sent, kk=0;st->cc != END;st++){ 249*9075Srrh printf("%s ",st->sp); 250*9075Srrh if(kk++ >= 15){ 251*9075Srrh kk=0; 252*9075Srrh printf("\n"); 253*9075Srrh } 254*9075Srrh } 255*9075Srrh } 256*9075Srrh kk=1; 257*9075Srrh } 258*9075Srrh else kk=0; 259*9075Srrh if(pstyle || kk){ 260*9075Srrh if(!part)printf("%s\n",sentp->sp); 261*9075Srrh printf(" sentence length: %d ",nn); 262*9075Srrh if(sc == 0){ 263*9075Srrh if(comp == 0)printf("SIMPLE "); 264*9075Srrh else printf("COMPOUND "); 265*9075Srrh } 266*9075Srrh else if(comp == 0)printf("COMPLEX "); 267*9075Srrh else printf("COMPOUND-COMPLEX "); 268*9075Srrh if(index==14)printf(":expletive:"); 269*9075Srrh if(lpas)printf(":passive:"); 270*9075Srrh if(rstyle||pstyle)printf(" readability %4.2f ",rd); 271*9075Srrh printf(": begins with %s\n\n",names[index]); 272*9075Srrh } 273*9075Srrh if(index < 15)beg[index]++; 274*9075Srrh if(nn > maxsent){ 275*9075Srrh maxsent=nn; 276*9075Srrh maxindex=numsent; 277*9075Srrh } 278*9075Srrh if(nn < minsent ){ 279*9075Srrh minsent = nn; 280*9075Srrh minindex=numsent; 281*9075Srrh } 282*9075Srrh numwds += nn; 283*9075Srrh if(nn > 49)nn=49; 284*9075Srrh sleng[nn]++; 285*9075Srrh if(sc == 0){ 286*9075Srrh if(comp == 0)simple++; 287*9075Srrh else compound++; 288*9075Srrh } 289*9075Srrh else if(comp == 0)complex++; 290*9075Srrh else compdx++; 291*9075Srrh } 292