QString BufferedSocketDevice::ReadLine( int msecs ) { MythTimer timer; QString sLine; if ( CanReadLine() ) return( ReadLine() ); // ---------------------------------------------------------------------- // If the user supplied a timeout, lets loop until we can read a line // or timeout. // ---------------------------------------------------------------------- if ( msecs > 0) { bool bTimeout = false; timer.start(); while ( !CanReadLine() && !bTimeout ) { #if 0 LOG(VB_HTTP, LOG_DEBUG, "Can't Read Line... Waiting for more." ); #endif WaitForMore( msecs, &bTimeout ); if ( timer.elapsed() >= msecs ) { bTimeout = true; LOG(VB_HTTP, LOG_INFO, "Exceeded Total Elapsed Wait Time." ); } } if (CanReadLine()) sLine = ReadLine(); } return( sLine ); }
void Indice::ReadColection(string file_name) { vector<string> termos, termos_clean; string line, buffer; ifstream arq(file_name.c_str()); if (!arq.is_open()) { cout << "erro ao abrir arquivo " << file_name << endl; //return NULL; } //Faz a leitura de cada linha do arquivo while (getline(arq, line)) { //cout << "abriuuuuu o/" << endl; if ((line.empty()) && (termos.size() > 0)) { termos_clean = CleanDocument(termos); indexaDocumento(termos_clean); termos.clear(); termos_clean.clear(); } //checa se a linha deve ser lida if (CanReadLine(line) || flag_linha) { buffer = GetLineContent(line); //cout << buffer << endl; istringstream iss(buffer); copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter<vector<string> >(termos)); } } map<string, Vocabulo>::iterator it_hash; map<int, CelulaLista>::iterator it_cel; //computa o idf de cada lista invertida e o peso de cada termo na lista invertida for (it_hash = indice_invertido.begin(); it_hash != indice_invertido.end(); ++it_hash){ (*it_hash).second.idf = log2(NUM_TOTAL_COLECAO/(*it_hash).second.total_docs); for (it_cel = it_hash->second.lista_invertida.begin(); it_cel != it_hash->second.lista_invertida.end(); ++it_cel){ (*it_cel).second.peso = (*it_hash).second.idf * (*it_cel).second.tf; } } }