Skip to content

Commit

Permalink
Fixed bug with uninitialized memory
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremysalwen committed Apr 12, 2014
1 parent b0d6593 commit 3bca9d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cextractcontexts.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ void compute_and_output_context(const boost::circular_buffer<int>& context, cons
if(midid>=prune) {
return;
}
arma::fvec out(vecdim);
arma::fvec out(vecdim,arma::fill::zeros);
compute_context(context, idfs,origvects,out,vecdim,contextsize);

//now tot will contain the context representation of the middle vector
fwrite(&out[0],sizeof(float),vecdim,outfiles[midid]);
fwrite(out.memptr(),sizeof(float),vecdim,outfiles[midid]);
}

int extract_contexts(std::ifstream& vocabstream, std::ifstream& tfidfstream, std::ifstream& vectorstream, std::string indir, std::string outdir, int vecdim,unsigned int contextsize,std::string eodmarker, bool indexed,unsigned int prune) {
Expand Down
4 changes: 2 additions & 2 deletions crelabelcorpus.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace fs=boost::filesystem;

int convert_word(int index, const boost::circular_buffer<int>& context, const std::vector<float>& idfs, const arma::fmat& origvects,const arma::fmat& newvects, std::vector<unsigned int>& xref, unsigned int vecdim, unsigned int contextsize) {
arma::fvec c;
compute_context(context, idfs,origvects.memptr(), c,vecdim,contextsize);
compute_context(context, idfs,origvects, c,vecdim,contextsize);
unsigned int starti=xref[index];
unsigned int endi=xref[index+1];

Expand Down Expand Up @@ -172,7 +172,7 @@ int main(int argc, char** argv) {
unsigned int contextsize;
std::string eod;

po::options_description desc("CExpandVocab Options");
po::options_description desc("CRelabelCorpus Options");
desc.add_options()
("help,h", "produce help message")
("oldvocab,v", po::value<std::string>(&vocabf)->value_name("<filename>")->required(), "original vocab file")
Expand Down

0 comments on commit 3bca9d8

Please sign in to comment.