资源简介
有需要的可以用 自己下载源码编译就不需要了
代码片段和文件信息
/*
* Copyright (C) 2007 by
*
* Xuan-Hieu Phan
* hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com
* Graduate School of Information Sciences
* Tohoku University
*
* GibbsLDA++ is a free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License
* or (at your option) any later version.
*
* GibbsLDA++ is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GibbsLDA++; if not write to the Free Software Foundation
* Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA.
*/
#include “stdafx.h“
#include
#include
#include “constants.h“
#include “strtokenizer.h“
#include “dataset.h“
using namespace std;
int dataset::write_wordmap(string wordmapfile mapword2id * pword2id) {
FILE * fout = fopen(wordmapfile.c_str() “w“);
if (!fout) {
printf(“Cannot open file %s to write!\n“ wordmapfile.c_str());
return 1;
}
mapword2id::iterator it;
fprintf(fout “%d\n“ pword2id->size());
for (it = pword2id->begin(); it != pword2id->end(); it++) {
fprintf(fout “%s %d\n“ (it->first).c_str() it->second);
}
fclose(fout);
return 0;
}
int dataset::read_wordmap(string wordmapfile mapword2id * pword2id) {
pword2id->clear();
FILE * fin = fopen(wordmapfile.c_str() “r“);
if (!fin) {
printf(“Cannot open file %s to read!\n“ wordmapfile.c_str());
return 1;
}
char buff[BUFF_SIZE_SHORT];
string line;
fgets(buff BUFF_SIZE_SHORT - 1 fin);
int nwords = atoi(buff);
for (int i = 0; i < nwords; i++) {
fgets(buff BUFF_SIZE_SHORT - 1 fin);
line = buff;
strtokenizer strtok(line “ \t\r\n“);
if (strtok.count_tokens() != 2) {
continue;
}
pword2id->insert(pair(strtok.token(0) atoi(strtok.token(1).c_str())));
}
fclose(fin);
return 0;
}
int dataset::read_wordmap(string wordmapfile mapid2word * pid2word) {
pid2word->clear();
FILE * fin = fopen(wordmapfile.c_str() “r“);
if (!fin) {
printf(“Cannot open file %s to read!\n“ wordmapfile.c_str());
return 1;
}
char buff[BUFF_SIZE_SHORT];
string line;
fgets(buff BUFF_SIZE_SHORT - 1 fin);
int nwords = atoi(buff);
for (int i = 0; i < nwords; i++) {
fgets(buff BUFF_SIZE_SHORT - 1 fin);
line = buff;
strtokenizer strtok(line “ \t\r\n“);
if (strtok.count_tokens() != 2) {
continue;
}
pid2word->insert(pair(atoi(strtok.token(1).c_str()) strtok.token(0)));
}
fclose(fin);
return 0;
}
int dataset::read_trndata(string dfile string wordmapfile) {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-12-08 12:12 lda\
目录 0 2016-12-07 18:19 lda\.vs\
目录 0 2016-12-07 18:19 lda\.vs\lda\
目录 0 2016-12-07 18:19 lda\.vs\lda\v14\
文件 41984 2016-12-08 12:12 lda\.vs\lda\v14\.suo
目录 0 2016-12-08 12:11 lda\Debug\
目录 0 2016-12-07 18:19 lda\ipch\
目录 0 2016-12-07 18:22 lda\ipch\LDA-14097a83\
文件 3407872 2016-12-07 18:22 lda\ipch\LDA-14097a83\LDA-b40717bd.ipch
目录 0 2016-12-07 18:28 lda\lda\
文件 1291 2016-12-07 18:19 lda\lda.sln
文件 12517376 2016-12-08 12:12 lda\lda.VC.db
文件 1107 2007-07-13 14:07 lda\lda\constants.h
文件 8300 2016-12-07 18:21 lda\lda\dataset.cpp
文件 3770 2007-08-01 13:12 lda\lda\dataset.h
文件 106244 2007-08-01 17:59 lda\lda\dataset.o
目录 0 2016-12-08 12:11 lda\lda\Debug\
文件 1526 2016-12-08 12:11 lda\lda\Debug\lda.Build.CppClean.log
文件 3 2016-12-08 12:11 lda\lda\Debug\lda.log
目录 0 2016-12-08 12:11 lda\lda\Debug\lda.tlog\
文件 73636 2007-08-01 17:59 lda\lda\lda
文件 1850 2016-12-07 18:19 lda\lda\lda.cpp
文件 8415 2016-12-07 18:22 lda\lda\lda.vcxproj
文件 2123 2016-12-07 18:20 lda\lda\lda.vcxproj.filters
文件 473 2007-07-16 15:27 lda\lda\Makefile
文件 23757 2016-12-07 18:28 lda\lda\model.cpp
文件 5317 2007-07-30 16:58 lda\lda\model.h
文件 107580 2007-08-01 17:59 lda\lda\model.o
文件 1482 2016-12-07 18:19 lda\lda\ReadMe.txt
文件 207 2016-12-07 18:19 lda\lda\stdafx.cpp
文件 234 2016-12-07 18:19 lda\lda\stdafx.h
............此处省略7个文件信息
- 上一篇:14章9题全部输入输出结果
- 下一篇:全国医院信息化建设标准与规范
评论
共有 条评论