Skip to content

Commit 83a7e0d

Browse files
committed
Remove WMD
1 parent dc24764 commit 83a7e0d

5 files changed

Lines changed: 30 additions & 16 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: doc2vec
22
Type: Package
33
Title: Distributed Representations of Sentences and Documents
4-
Version: 0.1.0
4+
Version: 0.1.1
55
Authors@R: c(
66
person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = '[email protected]', comment = "R wrapper"),
77
person('BNOSAC', role = 'cph', comment = "R wrapper"),

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## CHANGES IN doc2vec VERSION 0.1.1
2+
3+
- Fixes for valgrind R CMD checks
4+
- Fixes for destructors of Vocabulary
5+
- Remove WMD
6+
17
## CHANGES IN doc2vec VERSION 0.1.0
28

39
- Initial package based on https://github.com/hiyijian/doc2vec commit dec123e891f17ea664053ee7575b0e5e7dae4fca

src/Makevars

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CXX_STD = CXX11
22
PKG_LIBS = -pthread
33
PKG_CPPFLAGS = -pthread -DSTRICT_R_HEADERS -I./doc2vec
44

5-
SOURCES = doc2vec/Doc2Vec.cpp \
5+
#SOURCES = doc2vec/Doc2Vec.cpp \
66
doc2vec/NN.cpp \
77
doc2vec/TaggedBrownCorpus.cpp \
88
doc2vec/TrainModelThread.cpp \
@@ -11,6 +11,14 @@ SOURCES = doc2vec/Doc2Vec.cpp \
1111
rcpp_doc2vec.cpp \
1212
RcppExports.cpp
1313

14+
SOURCES = doc2vec/Doc2Vec.cpp \
15+
doc2vec/NN.cpp \
16+
doc2vec/TaggedBrownCorpus.cpp \
17+
doc2vec/TrainModelThread.cpp \
18+
doc2vec/Vocab.cpp \
19+
rcpp_doc2vec.cpp \
20+
RcppExports.cpp
21+
1422
OBJECTS = $(SOURCES:.cpp=.o)
1523

1624
.PHONY: all

src/doc2vec/Doc2Vec.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "Doc2Vec.h"
44
#include "NN.h"
55
#include "Vocab.h"
6-
#include "WMD.h"
6+
//#include "WMD.h"
77
#include "TrainModelThread.h"
88
#include "TaggedBrownCorpus.h"
99

@@ -17,7 +17,7 @@ void * trainModelThread(void * params)
1717
}
1818

1919
/////==============================DOC2VEC========================
20-
Doc2Vec::Doc2Vec(): m_word_vocab(NULL), m_doc_vocab(NULL), m_nn(NULL), m_wmd(NULL),
20+
Doc2Vec::Doc2Vec(): m_word_vocab(NULL), m_doc_vocab(NULL), m_nn(NULL), //m_wmd(NULL),
2121
m_brown_corpus(NULL), m_expTable(NULL), m_negtive_sample_table(NULL)
2222
{
2323
initExpTable();
@@ -28,7 +28,7 @@ Doc2Vec::~Doc2Vec()
2828
if(m_word_vocab) delete m_word_vocab;
2929
if(m_doc_vocab) delete m_doc_vocab;
3030
if(m_nn) delete m_nn;
31-
if(m_wmd) delete m_wmd;
31+
//if(m_wmd) delete m_wmd;
3232
if(m_brown_corpus) delete m_brown_corpus;
3333
if(m_expTable) free(m_expTable);
3434
if(m_negtive_sample_table) free(m_negtive_sample_table);
@@ -99,11 +99,11 @@ void Doc2Vec::train(const char * train_file,
9999
free(pt);
100100
if(m_trace > 0){
101101
std::time_t t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
102-
Rcpp::Rcout << Rcpp::as<Rcpp::Datetime>(Rcpp::wrap(t)) << " Closed all threads, normalising & WMD" << "\n";
102+
Rcpp::Rcout << Rcpp::as<Rcpp::Datetime>(Rcpp::wrap(t)) << " Closed all threads, normalising" << "\n";
103103
}
104104
m_nn->norm();
105-
m_wmd = new WMD(this);
106-
m_wmd->train();
105+
//m_wmd = new WMD(this);
106+
//m_wmd->train();
107107
}
108108

109109
void Doc2Vec::initTrainModelThreads(const char * train_file, int threads, int iter)
@@ -282,7 +282,7 @@ void Doc2Vec::save(FILE * fout)
282282
fwrite(&m_start_alpha, sizeof(real), 1, fout);
283283
fwrite(&m_sample, sizeof(real), 1, fout);
284284
fwrite(&m_iter, sizeof(int), 1, fout);
285-
m_wmd->save(fout);
285+
//m_wmd->save(fout);
286286
}
287287

288288
void Doc2Vec::load(FILE * fin)
@@ -304,12 +304,12 @@ void Doc2Vec::load(FILE * fin)
304304
if(errnr <= 0) Rcpp::stop("fread failed");
305305
initNegTable();
306306
m_nn->norm();
307-
m_wmd = new WMD(this);
308-
m_wmd->load(fin);
307+
//m_wmd = new WMD(this);
308+
//m_wmd->load(fin);
309309
}
310310

311311
long long Doc2Vec::dim() {return m_nn->m_dim;}
312-
WMD * Doc2Vec::wmd() {return m_wmd;}
312+
//WMD * Doc2Vec::wmd() {return m_wmd;}
313313
Vocabulary* Doc2Vec::wvocab() {return m_word_vocab;}
314314
Vocabulary* Doc2Vec::dvocab() {return m_doc_vocab;}
315315
NN * Doc2Vec::nn() {return m_nn;}

src/doc2vec/Doc2Vec.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
class TrainModelThread;
77
class NN;
88
class Vocabulary;
9-
class WMD;
9+
//class WMD;
1010
class TaggedBrownCorpus;
1111
class TaggedDocument;
1212
struct knn_item_t;
1313

1414
class Doc2Vec
1515
{
1616
friend class TrainModelThread;
17-
friend class WMD;
17+
//friend class WMD;
1818
friend class UnWeightedDocument;
1919
friend class WeightedDocument;
2020
public:
@@ -30,7 +30,7 @@ friend class WeightedDocument;
3030
Vocabulary* wvocab();
3131
Vocabulary* dvocab();
3232
NN * nn();
33-
WMD * wmd();
33+
//WMD * wmd();
3434

3535
public:
3636
real doc_likelihood(TaggedDocument * doc, int skip = -1);
@@ -59,7 +59,7 @@ friend class WeightedDocument;
5959
Vocabulary * m_word_vocab;
6060
Vocabulary * m_doc_vocab;
6161
NN * m_nn;
62-
WMD * m_wmd;
62+
//WMD * m_wmd;
6363
int m_cbow;
6464
int m_hs;
6565
int m_negtive;

0 commit comments

Comments
 (0)