static char sccsid
[] = "@(#)pscan.c 4.2 (Berkeley) 82/11/06";
#define isadv(c) (c == ADV || c == ADJ_ADV)
#define isadj(c) (c == ADJ || c == NOUN_ADJ || c == ADJ_ADV || c == UNK)
#define notnoun(c) (c != NOUN && c != UNK && c != NOUN_VERB && c != NV_PL && c != PNOUN)
#define issing(c) (c == UNK || c == NOUN_VERB || c == NOUN || c == NOM || c == NOUN_ADJ)
#define isnoun(c) (c == NOUN || c == NOUN_VERB || c == NV_PL || c == UNK || c == PNOUN)
#define nounnom(c) (c == NOUN || c == NOM)
scan(si
,ce
,command
) /*scan a phrase */
if(command
== 1)subty
= PLURAL
;
if(sent
[i
].cc
==ADJ_ADV
&& sent
[i
+1].cc
!= NOUN
&& sent
[i
+1].cc
!= UNK
&& sent
[i
+1].cc
!= ADJ
)
verb
=getv(i
,ce
); /*get verb if obvious*/
if(command
== 0)j
=getnoun(i
,ce
); /*get subject*/
if(i
!= j
|| ((i
==j
) && sent
[i
].cc
== NOUN
)){
for(;((c
=sent
[i
].cc
) != ce
) && (c
!= END
) && (c
!= '\0');i
++){
if(nextc
==ED
|| nextc
== MVERB
){
if(verb
== 1 && iverb
== i
+1){
if(nextc
== ',' && isadv(sent
[i
+2].cc
)) {
if(lastc
== NOUN
&& (nextc
== ',' || nextc
== END
)){
if(subty
== 0)subty
=PLURAL
;
if(nextc
==UNK
|| nextc
== NOUN_VERB
|| nextc
== NV_PL
){
if(lastc
== ADJ
)sent
[++i
].cc
= ADJ
;
else sent
[++i
].cc
= VERB
;
while(isadv(sent
[j
].cc
)) {
if((verb
==1 && iverb
== j
) || nextc
==ED
|| nextc
== VERB_ADJ
){
while(i
+1 < j
)sent
[++i
].cc
= ADV
;
else if(verb
==0 && nextc
==NV_PL
&& ((lastc
==NOUN
&& issing(sent
[i
-1].ic
)) || lastc
== ',')) {
while(i
+1 < j
)sent
[++i
].cc
= ADV
;
else if(verb
==0 && (nextc
==UNK
|| nextc
==NOUN_VERB
) && (lastc
==NOUN
&& sent
[i
-1].ic
==NV_PL
)){
while(i
+1 < j
)sent
[++i
].cc
= ADV
;
if(i
== 0)sent
[i
].cc
=ADJ
;
if(nextc
!= CONJ
){ /*parenthetical*/
if(sent
[i
+1].cc
== ED
|| sent
[i
+1].cc
== MVERB
){
if(nextc
==END
||(lastc
==',' && nextc
==',')){
if(sent
[savi
+1].cc
== VERB
|| sent
[savi
+1].cc
== AUXX
)
if(sent
[savi
].cc
== SUBCONJ
)sent
[savi
].cc
= ADV
;
if(sent
[i
+2].cc
==PREP_ADV
&&(sent
[i
+1].cc
!= NOUN
&& sent
[i
+1].cc
!= NOUN_VERB
&& sent
[i
+1].cc
!= NV_PL
&& sent
[i
+1].cc
!= PNOUN
)){
if((pverb
==1 && iverb
== i
) || sent
[i
].cc
== ED
){
if(pverb
==1 && iverb
== i
+1){
if(sent
[i
+1].cc
== ADV
)i
++;
if(sent
[i
+1].cc
!= BE
)continue;
if(sent
[i
+1].cc
== ADV
)i
++;
if(sent
[i
+1].cc
== ED
|| sent
[i
+1].cc
== ING
){
else if(sent
[i
+1].cc
== UNK
){
else if(verb
== 0){ /*need verb*/
if(be
==1 && nextc
!= WHO
){
else if(nextc
==NV_PL
&& isnoun(sent
[i
+2].cc
)) {
if(sent
[i
-1].cc
== NOUN
){
else if(sent
[i
-1].cc
== BE
){
default: printf("got a %c %o on %sat %d\n",sent
[i
].cc
,sent
[i
].cc
,sent
[i
].sp
,i
);
if(sent
[i
].cc
==END
&& sent
[i
].ic
!= ';')return(-1);
if(sent
[i
].ic
== ';')sent
[i
].cc
=';';
for(j
=si
;((c
=sent
[j
].cc
) != ce
) && (c
!= END
); j
++){
if(sent
[j
-1].cc
== CONJ
&& verb
== 0)conj
= 0;
if((sent
[j
].cc
!=VERB
&& sent
[j
].cc
!=BE
) && sent
[iverb
].cc
==AUXX
){
for(ik
=iverb
+1;ik
<=j
;ik
++){
if(sent
[ik
].ic
== NOM
)sent
[ik
].cc
=NOUN
;
else sent
[ik
].cc
=sent
[ik
].ic
;
if(sent
[j
-1].cc
== ',' && sent
[j
+1].cc
== ','){
case ',': if(comma
==1 && sent
[j
+1].cc
==CONJ
){
while(((c
=sent
[++j
].cc
) != ce
) && (c
!= END
)){
if(bflg
== 0 || sent
[j
+1].cc
== ED
|| sent
[j
+1].cc
== ING
){
if(sent
[j
+1].cc
== ED
|| sent
[j
+1].cc
== ING
|| sent
[j
+1].cc
== ADV
||
sent
[j
+1].cc
== ADJ_ADV
)sent
[j
].cc
= ADV
;
if(bflg
==1 || vflg
==1 || hflg
==1){
if(c
==ED
||c
==ING
||c
==BE
||must
==1){
if(prep
== 0)subty
=PLURAL
;
if((nextst
==NOUN
|| nextst
==PNOUN
)||(verb
==1 && (nextst
== NV_PL
|| nextst
==NOUN_VERB
) )){
if(sent
[st
].ic
==NV_PL
)subty
=PLURAL
;
if(sent
[st
-1].cc
== NOUN
&& nounnom(sent
[st
-1].ic
)) {
case SUBCONJ
: sent
[st
++].cc
=PRONP
; /* more than .. */
if(verb
==0)verb
=getv(st
,ce
);
if(aflg
== 1 && nextst
!= END
&& nextst
!= ART
){
if(nextst
==NOUN
||nextst
==ADJ
||nextst
== NOUN_ADJ
||nextst
==PRONS_ADJ
||nextst
==PRONP_ADJ
||nextst
==PNOUN
){
if(nextst
!=UNK
&& nextst
!= NOUN_VERB
&& nextst
!= NV_PL
){
if(verb
==1 || sent
[st
+2].cc
==ED
){
if(nextst
== ',' && rep
==0){
if((c
==UNK
||c
==ADJ
||c
==NOUN_ADJ
||c
==ING
) && isnoun(sent
[st
+3].cc
)){
if(sent
[st
+3].ic
==NV_PL
)subty
=PLURAL
;
if(nextst
==NOUN
||nextst
==ING
||nextst
==NOUN_ADJ
|| sent
[st
-1].cc
==ADV
|| nextst
==ADJ
|| nextst
==PNOUN
){
if((nextst
==NV_PL
|| nextst
==NOUN_VERB
) &&(verb
==1 ||(verb
==0 && (sent
[st
+2].cc
==UNK
|| sent
[st
+2].cc
==NOUN_VERB
|| sent
[st
+2].cc
==ED
||sent
[st
+2].cc
==VERB_ADJ
)))){
if(prep
== 0)subty
=PLURAL
;
if(nextst
== CONJ
&& isadv(sent
[st
+2].cc
)){
for(t
=st
+1;sent
[t
].cc
== UNK
;t
++);
if(verb
==0 && prep
== 0){ /* UUU. */
if(sent
[t
].cc
==NV_PL
|| sent
[t
].cc
== PNOUN
){ /* UUZ.*/
if(sent
[t
+1].cc
==UNK
|| sent
[t
+1].cc
==NOUN_VERB
){ /* UUZU */
else if(sent
[t
].cc
== NV_PL
){ /* UUZ. */
if(sent
[t
].cc
==NOUN_VERB
|| sent
[t
].cc
==NOUN
|| sent
[t
].cc
==NV_PL
|| sent
[t
].cc
==PNOUN
){
for(tt
=st
;tt
<t1
;tt
++)sent
[tt
].cc
=ADJ
;
if(sent
[st
].cc
== CONJ
&& sent
[st
-1].cc
== ADJ
){
if(sent
[st
-1].cc
==PREP
&& ( sent
[st
].cc
== THAT
|| sent
[st
].cc
== SUBCONJ
)){
if(sent
[st
].cc
!= NOUN
&& sent
[st
].cc
!= PRONP
&& sent
[st
].cc
!= PRONS
){
if(sent
[st
].cc
==ADJ
&& sent
[st
].ic
==ING
){
else if(sent
[st
].cc
== PREP
){
if(sent
[st
+1].cc
==CONJ
&& sent
[st
+2].cc
!= ED
){
if(c
==UNK
||c
==NOUN_VERB
||c
==VERB_ADJ
||c
==ED
|| c
==NV_PL
||c
==MVERB
){
if(verb
== 0)verb
= getv(kk
+1,ce
);
w
: switch(sent
[++kk
].cc
){