1: #ifndef lint
   2: static char sccsid[] = "@(#)pscan.c	4.2	(Berkeley)	82/11/06";
   3: #endif not lint
   4: 
   5: #include "names.h"
   6: #include "conp.h"
   7: #define isadv(c)    (c == ADV || c == ADJ_ADV)
   8: #define isadj(c)    (c == ADJ || c == NOUN_ADJ || c == ADJ_ADV || c == UNK)
   9: #define notnoun(c)  (c != NOUN && c != UNK && c != NOUN_VERB && c != NV_PL && c != PNOUN)
  10: #define issing(c)   (c == UNK || c == NOUN_VERB || c == NOUN || c == NOM || c == NOUN_ADJ)
  11: #define isnoun(c)   (c == NOUN || c == NOUN_VERB || c == NV_PL || c == UNK || c == PNOUN)
  12: #define nounnom(c)  (c == NOUN || c == NOM)
  13: char lastc,nextc;
  14: int savsub;
  15: scan(si,ce,command) /*scan a phrase */
  16: int si;
  17: char ce;
  18: {
  19:     int savi;
  20:     char c;
  21:     i=si;
  22:     if(command == 1)subty = PLURAL;
  23:     else subty = 0;
  24:     if(sent[i].cc==ADJ_ADV && sent[i+1].cc != NOUN && sent[i+1].cc != UNK && sent[i+1].cc != ADJ)
  25:         sent[i++].cc = ADV;
  26:     done=0;
  27:     verb = 0;
  28:     verb=getv(i,ce);    /*get verb if obvious*/
  29:     if(command == 0)j=getnoun(i,ce);        /*get subject*/
  30:     else j = si;
  31:     if(i != j || ((i==j) && sent[i].cc == NOUN)){
  32:         i = j+1;
  33:     }
  34:     for(;((c=sent[i].cc) != ce) && (c != END)  && (c != '\0');i++){
  35:         nextc=sent[i+1].cc;
  36:         if(i>0){
  37:             lastc=sent[i-1].cc;
  38:             if(lastc==BE)be=1;
  39:             else{
  40:                 if(lastc != ADV)be=0;
  41:             }
  42:         }
  43:         else lastc=0;
  44:         if(verb==1)question=0;
  45:         switch(c){
  46:         case '"':
  47:             if(nextc==ED || nextc == MVERB){
  48:                 verb=1;
  49:                 sent[++i].cc=VERB;
  50:                 subty=SING;
  51:                 continue;
  52:             }
  53:             subty=0;
  54:             verb=getv(++i,ce);
  55:             i=getnoun(i,ce);
  56:             continue;
  57:         case MVERB:
  58:             sent[i].cc = VERB;
  59:             if(i < nsleng*.5){
  60:                 verb = getv(++i,ce);
  61:                 i = getnoun(i,ce);
  62:                 continue;
  63:             }
  64:             continue;
  65:         case ART:
  66:         case ADJ:
  67:         case POS:
  68:         case ING:
  69:             aflg=1;
  70:             i=getnoun(i,ce);
  71:             aflg=0;
  72:             continue;
  73:         case PREP:
  74:             if(nextc == ce){
  75:                 sent[i].cc=ADV;
  76:                 goto sdone;
  77:             }
  78:             prep=1;
  79:             i=getnoun(++i,ce);
  80:             prep=0;
  81:             continue;
  82:         case VERB_ADJ:
  83:             if(verb==0){
  84:                 sent[i].cc=VERB;
  85:                 verb=1;
  86:                 continue;
  87:             }
  88:         case NOUN_ADJ:
  89:             if(be==1){
  90:                 sent[i].cc=ADJ;
  91:                 continue;
  92:             }
  93:         case PRONP_ADJ:
  94:         case PRONS_ADJ:
  95:             i=getnoun(i,ce);
  96:             continue;
  97:         case NOUN_ADV:
  98:             if(verb == 1 && iverb == i+1){
  99:                 sent[i].cc = NOUN;
 100:             }
 101:             else {
 102:                 sent[i].cc = ADV;
 103:             }
 104:             continue;
 105:         case ADJ_ADV:
 106:             if(be == 1){
 107:                 if (isadj(nextc)) {
 108:                     sent[i].cc = ADV;
 109:                     continue;
 110:                 }
 111:                 if(nextc == ',' && isadv(sent[i+2].cc)) {
 112:                     sent[i++].cc = ADV;
 113:                     sent[++i].cc = ADV;
 114:                     comma--;
 115:                     continue;
 116:                 }
 117:                 sent[i].cc = ADJ;
 118:                 continue;
 119:             }
 120:             if(lastc == NOUN && (nextc == ',' || nextc == END)){
 121:                 sent[i].cc=ADJ;
 122:                 continue;
 123:             }
 124:             if(notnoun(nextc)){
 125:                 sent[i].cc=ADV;
 126:                 continue;
 127:             }
 128:             sent[i].cc=ADJ;
 129:             continue;
 130:         case WHO:
 131:             i=who(i,ce);
 132:             continue;
 133:         case PRONP:
 134:             subty=PLURAL;
 135:             continue;
 136:         case NOUN:
 137:             if(nextc==NOUN){
 138:                 sent[i].cc=ADJ;
 139:                 continue;
 140:             }
 141:         case PRONS:
 142:             subty=SING;
 143:             continue;
 144:         case PNOUN:
 145:             sent[i].cc = NOUN;
 146:             if(subty == 0)subty=PLURAL;
 147:             continue;
 148:         case CONJ:
 149:             if(nextc==UNK || nextc == NOUN_VERB || nextc == NV_PL){
 150:                 if(lastc == ADJ)sent[++i].cc = ADJ;
 151:                 else sent[++i].cc = VERB;
 152:             }
 153:             if(nextc == ED){
 154:                 sent[++i].cc = VERB;
 155:             }
 156:             continue;
 157:         case AUXP:
 158:         case AUXS:
 159:         case BES:
 160:         case BEP:
 161:         case AUXV:
 162:         case AUX:
 163:         case HAS:
 164:         case HAVE:
 165:         case HAD:
 166:             verb=getv(i,ce);
 167:             continue;
 168:         case ADV:
 169:         case AUXX:
 170:         case VERB:
 171:         case BE:
 172:         case INTER:
 173:             continue;
 174:         case THAT:
 175:             if(nextc==SUBCONJ){
 176:                 sent[i].cc=PRONP;
 177:                 goto subc;
 178:             }
 179:             verb=getv(i+1,ce);
 180:             j = i+1;
 181:             while(isadv(sent[j].cc)) {
 182:                 j++;
 183:             }
 184:             nextc = sent[j].cc;
 185:             if((verb==1 && iverb== j) || nextc==ED || nextc == VERB_ADJ){
 186:                 sent[i].cc=PRONP;
 187:                 while(i+1 < j)sent[++i].cc = ADV;
 188:             }
 189:             else if(verb==0 && nextc==NV_PL && ((lastc==NOUN
 190:                 && issing(sent[i-1].ic)) || lastc == ',')) {
 191:                 sent[i].cc=PRONP;
 192:                 subty=SING;
 193:                 while(i+1 < j)sent[++i].cc = ADV;
 194:             }
 195:             else if(verb==0 && (nextc==UNK || nextc==NOUN_VERB) && (lastc==NOUN
 196:                 && sent[i-1].ic==NV_PL)){
 197:                 subty=PLURAL;
 198:                 sent[i].cc=PRONP;
 199:                 while(i+1 < j)sent[++i].cc = ADV;
 200:             }
 201:             else {
 202:                 if(i == 0)sent[i].cc=ADJ;
 203:                 else sent[i].cc=SUBCONJ;
 204:                 j=i;
 205:                 subty=0;
 206:                 i=getnoun(i+1,ce);
 207:                 if(done)sent[j].cc=ADJ;
 208:             }
 209:             continue;
 210:         case ',':
 211:             if(nextc != CONJ){  /*parenthetical*/
 212:                 continue;
 213:             }
 214:             i++;
 215:             comma--;
 216:             if(sent[i+1].cc == ED || sent[i+1].cc == MVERB){
 217:                 sent[++i].cc = VERB;
 218:                 continue;
 219:             }
 220:             if(command == 1){
 221:                 verb = getv(++i,ce);
 222:                 continue;
 223:             }
 224:         case SUBCONJ:
 225: subc:
 226:             savi = i;
 227:             if(nextc==END||(lastc==',' && nextc==',')){
 228:                 sent[i].cc=ADV;
 229:                 continue;
 230:             }
 231:             subty=0;
 232:             ce=',';
 233:             verb=getv(++i,ce);
 234:             if(sent[savi+1].cc == VERB || sent[savi+1].cc == AUXX)
 235:                 if(sent[savi].cc == SUBCONJ)sent[savi].cc = ADV;
 236:             i=getnoun(i,ce);
 237:             continue;
 238:         case PREP_ADV:
 239:             if(sent[i+2].cc==PREP_ADV &&(sent[i+1].cc != NOUN && sent[i+1].cc != NOUN_VERB
 240:                 && sent[i+1].cc != NV_PL && sent[i+1].cc != PNOUN)){
 241:                 sent[i].cc=ADV;
 242:                 sent[i+2].cc=CONJ;
 243:                 continue;
 244:             }
 245:             sav=i++;
 246:             savsub = subty;
 247:             pverb=getv(i,ce);
 248:             if((pverb==1 && iverb == i) || sent[i].cc== ED){
 249:                 sent[sav].cc=PRONP;
 250:                 sent[i].cc=VERB;
 251:                 continue;
 252:             }
 253:             i=getnoun(i,ce);
 254:             if(done==1){
 255:                 sent[sav].cc=ADV;
 256:                 goto sdone;
 257:             }
 258:             if(pverb==1 && iverb == i+1){
 259:                 sent[sav].cc=SUBCONJ;
 260:                 ce=',';
 261:                 continue;
 262:             }
 263:             switch(sent[i+1].cc){
 264:             case UNK:
 265:             case NV_PL:
 266:             case NOUN_VERB:
 267:             case ED:
 268:                 sent[sav].cc=SUBCONJ;
 269:                 verb=0;
 270:                 ce=',';
 271:                 continue;
 272:             default:
 273:                 sent[sav].cc=PREP;
 274:                 subty = savsub;
 275:                 continue;
 276:             }
 277:         case TO:
 278:             savi = i;
 279:             sent[i++].cc=VERB;
 280: sw:
 281:             switch(nextc){
 282:             case UNK:
 283:             case AUXS:
 284:             case VERB_ADJ:
 285:             case NOUN_VERB:
 286:             case VERB:
 287:             case MVERB:
 288:                 sent[i].cc=VERB;
 289:                 continue;
 290:             case HAVE:
 291:                 sent[i].cc = VERB;
 292:                 if(sent[i+1].cc == ED){
 293:                     sent[++i].cc = VERB;
 294:                     continue;
 295:                 }
 296:                 if(sent[i+1].cc == ADV)i++;
 297:                 if(sent[i+1].cc != BE)continue;
 298:                 i++;
 299:             case BE:
 300:                 sent[i].cc=VERB;
 301:                 if(sent[i+1].cc == ADV)i++;
 302:                 if(sent[i+1].cc == ED || sent[i+1].cc == ING){
 303:                     sent[++i].cc = VERB;
 304:                 }
 305:                 else if(sent[i+1].cc == UNK){
 306:                     sent[++i].cc = ADJ;
 307:                 }
 308:                 continue;
 309:             case ADV:
 310:                 nextc = sent[++i].cc;
 311:                 goto sw;
 312:             default:
 313:                 sent[savi].cc = PREP;
 314:                 prep=1;
 315:                 i=getnoun(i,ce);
 316:                 prep=0;
 317:                 continue;
 318:             }
 319:         case NV_PL:
 320:             if(subty==0){
 321:                 i=getnoun(i,ce);
 322:                 subty=PLURAL;
 323:             }
 324:             else if(verb== 0){  /*need verb*/
 325:                 sent[i].cc=VERB;
 326:                 verb=1;
 327:             }
 328:             else{
 329:                 i=getnoun(i,ce);
 330:             }
 331:             continue;
 332:         case UNK:
 333:         case NOUN_VERB:
 334:             if(verb==1){
 335:                 if(be==1 && nextc != WHO){
 336:                     sent[i].cc=ADJ;
 337:                     continue;
 338:                 }
 339:                 i=getnoun(i,ce);
 340:             }
 341:             else if(nextc==NV_PL && isnoun(sent[i+2].cc)) {
 342:                 sent[i].cc=NOUN;
 343:                 if(sent[i-1].cc == NOUN){
 344:                     sent[i-1].cc = ADJ;
 345:                 }
 346:                 subty=SING;
 347:                 continue;
 348:             }
 349:             else if(subty==0){
 350:                 i=getnoun(i,ce);
 351:                 continue;
 352:             }
 353:             else {      /* desparation */
 354:                 sent[i].cc=VERB;
 355:                 verb=1;
 356:             }
 357:             continue;
 358:         case ED:
 359:             if(verb == 0){
 360:                 sent[i].cc=VERB;
 361:                 verb=1;
 362:             }
 363:             else if(sent[i-1].cc == BE){
 364:                 sent[i].cc = VERB;
 365:             }
 366:             else{
 367:                 i=getnoun(i,ce);
 368:             }
 369:             continue;
 370:         default:    printf("got a %c %o on %sat %d\n",sent[i].cc,sent[i].cc,sent[i].sp,i);
 371:         }
 372:     }
 373: sdone:
 374:     if(sent[i].cc==END && sent[i].ic != ';')return(-1);
 375:     else {
 376:         if(sent[i].ic == ';')sent[i].cc=';';
 377:         else comma--;
 378:         return(i);
 379:     }
 380: }
 381: getv(si,ce)
 382: int si;
 383: char ce;
 384: {
 385:     int conj;
 386:     char c;
 387:     int ik;
 388:     must=0;
 389:     bflg=0;
 390:     hflg=0;
 391:     verbty=0;
 392:     for(j=si;((c=sent[j].cc) != ce) && (c != END); j++){
 393:         iverb=j;
 394:         switch(c){
 395:         case ED:
 396:             continue;
 397:         case HAS:
 398:             hflg=1;
 399:             verbty=SING;
 400:             sent[j].cc=AUXX;
 401:             goto next;
 402:         case HAVE:
 403:             if(sent[j-1].cc==TO){
 404:                 continue;
 405:             }
 406:         case HAD:
 407:             hflg=1;
 408:             verbty=PLURAL;
 409:             sent[j].cc=AUXX;
 410:             goto next;
 411:         case BE:
 412:             if(sent[j].ic != BE){
 413:                 return(1);
 414:             }
 415:             continue;
 416:         case VERB:
 417:             if(sent[j-1].cc==TO){
 418:                 continue;
 419:             }
 420:             return(1);
 421:         case AUXX:
 422:             return(1);
 423:         case AUXP:
 424:             must=1;
 425:             verbty=PLURAL;
 426:             sent[j].cc=AUXX;
 427:             goto next;
 428:         case AUXS:
 429:             if(sent[j-1].cc==TO){
 430:                 continue;
 431:             }
 432:             verbty=SING;
 433:             sent[j].cc=AUXX;
 434:             goto next;
 435:         case AUX:
 436:         case AUXV:
 437:             must=1;
 438:             sent[j].cc=AUXX;
 439: next:
 440:             if(sent[j-1].cc == CONJ && verb == 0)conj = 0;
 441:             else conj = 1;
 442:             if(question==1){
 443:                 j=getnoun(j+1,ce);
 444:                 question=0;
 445:             }
 446:             getv2(ce);
 447:             if(sent[j].cc == AUXX){
 448:                 sent[j].cc = VERB;
 449:             }
 450:             if((sent[j].cc!=VERB && sent[j].cc!=BE) && sent[iverb].cc==AUXX){
 451:                 sent[iverb].cc=VERB;
 452:                 for(ik=iverb+1;ik<=j;ik++){
 453:                     if(sent[ik].ic == NOM)sent[ik].cc=NOUN;
 454:                     else sent[ik].cc=sent[ik].ic;
 455:                 }
 456:             }
 457:             return(conj);
 458:         case BES:
 459:             verbty=SING;
 460:             bflg=1;
 461:             sent[j].cc=BE;
 462:             goto next;
 463:         case BEP:
 464:             verbty=PLURAL;
 465:             bflg=1;
 466:             sent[j].cc=BE;
 467:             goto next;
 468:         case SUBCONJ:
 469:             if(sent[j-1].cc== ',' && sent[j+1].cc == ','){
 470:                 continue;
 471:             }
 472:         case THAT:
 473:         case WHO:
 474:             goto vdone;
 475:         case ',':   if(comma==1 && sent[j+1].cc==CONJ){
 476:                     goto vdone;
 477:                 }
 478:         }
 479:     }
 480: vdone:
 481:     return(0);
 482: }
 483: getv2(ce)
 484: char ce;
 485: {
 486:     int vflg;
 487:     char c;
 488:     vflg=0;
 489:     while(((c=sent[++j].cc) != ce) && (c != END)){
 490:         switch(c){
 491:         case NOUN_ADV:
 492:         case ADJ_ADV:
 493:             if(bflg == 0 || sent[j+1].cc == ED || sent[j+1].cc == ING){
 494:                 sent[j].cc = ADV;
 495:             }
 496:             else{
 497:                 j -= 1;
 498:                 return;
 499:             }
 500:         case ADV:
 501:             continue;
 502:         case SUBCONJ:
 503:             if(sent[j+1].cc == ED || sent[j+1].cc == ING || sent[j+1].cc == ADV ||
 504:                 sent[j+1].cc == ADJ_ADV)sent[j].cc = ADV;
 505:             else return;
 506:             continue;
 507:         case VERB:
 508:             return;
 509:         case VERB_ADJ:
 510:         case ED:
 511:             sent[j].cc=VERB;
 512:             return;
 513:         case BE:
 514:             must=0;
 515:             bflg=1;
 516:             continue;
 517:         case ING:
 518:             if(bflg == 1){
 519:                 sent[j].cc = VERB;
 520:             }
 521:             else {
 522:                 j -= 1;
 523:             }
 524:             return;
 525:         case NOUN_VERB:
 526:         case UNK:
 527:             if(bflg==1 || vflg==1 || hflg==1){
 528:                 j -= 1;
 529:                 return;
 530:             }
 531:             sent[j].cc=VERB;
 532:             return;
 533:         case PRONP_ADJ:
 534:         case PRONS_ADJ:
 535:             c=sent[j+1].cc;
 536:             if(c==ED||c==ING||c==BE||must==1){
 537:                 sent[j].cc = ADV;
 538:             }
 539:             else{
 540:                 j -= 1;
 541:                 return;
 542:             }
 543:             continue;
 544:         case AUXV:
 545:         case AUX:
 546:         case AUXP:
 547:         case AUXS:
 548:         case HAD:
 549:         case HAVE:
 550:         case HAS:
 551:             must=0;
 552:             vflg=1;
 553:             sent[j].cc=AUXX;
 554:             continue;
 555:         default:
 556:             j -= 1;
 557:             return;
 558:         }
 559:     }
 560:     j -= 1;
 561: }
 562: getnoun(k,ce)
 563: int k,ce;
 564: {
 565:     char c;
 566:     int st,t,nextst;
 567:     int rep;
 568:     int t1,tt;
 569:     st=k;
 570:     rep=0;
 571: b:
 572:     nextst=sent[st+1].cc;
 573:     switch(sent[st].cc){
 574:     case END:
 575:         done=1;
 576:         break;
 577:     case ',':
 578:         if(ce==','){
 579:             done=1;
 580:             break;
 581:         }
 582:         else {
 583:             goto getdef;
 584:         }
 585:     case '"':
 586:         if(aflg == 1){
 587:             st++;
 588:             goto b;
 589:         }
 590:         break;
 591:     case NOUN:
 592:         switch(nextst){
 593:         case UNK:
 594:         case NOUN_VERB:
 595:             if(verb==1){
 596:                 goto nn;
 597:             }
 598:             if(subty != PLURAL){
 599:                 goto nn;
 600:             }
 601:             break;
 602:         case NV_PL:
 603:             if(verb==1){
 604:                 goto nn;
 605:             }
 606:             if(subty == PLURAL){
 607:                 goto nn;
 608:             }
 609:             break;
 610:         case PNOUN:
 611:         case NOUN_ADJ:
 612:         case POS:
 613:         case NOUN:
 614: nn:
 615:             sent[st].cc=ADJ;
 616:             goto b;
 617:         }
 618:         if(prep==0)subty=SING;
 619:         break;
 620:     case PNOUN:
 621:         sent[st].cc = NOUN;
 622:         if(prep == 0)subty=PLURAL;
 623:         break;
 624:     case ADV:
 625:         st++;
 626:         goto b;
 627:     case WHO:
 628:         st=who(st,ce);
 629:         st++;
 630:         goto b;
 631:     case ADJ_ADV:
 632:     case VERB_ADJ:
 633:     case ED:
 634:         sent[st++].cc=ADJ;
 635:         goto b;
 636:     case ING:
 637:         if(isnoun(nextst)){
 638:             sent[st++].cc=ADJ;
 639:             goto b;
 640:         }
 641:         sent[st].cc=NOUN;
 642:         if(prep==0)subty=SING;
 643:         break;
 644:     case ART:
 645:     case POS:
 646:         if(st != k){
 647:             goto getdef;
 648:         }
 649:     case ADJ:
 650:         st++;
 651:         goto b;
 652:     case PRONP:
 653:         if(prep==0)subty=PLURAL;
 654: 
 655:         break;
 656:     case PRONS:
 657:         if(prep==0)subty=SING;
 658:         break;
 659:     case NOUN_VERB:
 660:         if((nextst==NOUN|| nextst==PNOUN)||(verb==1 && (nextst== NV_PL|| nextst==NOUN_VERB) )){
 661:             sent[st].cc=ADJ;
 662:             goto b;
 663:         }
 664:     case NV_PL:
 665:         sent[st].cc=NOUN;
 666:         if(prep==0){
 667:             if(sent[st].ic==NV_PL)subty=PLURAL;
 668:             else subty=SING;
 669:         }
 670:         if(sent[st-1].cc == NOUN && nounnom(sent[st-1].ic)) {
 671:             sent[st-1].cc = ADJ;
 672:         }
 673:         break;
 674:     case PRONP_ADJ:
 675:         switch(nextst){
 676:         case PNOUN:
 677:         case NOUN_ADJ:
 678:         case NV_PL:
 679:         case ADJ_ADV:
 680:         case PRONS_ADJ:
 681:         case ADJ:
 682:         case ING:
 683:             sent[st++].cc=ADJ;
 684:             goto b;
 685:         case NOUN_VERB:
 686:         case UNK:
 687:         case ED:
 688:             if(verb == 0){
 689:                 goto def;
 690:             }
 691:             else{
 692:                 sent[st++].cc=ADJ;
 693:                 goto b;
 694:             }
 695:         case NOUN:
 696:             sent[st++].cc=ADJ;
 697:             if(prep==0)subty=SING;
 698:             break;
 699:         case SUBCONJ:   sent[st++].cc=PRONP;    /* more than .. */
 700:             sent[st++].cc=CONJ;
 701:             if(verb==0)verb=getv(st,ce);
 702:             goto b;
 703:         case '"':
 704:             sent[st++].cc = ADJ;
 705:             st++;
 706:             goto b;
 707:         default:
 708: def:
 709:             sent[st].cc=PRONP;
 710:             if(prep==0)subty=PLURAL;
 711: 
 712:             break;
 713:         }
 714:         break;
 715:     case PRONS_ADJ:
 716:         if(aflg == 1 && nextst != END && nextst != ART){
 717:             sent[st++].cc=ADJ;
 718:             goto b;
 719:         }
 720:         switch(nextst){
 721:         case '"':
 722:             sent[st++].cc = ADJ;
 723:             st++;
 724:             goto b;
 725:         case PNOUN:
 726:         case ING:
 727:         case UNK:
 728:         case NOUN_VERB:
 729:         case NOUN_ADJ:
 730:         case ADJ_ADV:
 731:         case ADJ:
 732:             sent[st++].cc=ADJ;
 733:             goto b;
 734:         case NOUN:
 735:             sent[st++].cc=ADJ;
 736:             if(prep==0)subty=SING;
 737:             break;
 738:         case PRONS_ADJ:
 739:             sent[st++].cc=ADJ;
 740:             sent[st].cc=PRONP;
 741:             if(prep==0)subty=SING;
 742:             break;
 743:         case NV_PL:
 744:             if(verb==1){
 745:                 sent[st++].cc=ADJ;
 746:                 sent[st].cc=NOUN;
 747:                 if(prep==0)subty=PLURAL;
 748: 
 749:                 break;
 750:             }
 751:             sent[st].cc=PRONP;
 752:             if(prep==0)subty=SING;
 753:             break;
 754:         default:
 755:             sent[st].cc=PRONP;
 756:             if(prep==0)subty=SING;
 757: 
 758:             break;
 759:         }
 760:         break;
 761:     case NOUN_ADJ:
 762:         if(nextst==NOUN||nextst==ADJ||nextst == NOUN_ADJ||nextst==PRONS_ADJ||nextst==PRONP_ADJ||nextst==PNOUN){
 763:             sent[st++].cc=ADJ;
 764:             goto b;
 765:         }
 766:         if(nextst!=UNK && nextst != NOUN_VERB && nextst != NV_PL){
 767:             sent[st].cc=NOUN;
 768:             if(prep==0)subty=SING;
 769:             break;
 770:         }
 771:         if(verb==1 || sent[st+2].cc==ED){
 772:             sent[st++].cc=ADJ;
 773:             goto b;
 774:         }
 775:         sent[st].cc=NOUN;
 776:         if(prep==0)subty=SING;
 777:         break;
 778:     case UNK:
 779:         if(nextst != UNK){
 780:             if(nextst == ',' && rep==0){
 781:                 c=sent[st+2].cc;
 782:                 if((c==UNK||c==ADJ||c==NOUN_ADJ||c==ING) && isnoun(sent[st+3].cc)){
 783:                     comma--;
 784:                     sent[st].cc=ADJ;
 785:                     sent[st+2].cc=ADJ;
 786:                     sent[st+3].cc=NOUN;
 787:                     if(prep==0){
 788:                         if(sent[st+3].ic==NV_PL)subty=PLURAL;
 789:                         else subty=SING;
 790:                     }
 791:                     return(st+3);
 792:                 }
 793:                 else {
 794:                     sent[st].cc=NOUN;
 795:                     if(prep==0)subty=SING;
 796:                     break;
 797:                 }
 798:             }
 799:             if(nextst==NOUN||nextst==ING ||nextst==NOUN_ADJ|| sent[st-1].cc==ADV
 800:                 || nextst==ADJ || nextst==PNOUN){
 801:                 sent[st++].cc=ADJ;
 802:                 goto b;
 803:             }
 804:             if((nextst==NV_PL || nextst==NOUN_VERB) &&(verb==1 ||(verb==0 && (sent[st+2].cc==UNK
 805:                 || sent[st+2].cc==NOUN_VERB || sent[st+2].cc==ED||sent[st+2].cc==VERB_ADJ)))){
 806:                     sent[st++].cc=ADJ;
 807:                     sent[st].cc=NOUN;
 808:                     if(prep == 0)subty=PLURAL;
 809:                     break;
 810:                 }
 811:             if(nextst == CONJ && isadv(sent[st+2].cc)){
 812:                 sent[st].cc=ADJ;
 813:                 goto b;
 814:             }
 815:             sent[st].cc=NOUN;
 816:             if(prep==0)subty=SING;
 817: 
 818:             break;
 819:         }
 820:         for(t=st+1;sent[t].cc== UNK;t++);
 821:         if(verb==0 && prep == 0){       /* UUU. */
 822:             if(prep==0)subty=SING;
 823:             if(sent[t].cc==NV_PL|| sent[t].cc == PNOUN){    /* UUZ.*/
 824:                 if(sent[t+1].cc==UNK || sent[t+1].cc==NOUN_VERB){   /* UUZU */
 825:                     sent[t+1].cc=VERB;
 826:                     verb=1;
 827:                     sent[t].cc=NOUN;
 828:                     t1=t;
 829:                 }
 830:                 else if(sent[t].cc == NV_PL){       /* UUZ. */
 831:                     sent[t].cc=VERB;
 832:                     verb=1;
 833:                     sent[t-1].cc=NOUN;
 834:                     t1=t-1;
 835:                 }
 836:                 else {
 837:                     sent[t].cc = NOUN;
 838:                     t1 = t;
 839:                 }
 840:             }
 841:             else{       /* UU. */
 842:                 if(sent[t].cc!= ED){
 843:                     sent[t-1].cc=VERB;
 844:                     verb=1;
 845:                     sent[t-2].cc=NOUN;
 846:                     t1=t-2;
 847:                     t--;
 848:                 }
 849:                 else {
 850:                     sent[--t].cc=NOUN;
 851:                     t1=t;
 852:                 }
 853:             }
 854:         }
 855:         else{
 856:             if(sent[t].cc==NOUN_VERB|| sent[t].cc==NOUN|| sent[t].cc==NV_PL|| sent[t].cc==PNOUN){
 857:                 sent[t].cc=NOUN;
 858:                 if(prep==0)subty=PLURAL;
 859:                 t1=t;
 860:             }
 861:             else{
 862:                 sent[--t].cc=NOUN;
 863:                 if(prep==0)subty=SING;
 864:                 t1=t;
 865:             }
 866:         }
 867:         for(tt=st;tt<t1;tt++)sent[tt].cc=ADJ;
 868:         st=t;
 869:         break;
 870:     }
 871: getdef:
 872:     if(sent[st].cc == CONJ && sent[st-1].cc == ADJ){
 873:         st++;
 874:         goto b;
 875:     }
 876:     if(sent[st-1].cc==PREP && ( sent[st].cc == THAT || sent[st].cc == SUBCONJ)){
 877:         prep=0;
 878:         return(--st);
 879:     }
 880:     if(sent[st].cc != NOUN && sent[st].cc != PRONP && sent[st].cc != PRONS){
 881:         st--;
 882:         if(sent[st].cc==ADJ && sent[st].ic==ING){
 883:             sent[st].cc=NOUN;
 884:             if(prep==0)subty=SING;
 885:         }
 886:         else if(sent[st].cc == PREP){
 887:             sent[st].cc = ADV;
 888:         }
 889:         prep=0;
 890:         return(st);
 891:     }
 892:     if(done==1){
 893:         prep=0;
 894:         return(st);
 895:     }
 896:     if(sent[st+1].cc== ','){
 897:         if(sent[st+2].cc==CONJ){
 898:             if(rep==0){
 899:                 prep=0;
 900:                 return(st);
 901:             }
 902:             else{
 903:                 st+=3;
 904:                 comma--;
 905:                 if(prep==0)subty=PLURAL;
 906:                 prep=1;
 907:                 goto b;
 908:             }
 909:         }
 910:         if(comma==1){
 911:             prep=0;
 912:             return(st);
 913:         }
 914: 
 915:         switch(sent[st+2].cc){
 916:         case PREP:
 917:         case SUBCONJ:
 918:         case PRONS:
 919:         case PRONP:
 920:             prep=0;
 921:             return(st);
 922:         default:    rep++;
 923:             comma--;
 924:             st+=2;
 925:             if(prep==0)subty=PLURAL;
 926:             prep=1;
 927:             goto b;
 928:         }
 929:     }
 930:     if(sent[st+1].cc==CONJ && sent[st+2].cc != ED){
 931:         st+=2;
 932:         if(prep==0)subty=PLURAL;
 933:         prep=1;
 934:         goto b;
 935:     }
 936:     prep=0;
 937:     return(st);
 938: }
 939: who(kk,ce)
 940: int kk,ce;
 941: {
 942:     char c;
 943:     sent[kk].cc=PRONP;
 944:     c=sent[kk+1].cc;
 945:     while(isadv(c)){
 946:         sent[++kk].cc = ADV;
 947:         c = sent[kk+1].cc;
 948:     }
 949:     if(c==UNK||c==NOUN_VERB||c==VERB_ADJ||c==ED|| c==NV_PL||c==MVERB){
 950:         sent[++kk].cc=VERB;
 951:         if(verb == 0)verb = getv(kk+1,ce);
 952:         return(kk);
 953:     }
 954: w:  switch(sent[++kk].cc){
 955:     case AUXX:
 956:     case ADV:
 957:     case BE:
 958:     case VERB:
 959:         goto w;
 960:     default:
 961:         verb=getv(kk,ce);
 962:         return(--kk);
 963:     }
 964: }

Defined functions

getnoun defined in line 562; used 16 times
getv defined in line 381; used 11 times
getv2 defined in line 483; used 1 times
scan defined in line 15; never used
who defined in line 939; used 2 times

Defined variables

lastc defined in line 13; used 10 times
nextc defined in line 13; used 28 times
savsub defined in line 14; used 2 times
sccsid defined in line 2; never used

Defined macros

isadj defined in line 8; used 1 times
isadv defined in line 7; used 4 times
isnoun defined in line 11; used 3 times
issing defined in line 10; used 1 times
notnoun defined in line 9; used 1 times
nounnom defined in line 12; used 1 times
Last modified: 1983-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 792
Valid CSS Valid XHTML 1.0 Strict