一、标记 标记(tokenizing)是从文本中提取具体内容的过程。 下面的代码从句子中提取单词,并把它们输出到控制台。 class mytokenizing { static void Main(string[ ] args) { string mystring="I like this food,are you?"; char[] separators={' ',',','?',':','!'}; int startpos=0; int endpos=0; do { endpos=mystring.IndexOfAny(separators,startpos); if ( endpos==-1 ) endpos=mystring.Length; if ( endpos!=startpos ) Console.WriteLine(mystring.Substring( startpos,(endpos-startpos))); startpos=(endpos+1); }while(startpos
关注
打赏
立即登录/注册


微信扫码登录