labrary常用函数备份

本文章用于自己labrary用到的程序片段备份

1、

 //函数作用,将ifstream的内容放到vector里面,其中hasOtherValue表示是否一行中,除了原词,还有词频和词性 

// 函数作用,将ifstream的内容放到vector里面,其中hasOtherValue表示是否一行中,除了原词,还有词频和词性
void  ifsreamToVector(ifstream  &  fin,vector < string >   & v, bool  hasOtherValue = true ){
    v.clear();
    
string  str; // 存放词语

    
if (hasOtherValue){
        
// 说明一行中,除了原词,还有词频和词性
         int  itmp; // 存放词频
         string  stmp; // 存放词性    
         while (fin >> str >> itmp >> stmp){
            v.push_back(str);
        }
    } 
else  {
        
while (fin >> str){
            v.push_back(str);
        }
    }

} 

你可能感兴趣的:(常用函数)