<commit_before>#include "PrefixTreeMap.h"
#include "TypeDef.h"

namespace Moses
{
void GenericCandidate::readBin(FILE* f){
  m_PhraseList.clear();
  m_ScoreList.clear();
  UINT32 num_phrases;  // on older compilers, <stdint.h> may need to be included
  fRead(f, num_phrases);
  for(unsigned int i = 0; i < num_phrases; ++i){
	IPhrase phrase;
	fReadVector(f, phrase);
	m_PhraseList.push_back(phrase);
  };
  UINT32 num_scores;
  fRead(f, num_scores);
  for(unsigned int j = 0; j < num_scores; ++j){
	std::vector<float> score;
	fReadVector(f, score);
	m_ScoreList.push_back(score);
  };
};

void GenericCandidate::writeBin(FILE* f) const {
  // cast is necessary to ensure compatibility between 32- and 64-bit platforms
  fWrite(f, static_cast<UINT32>(m_PhraseList.size()));
  for(size_t i = 0; i < m_PhraseList.size(); ++i){
	fWriteVector(f, m_PhraseList[i]);
  }
  fWrite(f, static_cast<UINT32>(m_ScoreList.size()));
  for(size_t j = 0; j < m_ScoreList.size(); ++j){
	fWriteVector(f, m_ScoreList[j]);
  }
};


void Candidates::writeBin(FILE* f) const {
  UINT32 s = this->size();
  fWrite(f,s);
  for(size_t i = 0; i < s; ++i) {
	MyBase::operator[](i).writeBin(f);
  }
}

void Candidates::readBin(FILE* f) {
  UINT32 s;
  fRead(f,s);
  this->resize(s);
  for(size_t i = 0; i<s; ++i) {
	MyBase::operator[](i).readBin(f);
  }
}

const LabelId PrefixTreeMap::MagicWord = InvalidLabelId - 1; 


void PrefixTreeMap::FreeMemory() {
  for(Data::iterator i = m_Data.begin(); i != m_Data.end(); ++i){
	i->free();<commit_msg>Fix seg fault when libmoses is used ad a dynamic library on windows, MagicWord was initialized to a wrong value<commit_after>#include "PrefixTreeMap.h"
#include "TypeDef.h"

namespace Moses
{
void GenericCandidate::readBin(FILE* f){
  m_PhraseList.clear();
  m_ScoreList.clear();
  UINT32 num_phrases;  // on older compilers, <stdint.h> may need to be included
  fRead(f, num_phrases);
  for(unsigned int i = 0; i < num_phrases; ++i){
	IPhrase phrase;
	fReadVector(f, phrase);
	m_PhraseList.push_back(phrase);
  };
  UINT32 num_scores;
  fRead(f, num_scores);
  for(unsigned int j = 0; j < num_scores; ++j){
	std::vector<float> score;
	fReadVector(f, score);
	m_ScoreList.push_back(score);
  };
};

void GenericCandidate::writeBin(FILE* f) const {
  // cast is necessary to ensure compatibility between 32- and 64-bit platforms
  fWrite(f, static_cast<UINT32>(m_PhraseList.size()));
  for(size_t i = 0; i < m_PhraseList.size(); ++i){
	fWriteVector(f, m_PhraseList[i]);
  }
  fWrite(f, static_cast<UINT32>(m_ScoreList.size()));
  for(size_t j = 0; j < m_ScoreList.size(); ++j){
	fWriteVector(f, m_ScoreList[j]);
  }
};


void Candidates::writeBin(FILE* f) const {
  UINT32 s = this->size();
  fWrite(f,s);
  for(size_t i = 0; i < s; ++i) {
	MyBase::operator[](i).writeBin(f);
  }
}

void Candidates::readBin(FILE* f) {
  UINT32 s;
  fRead(f,s);
  this->resize(s);
  for(size_t i = 0; i<s; ++i) {
	MyBase::operator[](i).readBin(f);
  }
}

const LabelId PrefixTreeMap::MagicWord = std::numeric_limits<LabelId>::max() - 1;


void PrefixTreeMap::FreeMemory() {
  for(Data::iterator i = m_Data.begin(); i != m_Data.end(); ++i){
	i->free();
{'fraction_non_alphanumeric': 0.17249047013977128, 'fraction_numerical': 0.014612452350698857, 'mean_word_length': 4.777981651376146, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3683179', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1249, 'n_words': 276}