fasttext.h
Go to the documentation of this file.
#ifndef FASTTEXT_FASTTEXT_H
#define FASTTEXT_FASTTEXT_H
#define FASTTEXT_VERSION 11 /* Version 1a */
#define FASTTEXT_FILEFORMAT_MAGIC_INT32 793712314
#include <time.h>
#include <atomic>
#include <memory>
#include <set>
#include "args.h"
#include "dictionary.h"
#include "matrix.h"
#include "qmatrix.h"
#include "model.h"
#include "real.h"
#include "utils.h"
#include "vector.h"
namespace fasttext {
class FastText {
private:
std::shared_ptr<Args> args_;
std::shared_ptr<Dictionary> dict_;
std::shared_ptr<Matrix> input_;
std::shared_ptr<Matrix> output_;
std::shared_ptr<QMatrix> qinput_;
std::shared_ptr<QMatrix> qoutput_;
std::shared_ptr<Model> model_;
std::atomic<int64_t> tokenCount;
clock_t start;
void signModel(std::ostream&);
bool checkModel(std::istream&);
bool quant_;
public:
FastText();
void getVector(Vector&, const std::string&) const;
void saveVectors();
void saveOutput();
void saveModel();
void loadModel(std::istream&);
void loadModel(const std::string&);
void printInfo(real, real);
void supervised(Model&, real, const std::vector<int32_t>&,
const std::vector<int32_t>&);
void cbow(Model&, real, const std::vector<int32_t>&);
void skipgram(Model&, real, const std::vector<int32_t>&);
std::vector<int32_t> selectEmbeddings(int32_t) const;
void quantize(std::shared_ptr<Args>);
void test(std::istream&, int32_t);
void predict(std::istream&, int32_t, bool);
void predict(
std::istream&,
int32_t,
std::vector<std::pair<real, std::string>>&) const;
void wordVectors();
void sentenceVectors();
void ngramVectors(std::string);
void textVectors();
void printWordVectors();
void printSentenceVectors();
void precomputeWordVectors(Matrix&);
void findNN(const Matrix&, const Vector&, int32_t,
const std::set<std::string>&);
void nn(int32_t);
void analogies(int32_t);
void trainThread(int32_t);
void train(std::shared_ptr<Args>);
void loadVectors(std::string);
int getDimension() const;
};
}
#endif
fasttext::FastText::textVectors
void textVectors()
Definition: fasttext.cc:402
fasttext::FastText::model_
std::shared_ptr< Model > model_
Definition: fasttext.h:44
fasttext::FastText::printSentenceVectors
void printSentenceVectors()
Definition: fasttext.cc:422
fasttext::FastText::supervised
void supervised(Model &, real, const std::vector< int32_t > &, const std::vector< int32_t > &)
Definition: fasttext.cc:257
fasttext::FastText::saveModel
void saveModel()
Definition: fasttext.cc:93
fasttext::FastText::getVector
void getVector(Vector &, const std::string &) const
Definition: fasttext.cc:28
fasttext::FastText::ngramVectors
void ngramVectors(std::string)
Definition: fasttext.cc:388
fasttext::FastText
Definition: fasttext.h:33
fasttext::FastText::loadVectors
void loadVectors(std::string)
Definition: fasttext.cc:551
fasttext::FastText::tokenCount
std::atomic< int64_t > tokenCount
Definition: fasttext.h:46
fasttext::FastText::qoutput_
std::shared_ptr< QMatrix > qoutput_
Definition: fasttext.h:42
fasttext::FastText::findNN
void findNN(const Matrix &, const Vector &, int32_t, const std::set< std::string > &)
Definition: fasttext.cc:443
fasttext::FastText::cbow
void cbow(Model &, real, const std::vector< int32_t > &)
Definition: fasttext.cc:266
fasttext::FastText::selectEmbeddings
std::vector< int32_t > selectEmbeddings(int32_t) const
Definition: fasttext.cc:194
fasttext::FastText::nn
void nn(int32_t)
Definition: fasttext.cc:467
fasttext::FastText::getDimension
int getDimension() const
Definition: fasttext.cc:645
model.h
fasttext
Definition: args.cc:17
fasttext::FastText::FastText
FastText()
Definition: fasttext.cc:26
fasttext::Vector
Definition: vector.h:23
fasttext::FastText::trainThread
void trainThread(int32_t)
Definition: fasttext.cc:511
fasttext::FastText::analogies
void analogies(int32_t)
Definition: fasttext.cc:483
fasttext::FastText::test
void test(std::istream &, int32_t)
Definition: fasttext.cc:297
fasttext::FastText::checkModel
bool checkModel(std::istream &)
Definition: fasttext.cc:72
utils.h
fasttext::FastText::loadModel
void loadModel(std::istream &)
Definition: fasttext.cc:140
fasttext::FastText::start
clock_t start
Definition: fasttext.h:47
fasttext::Model
Definition: model.h:38
fasttext::FastText::quant_
bool quant_
Definition: fasttext.h:51
real.h
fasttext::FastText::printWordVectors
void printWordVectors()
Definition: fasttext.cc:418
fasttext::FastText::train
void train(std::shared_ptr< Args >)
Definition: fasttext.cc:591
fasttext::FastText::saveVectors
void saveVectors()
Definition: fasttext.cc:39
fasttext::FastText::saveOutput
void saveOutput()
Definition: fasttext.cc:55
fasttext::FastText::sentenceVectors
void sentenceVectors()
Definition: fasttext.cc:368
matrix.h
fasttext::FastText::predict
void predict(std::istream &, int32_t, bool)
Definition: fasttext.cc:338
fasttext::FastText::qinput_
std::shared_ptr< QMatrix > qinput_
Definition: fasttext.h:41
fasttext::FastText::output_
std::shared_ptr< Matrix > output_
Definition: fasttext.h:39
fasttext::FastText::input_
std::shared_ptr< Matrix > input_
Definition: fasttext.h:38
vector.h
fasttext::FastText::args_
std::shared_ptr< Args > args_
Definition: fasttext.h:35
fasttext::FastText::precomputeWordVectors
void precomputeWordVectors(Matrix &)
Definition: fasttext.cc:430
args.h
fasttext::real
float real
Definition: real.h:15
fasttext::Matrix
Definition: matrix.h:23
fasttext::FastText::skipgram
void skipgram(Model &, real, const std::vector< int32_t > &)
Definition: fasttext.cc:283
fasttext::FastText::printInfo
void printInfo(real, real)
Definition: fasttext.cc:178
fasttext::FastText::wordVectors
void wordVectors()
Definition: fasttext.cc:359
fasttext::FastText::dict_
std::shared_ptr< Dictionary > dict_
Definition: fasttext.h:36
fasttext::FastText::quantize
void quantize(std::shared_ptr< Args >)
Definition: fasttext.cc:208
fasttext::FastText::signModel
void signModel(std::ostream &)
Definition: fasttext.cc:86
dictionary.h
qmatrix.h