bool loadColProbs(const std::string &file_name, NameDict &term_dict, ValueMap &col_probs, double &default_col_prob){ col_probs.clear(); ifstream fin(file_name.c_str()); if (! fin){ ucair::getLogger().error("Failed to open " + file_name); return false; } try{ string line; if (! getline(fin, line)){ return false; } size_t pos = line.find('\t'); if (pos == string::npos){ return false; } trim_right(line); int unique_term_count = lexical_cast<int>(line.substr(0, pos)); long long total_term_count = lexical_cast<long long>(line.substr(pos + 1)); default_col_prob = 1.0 / (total_term_count + unique_term_count); while (getline(fin, line)){ size_t pos = line.find('\t'); if (pos == string::npos){ return false; } trim_right(line); string term = line.substr(0, pos); long long term_count = lexical_cast<long long>(line.substr(pos + 1)); int term_id = term_dict.getId(term, true); double col_prob = (term_count + 1.0) / (total_term_count + unique_term_count); col_probs.set(term_id, col_prob, false); } } catch (bad_lexical_cast &){ return false; } return true; }