19075Srrh #ifndef lint 2*9081Srrh static char sccsid[] = "@(#)outp.c 4.2 (Berkeley) 82/11/06"; 39075Srrh #endif not lint 49075Srrh 5*9081Srrh #include <stdio.h> 6*9081Srrh #include <ctype.h> 79075Srrh #include "style.h" 89075Srrh #include "names.h" 99075Srrh #include "conp.h" 109075Srrh char *names[] = { 119075Srrh "noun", "verb", "interjection", "adjective", "adverb", "conjunction", "possessive", 12*9081Srrh "pronoun", "article", "preposition", "auxiliary", "tobe", "", "subordinate conjunction", "expletive" 139075Srrh }; 14*9081Srrh extern int barebones; 159075Srrh outp(){ 169075Srrh struct ss *st; 179075Srrh char *ssp; 189075Srrh char *spart, ff; 199075Srrh int index, lverbc; 209075Srrh int nn, sc, f, kk,comp, begsc; 219075Srrh int conjf, verbf,lpas,bflg,lexp,olvb; 22*9081Srrh int nom; 239075Srrh int infinf, ovflg; 249075Srrh int lvowel,nlet; 259075Srrh int imper; 269075Srrh float rd; 27*9081Srrh extern FILE *deb; 28*9081Srrh extern int nosave; 299075Srrh 30*9081Srrh if(barebones){ 31*9081Srrh for(sentp=sent;sentp->cc != END;sentp++) 32*9081Srrh printf("%s %c %c\n",sentp->sp,sentp->ic,sentp->cc); 33*9081Srrh printf("%s %c %c\n",sentp->sp,sentp->ic,sentp->cc); 34*9081Srrh return; 35*9081Srrh } 36*9081Srrh if(topic){ 37*9081Srrh for(sentp=sent;sentp->cc != END;sentp++){ 38*9081Srrh if(sentp->cc==ADJ && (sentp+1)->cc==NOUN){ 39*9081Srrh printf("%s ",sentp->sp); 40*9081Srrh sentp++; 41*9081Srrh printf("%s\n",sentp->sp); 42*9081Srrh } 43*9081Srrh else if(sentp->cc==NOUN)printf("%s\n",sentp->sp); 44*9081Srrh } 45*9081Srrh return; 46*9081Srrh } 479075Srrh if(style){ 489075Srrh nn = kk = 0; 499075Srrh for(sentp=sent;sentp->cc != END;sentp++){ 509075Srrh if(sentp->cc != ',' && sentp->cc != '"')nn++; 519075Srrh if(sentp->cc == VERB || sentp->cc == BE || sentp->cc == AUX)kk++; 529075Srrh } 539075Srrh if(nn < 4 && kk == 0)return; 549075Srrh } 559075Srrh 56*9081Srrh imper = lexp = lpas = index = lverbc = nom = 0; 579075Srrh conjf = verbf = kk = nn = sc = comp = begsc = 0; 589075Srrh bflg = olvb = infinf = ovflg = 0; 599075Srrh nlet = 0; 609075Srrh f = 1; 619075Srrh sentp=sent; 629075Srrh while(sentp->cc != END){ 639075Srrh /* printf("%c:",sentp->ic); */ 649075Srrh if(sentp->cc == ';')comp++; 659075Srrh else { 669075Srrh if((sentp->cc != ',') && (sentp->cc != '"')){ 679075Srrh if(*sentp->sp != 'x'){ 689075Srrh nn++; 699075Srrh nlet += sentp->leng; 709075Srrh } 719075Srrh kk++; 729075Srrh } 739075Srrh } 749075Srrh switch(sentp->cc){ 759075Srrh case NOUN: 769075Srrh spart ="noun"; 779075Srrh if(f)index=0; 78*9081Srrh if((sentp->ic==NOM)||(sentp->ic==PNOUN && islower(*(sentp->sp)))){ 79*9081Srrh sentp->ic = NOM; 80*9081Srrh nom++; 81*9081Srrh if(nosave && (deb != NULL)) /* SAVE NOM */ 82*9081Srrh fprintf(deb,"%s\n",sentp->sp); 83*9081Srrh } 849075Srrh if(*sentp->sp != 'x'){ 859075Srrh noun++; 869075Srrh numnonf++; 879075Srrh letnonf += sentp->leng; 889075Srrh } 899075Srrh bflg = infinf = ovflg = 0; 909075Srrh break; 919075Srrh case VERB: 929075Srrh spart = "verb"; 939075Srrh if(f)index=1; 949075Srrh if(sentp->ic==TO){ 959075Srrh infin++; 969075Srrh infinf=1; 979075Srrh lverbc++; 989075Srrh } 999075Srrh else { 1009075Srrh if(f)imper=1; 1019075Srrh if(ovflg == 0 && infinf == 0){ 1029075Srrh ovflg = 1; 1039075Srrh lverbc++; 1049075Srrh olvb++; 1059075Srrh } 1069075Srrh numnonf++; 1079075Srrh letnonf += sentp->leng; 1089075Srrh if(infinf == 0){ 1099075Srrh if(verbf == 0)verbf++; 1109075Srrh else if(conjf)comp++; 1119075Srrh } 112*9081Srrh if(bflg && sentp->ic == ED){lpas++; ++passive;} 1139075Srrh } 1149075Srrh break; 1159075Srrh case INTER: 1169075Srrh spart = "interj"; 1179075Srrh if(f)index=2; 1189075Srrh bflg = infinf = ovflg = 0; 1199075Srrh break; 1209075Srrh case ADJ: 1219075Srrh spart = "adj"; 1229075Srrh if(f)index=3; 1239075Srrh adj++; 1249075Srrh numnonf++; 125*9081Srrh if(sentp->ic == NOM){ 126*9081Srrh nom++; 127*9081Srrh if(nosave && (deb != NULL)) /* SAVE NOM */ 128*9081Srrh fprintf(deb,"%s\n",sentp->sp); 129*9081Srrh } 1309075Srrh letnonf += sentp->leng; 1319075Srrh bflg = infinf = ovflg = 0; 1329075Srrh break; 1339075Srrh case ADV: 1349075Srrh spart = "adv"; 1359075Srrh if(f)index=4; 1369075Srrh adv++; 1379075Srrh numnonf++; 1389075Srrh letnonf += sentp->leng; 1399075Srrh break; 1409075Srrh case CONJ: 1419075Srrh spart = "conj"; 1429075Srrh conjc++; 1439075Srrh if(f)index=5; 1449075Srrh if(infinf && (sentp+1)->cc == VERB); 1459075Srrh else { 1469075Srrh if(verbf)conjf++; 1479075Srrh bflg = infinf = ovflg = 0; 1489075Srrh } 1499075Srrh break; 1509075Srrh case POS: 1519075Srrh spart = "pos"; 1529075Srrh if(f)index=6; 1539075Srrh bflg = infinf = ovflg = 0; 1549075Srrh break; 1559075Srrh case PRONS: 1569075Srrh case PRONP: 1579075Srrh spart = "pron"; 1589075Srrh pron++; 1599075Srrh if(f){ 1609075Srrh index=7; 1619075Srrh if((sentp+1)->cc == BE){ 1629075Srrh if(sentp->leng == 5 && *(sentp->sp) == 't' && *((sentp->sp)+3)=='r'){index=14;lexp=1;} 1639075Srrh else if(sentp->leng ==2&& *(sentp->sp) == 'i' ){index=14;lexp=1;} 1649075Srrh } 1659075Srrh } 1669075Srrh bflg = infinf = ovflg = 0; 1679075Srrh if(sentp->ic == THAT || sentp->ic == WHO)sc++; 1689075Srrh break; 1699075Srrh case ART: 1709075Srrh spart = "art"; 1719075Srrh if(f)index=8; 1729075Srrh bflg = infinf = ovflg = 0; 1739075Srrh break; 1749075Srrh case PREP: 1759075Srrh spart = "prep"; 1769075Srrh if(f)index=9; 1779075Srrh prepc++; 1789075Srrh bflg = infinf = ovflg = 0; 1799075Srrh break; 1809075Srrh case AUXX: 1819075Srrh spart = "aux"; 1829075Srrh if(ovflg == 0 && infinf == 0){ 1839075Srrh ovflg = 1; 1849075Srrh lverbc++; 1859075Srrh olvb++; 1869075Srrh aux++; 1879075Srrh } 1889075Srrh if(f)index=10; 1899075Srrh break; 1909075Srrh case BE: 1919075Srrh if(ovflg == 0 && infinf == 0){ 1929075Srrh ovflg = 1; 1939075Srrh lverbc++; 1949075Srrh olvb++; 1959075Srrh } 1969075Srrh spart = "be"; 1979075Srrh if(f)index=11; 1989075Srrh tobe++; 1999075Srrh bflg = 1; 2009075Srrh if(verbf == 0)verbf++; 2019075Srrh else if(conjf)comp++; 2029075Srrh break; 2039075Srrh case SUBCONJ: 2049075Srrh spart = "subcj"; 2059075Srrh if(f){ 2069075Srrh index=13; 2079075Srrh begsc++; 2089075Srrh } 2099075Srrh sc++; 2109075Srrh if((sentp-1)->cc != CONJ) 2119075Srrh verbf = conjf = 0; 2129075Srrh bflg = infinf = ovflg = 0; 2139075Srrh break; 2149075Srrh default: 2159075Srrh if(sentp->cc == ','){ 2169075Srrh if(begsc)conjf=verbf=0; 2179075Srrh } 2189075Srrh spart = sentp->sp; 2199075Srrh } 2209075Srrh if(part){ 2219075Srrh printf("%s %s\n",spart,sentp->sp); 2229075Srrh } 2239075Srrh if(style){ 2249075Srrh ssp=sentp->sp; 2259075Srrh lvowel = 0; 2269075Srrh while(*ssp != '\0'){ 2279075Srrh if(*ssp >= '0' && *ssp <= '9'){ 2289075Srrh lvowel=0; 2299075Srrh break; 2309075Srrh } 2319075Srrh switch(*(ssp++)){ 2329075Srrh case 'a': 2339075Srrh case 'e': 2349075Srrh case 'i': 2359075Srrh case 'o': 2369075Srrh case 'u': 2379075Srrh case 'y': 2389075Srrh case 'A': 2399075Srrh case 'E': 2409075Srrh case 'I': 2419075Srrh case 'O': 2429075Srrh case 'U': 2439075Srrh case 'Y': 2449075Srrh lvowel++; 2459075Srrh continue; 2469075Srrh } 2479075Srrh } 2489075Srrh if(lvowel != 0){ 2499075Srrh vowel += lvowel; 2509075Srrh twds++; 2519075Srrh } 2529075Srrh } 2539075Srrh if(f){ 2549075Srrh ff=sentp->cc; 2559075Srrh f=0; 2569075Srrh } 2579075Srrh sentp++; 2589075Srrh } 2599075Srrh if(part){ 260*9081Srrh printf(". %s\n",sentp->sp); 261*9081Srrh if(sentno < MAXPAR && nn > 0) 262*9081Srrh leng[sentno++] = nn; 2639075Srrh } 264*9081Srrh if(nn == 0)return; 2659075Srrh numsent++; 2669075Srrh numlet += nlet; 2679075Srrh tverbc += lverbc; 2689075Srrh verbc += olvb; 2699075Srrh if(*(sentp->sp) == '?'){ 2709075Srrh if(sc > 0)sc -= 1; 2719075Srrh qcount++; 2729075Srrh } 2739075Srrh else if(*(sentp->sp) == '/')icount++; 2749075Srrh else if(imper)icount++; 2759075Srrh if(rstyle||pstyle)rd = 4.71*((float)(nlet)/(float)(nn))+.5*(float)(nn)-21.43; 276*9081Srrh if(pstyle || 277*9081Srrh (rstyle&& rd>=rthresh)||(lstyle&&nn >= lthresh)||(pastyle&&lpas)||(estyle&&lexp) 278*9081Srrh || (nstyle && (nom > 1 || (nom && lpas)))|| (Nstyle && nom)){ 2799075Srrh if(!part){ 2809075Srrh for(st=sent, kk=0;st->cc != END;st++){ 281*9081Srrh if(st->ic == NOM) 282*9081Srrh printf("*%s* ",st->sp); 283*9081Srrh else printf("%s ",st->sp); 2849075Srrh if(kk++ >= 15){ 2859075Srrh kk=0; 2869075Srrh printf("\n"); 2879075Srrh } 2889075Srrh } 2899075Srrh } 2909075Srrh kk=1; 2919075Srrh } 2929075Srrh else kk=0; 2939075Srrh if(pstyle || kk){ 2949075Srrh if(!part)printf("%s\n",sentp->sp); 2959075Srrh printf(" sentence length: %d ",nn); 2969075Srrh if(sc == 0){ 2979075Srrh if(comp == 0)printf("SIMPLE "); 2989075Srrh else printf("COMPOUND "); 2999075Srrh } 3009075Srrh else if(comp == 0)printf("COMPLEX "); 3019075Srrh else printf("COMPOUND-COMPLEX "); 3029075Srrh if(index==14)printf(":expletive:"); 3039075Srrh if(lpas)printf(":passive:"); 3049075Srrh if(rstyle||pstyle)printf(" readability %4.2f ",rd); 3059075Srrh printf(": begins with %s\n\n",names[index]); 3069075Srrh } 3079075Srrh if(index < 15)beg[index]++; 3089075Srrh if(nn > maxsent){ 3099075Srrh maxsent=nn; 3109075Srrh maxindex=numsent; 3119075Srrh } 3129075Srrh if(nn < minsent ){ 3139075Srrh minsent = nn; 3149075Srrh minindex=numsent; 3159075Srrh } 3169075Srrh numwds += nn; 3179075Srrh if(nn > 49)nn=49; 3189075Srrh sleng[nn]++; 3199075Srrh if(sc == 0){ 3209075Srrh if(comp == 0)simple++; 3219075Srrh else compound++; 3229075Srrh } 3239075Srrh else if(comp == 0)complex++; 3249075Srrh else compdx++; 3259075Srrh } 326