Exemple #1
0
int main(){

	const string fn = "iris.csv";

	CSVData mycsv;
	mycsv.load_from(fn);

	cout << "new size:"<< mycsv.get_col() * mycsv.get_row() << endl;
	cout << "conb:" << conb(mycsv.get_col(),2) << endl;

	folder_check();
	
	all_data mydata;

	//all
	mydata.all(mycsv);//CSVData型をall_data型へ変換。mydataのメンバ変数をいじる。
	
	//フィルタ
	cout <<"-----------------------------------------"<<endl;

	//allからafter_filにコピー
	fil_kmeans(mydata);
	fil_r(mydata);

	print(mydata);

	write(mydata);//ファイル書き込み

	cout << "Complete!!!" <<endl;

	return 0;
}
Exemple #2
0
static int folder_scan(folderInfo_t* fi)
{
	DIR *dir;
	char path[256], subpath[10];
	struct dirent* ptr;
	struct dirent** list = NULL;
	int fldidx = 0, fidx = 0;
	int fnum, file_num = 0;
	int i, j;
	
	memset(fi->working_path, 0, 256);
	
	dir = opendir(fi->root_path);
	
	if (!dir)
	{
		printf("[folder] open directory %s fail: %s\n", fi->root_path, strerror(errno));
		return -1;
	}
	
	closedir(dir);
		
	if (fi->root_path[strlen(fi->root_path)-1] == '/')
		fi->root_path[strlen(fi->root_path)-1] = 0;
		
	sprintf(path, "%s/%s", fi->root_path, fi->folder_name);
	
	dir = opendir(path);
		
	if (!dir)
	{
		if (errno == ENOENT)
		{
			printf("[folder] directory not found, create %s\n", path);
			if (0 > mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO))
			{
				printf("[folder] canot create directory %s. error: %s\n", path, strerror(errno));
				return -1;
			}			
		}
		
		dir = opendir(path);
		
		if (!dir)
		{
			printf("[folder] open directory %s fail. error: %s\n", path, strerror(errno));
			return -1;
		}
	}
	
	closedir(dir);
	
	strcpy(fi->working_path, path);

	fi->folder_num = scandir(path, &fi->folder_list, folder_select, folder_compar);
	if (0 > fi->folder_num)
	{
		printf("[folder] cannot scan directory %s. errno: %s\n", path, strerror(errno));
		return -1;
	}

	for (i = 0; i < fi->folder_num; i++)
	{
		if (0 > folder_check(fi->folder_list[i], fi->working_path))
		{
			printf("[folder scan] skipped %s\n", fi->folder_list[i]->d_name);
			free(fi->folder_list[i]);
			fi->folder_list[i] = NULL;
		}
	}
	for (i = 0, j = 0; i < fi->folder_num; i++)
	{
		if (fi->folder_list[i])
		{
			if (j < i)
			{
				fi->folder_list[j+1] = fi->folder_list[i];
				fi->folder_list[i] = NULL;
			}
			printf("[folder scan] found %s\n", fi->folder_list[j]->d_name);
			j++;
		}
	}
	fi->folder_num = j;
				
	fi->delete_folder_idx = 0;
	
	if (fi->folder_num)
	{
		strcat(path, "/");
		strcat(path, fi->folder_list[fi->folder_num-1]->d_name);
	
		if (fi->name_format == 1)
			file_num = scandir(path, &list, file_select2, file_compar2);
		else
			file_num = scandir(path, &list, file_select, file_compar);
		if (0 > file_num)
		{
			printf("[folder] cannot scan directory %s. errno: %s\n", path, strerror(errno));
			return -1;
		}
		
		//for (i = 0; i < file_num; i++)
			//printf("[file scan] %s\n", list[i]->d_name);
	}
	
	if (file_num)
	{
		char* tmp;
		
		if (fi->name_format == 1)
			fnum = file_num;
		else
		{
			tmp = strdup(list[file_num-1]->d_name);
			tmp[8] = 0;
			fnum = (int)strtoul(&tmp[4], NULL, 10);
			free(tmp);
			fnum++;

			if (fnum > 9999)
				fnum = 1;
		}
			
		if (list)
		{
			while(file_num)
				free(list[--file_num]);
			
			free(list);
		}
	}
	else
		fnum = 1;
		
	return fnum;
}
Exemple #3
0
int main(){

	const string fn = "iris.csv";

	//CSVData mycsv;
	//mycsv.load_from(fn);

	//cout << "new size:"<< mycsv.get_col() * mycsv.get_row() << endl;
	//cout << "conb:" << conb(mycsv.get_col(),2) << endl;

	folder_check();

	/*
	all_data mydata;

	//all
	mydata.all(mycsv);//CSVData型をall_data型へ変換。mydataのメンバ変数をいじる。
	
	//フィルタ
	cout <<"-----------------------------------------"<<endl;

	fil_kmeans(&mydata);
	fil_r(&mydata);
	//sort(mydata.mysd.begin(), mydata.mysd.end());
	

	//print(mydata);

	write(mydata);//ファイル書き込み
*/

	Platform p;
	
	//分析オブジェクト生成
	Sokan *sokan = new Sokan();
	Kmeans *kmeans = new Kmeans();
	Aso *aso = new Aso();
	
	//フィルターオブジェクト生成
	Fil_kmeans *f_kmeans = new Fil_kmeans();
	Fil_r *f_r = new Fil_r();

	//分析オブジェクトをセット
	p.addAnalyzer(sokan);
	p.addAnalyzer(kmeans);
	p.addAnalyzer(aso);

	//フィルターオブジェクトをセット
	//p.addFilter(f_kmeans);
	p.addFilter(f_r);

	//入力データセット
	p.input(fn);

	//実行
	p.execute();
	
	//出力
	p.output();

	cout << "Complete!!!" <<endl;

	delete sokan;
	delete kmeans;
	delete aso;
	delete f_kmeans;
	delete f_r;

	return 0;
}