bool Vocab::Load(OnDiskWrapper &onDiskWrapper)
{
	fstream &file = onDiskWrapper.GetFileVocab();
	
	string line;
	while(getline(file, line))
	{
		vector<string> tokens;
		Moses::Tokenize(tokens, line);
		assert(tokens.size() == 2);
		const string &key = tokens[0];
		m_vocabColl[key] =  Moses::Scan<UINT64>(tokens[1]);
	}
	
	// create lookup
	// assume contiguous vocab id
	m_lookup.resize(m_vocabColl.size() + 1);
	
	CollType::const_iterator iter;
	for (iter = m_vocabColl.begin(); iter != m_vocabColl.end(); ++iter)
	{
		UINT32 vocabId = iter->second;
		const std::string &word = iter->first;
		
		m_lookup[vocabId] = word;
	}
	
	return true;
}
void Vocab::Save(OnDiskWrapper &onDiskWrapper)
{
  fstream &file = onDiskWrapper.GetFileVocab();
  CollType::const_iterator iterVocab;
  for (iterVocab = m_vocabColl.begin(); iterVocab != m_vocabColl.end(); ++iterVocab) {
    const string &word = iterVocab->first;
    UINT32 vocabId = iterVocab->second;

    file << word << " " << vocabId << endl;
  }
}