Annotation of researchv10no/cmd/style/outp.c, revision 1.1

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

unix.superglobalmegacorp.com

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