// defined later void display_resp(int num); void quit_display_resp(int num);
};
//------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ void read_from_file()
{
ifstream fin; int index=-1;
fin.open("eliza.dat"); char line[MAX_RESP_LEN]; while(fin)
{
fin.getline(line,MAX_RESP_LEN); char *ptr=NULL;
ptr=strstr("@KWD@",line); if(strlen(line)<1)
{ break;
} elseif(ptr!=NULL)
{ // the next line is a keyword
fin.getline(line,MAX_RESP_LEN);
keys[++index].addword(line);
} else
{ // it is a response
keys[index].addresp(line);
}
} // end of while
// * is used to write anything after the // keyword // as it is, but with some transformatio // ns like // converting MY to YOUR.< // br> if(replys[num][i]=='*')
{ char * s1=ip.userip+strlen(ip.keyword); shortint flag=0; for(int m=0;m<TRANSPOSE;m++)
{ char * s2=wordin[m]; char *ptr=NULL;
ptr=strstr(s1,s2);
if(ptr!=NULL)
{ // transposition word found in the // user input
flag=1;
// printing text before wordin[m] int times=ptr-s1; for(int i=0;i<times;i++)
{
delay(DELAY);
cout<<ip.userip[strlen(ip.keyword)+i];
}
// printing the wordout
cout<<wordout[m]; // printing the left overs char c;
c=*(ptr+strlen(wordin[m])); int t=0; while(c!='\0')
{
cout<<*(ptr+strlen(wordin[m])+t);
t++;
c=*(ptr+strlen(wordin[m])+t);
}
}
} // end of for
// if flag is still zero , this means no need for // transposing any word. if(0==flag)
{ char c;
c=*(s1+strlen(ip.keyword)); int t=0; while(c!='\0')
{
cout<<*(s1+t);
t++;
c=*(s1+t);
}
} // end of if break;
} else
{
cout<<replys[num][i];
delay(RanNum(DELAY));
}
} // end of for
// giving the prompt back to user
cout<<"\n"<<user<<" > ";
}
{ int len=0; int lenkey=0; int key_no=0; char teststr[50]; while((ip.keyfound==0) &&(key_no!=MAX_KEY))
{ // getting the length of the keyword // lenkey=strlen(keys[key_no].getword());
char *ptr=NULL;
ptr=strstr(ip.userip,keys[key_no].getword()); if (ptr!=NULL)
{ // keyword found !
ip.keyfound=1;
ip.keyno=key_no;
strcpy(ip.keyword,keys[key_no].getword()); break;
}
key_no++;
}
}
¤ Dauer der Verarbeitung: 0.30 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.