-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cc
More file actions
31 lines (25 loc) · 1022 Bytes
/
main.cc
File metadata and controls
31 lines (25 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//g++ main.cc src/tfidf_vectorizer.cc -larmadillo -std=c++11
#include "include/tfidf_vectorizer.h"
int main()
{
std::vector<std::string> documents = {"This is the first document.",
"This document is the second document.",
"And this is the third one.",
"Is this the first document?"};
TfIdfVectorizer tfidfvectorizer;
arma::mat X = tfidfvectorizer.fit_transform(documents);
X.print("TF-IDF Matrix");
std::map<std::string, double> idfs = tfidfvectorizer.get_idf_();
std::map<std::string, size_t> vocab = tfidfvectorizer.get_vocabulary_();
std::cout << "Training vocabulary:" << std::endl;
for (auto const& x : vocab)
{
std::cout << x.first << " ";
}std::cout << std::endl;
std::cout << "IDF values:" << std::endl;
for (auto const& x : idfs)
{
std::cout << x.first << " = " << x.second << std::endl;;
}
return 0;
}