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

Defined functions

outp defined in line 15; never used

Defined variables

names defined in line 10; used 1 times
sccsid defined in line 2; never used
Last modified: 1983-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1041
Valid CSS Valid XHTML 1.0 Strict