当前位置: 首页>>代码示例>>Java>>正文


Java FileIO.makeDirectory方法代码示例

本文整理汇总了Java中happy.coding.io.FileIO.makeDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileIO.makeDirectory方法的具体用法?Java FileIO.makeDirectory怎么用?Java FileIO.makeDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在happy.coding.io.FileIO的用法示例。


在下文中一共展示了FileIO.makeDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: probeTTTnScores

import happy.coding.io.FileIO; //导入方法依赖的package包/类
protected void probeTTTnScores() throws Exception
{
	int horizon = params.TRUST_PROPERGATION_LENGTH;
	FileIO.makeDirectory(trustDirPath);
	Logs.debug("Building TT{} Data to: {}", horizon, trustDirPath);

	for (String user : testUserRatingsMap.keySet())
	{
		File file = new File(trustDirPath + user + ".txt");
		if (file.exists()) continue;

		Map<String, Double> trustScores = TidalTrust.runAlgorithm(userTrusteesMap, userTrustorsMap,
				userTrustRatingsMap, user, horizon);
		if (trustScores != null && trustScores.size() > 0) FileIO.writeMap(file.getPath(), trustScores);
	}
	Logs.debug("Done!");
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:18,代码来源:TTx_mt.java

示例2: run_web_pages

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public void run_web_pages(String url) throws Exception {
	String[] data = url.split(": ");
	String category = data[0];
	String link = data[1];
	String dirPath = FileIO.makeDirectory(dir, category, "webPages");

	int pageSize = 15;
	String html = read_url(link);
	FileIO.writeString(dirPath + "page_" + 1 + ".html", html);

	Document doc = Jsoup.parse(html);
	int maxPage = Integer.parseInt(doc.select(
			"div.CWCiaoKievPagination.clearfix li.last").text());
	Logs.debug(category + ": progress [" + 1 + "/" + maxPage + "]");

	for (int i = 2; i <= maxPage; i++) {
		String pageLink = link + "~s" + (i - 1) * pageSize;
		String content = read_url(pageLink);
		FileIO.writeString(dirPath + "page_" + i + ".html", content);
		Logs.debug(category + ": progress [" + i + "/" + maxPage + "]");
	}
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:23,代码来源:CiaoCrawler.java

示例3: sampleByItems

import happy.coding.io.FileIO; //导入方法依赖的package包/类
@Test
public void sampleByItems() throws Exception
{
	int num_users = 3000;
	int num_items = 2000;

	ConfigParams.defaultInstance();
	String dirPath = Dataset.DIRECTORY + "Sample_" + num_items + "_items/";
	FileIO.deleteDirectory(dirPath);
	FileIO.makeDirectory(dirPath);

	samplingDatasetByItems(num_users, num_items);

	String trustPath = Dataset.DIRECTORY + Dataset.TRUST_SET;
	retrieveTrustData(dirPath, trustPath);

	splitKFoldDataset(dirPath);

	Logs.debug("Data sampling is done!");
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:21,代码来源:DatasetUtils.java

示例4: initFolders

import happy.coding.io.FileIO; //导入方法依赖的package包/类
private void initFolders() {
	String resultPath = cf.getString("result.dir");
	File f = new File(resultPath + File.separator + algoName + File.separator + getFactors() + "_"
			+ Dates.now().replace(" ", "_"));
	f.mkdirs();
	resultFolder = f.getAbsolutePath();
	try {
		logPW = FileUtil.createWriter(resultFolder + File.separator + "log.txt");

		String info = algoName + ": \n" + toString();
		logPW.println(info);

		logPW.println("Training set: " + trainDao.getRatingPath());
		logPW.println("Testing set: " + testDao.getRatingPath());
		logPW.println("Text:" + trainDao.getTextPath());

		logPW.println("-----Training----");
		logPW.println("User: " + numUsers);
		logPW.println("Items: " + numItems);
		logPW.println("Ratings: " + numRates);
		logPW.println();

		logPW.flush();

		resultPW = FileUtil.createWriter(resultFolder + File.separator + "result.csv");
		resultPW.println(info);
		String evalInfo = "Iter,Pre1,Pre3,Pre5,Pre10,Pre20,MAP";
		resultPW.println(evalInfo);

		FileIO.makeDirectory(resultFolder + File.separator + "prediction");

		// copy config file
		Files.copy(new File(configPath), new File(resultFolder + File.separator + "config.txt"));

	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:kite1988,项目名称:famf,代码行数:39,代码来源:Recommender.java

示例5: saveModel

import happy.coding.io.FileIO; //导入方法依赖的package包/类
protected String saveModel() throws Exception {
	// make a folder
	modelFolder = resultFolder + File.separator + "model/";
	FileIO.makeDirectory(modelFolder);

	if (!FileIO.exist(modelFolder + "config"))
		FileIO.copyFile(configPath, modelFolder + "config");

	// save the rating matrix and dao as binary to save space
	String suffix = ".bin";
	if (cf.isOn("save.model.bin")) {
		suffix = ".bin";
		FileIO.serialize(U, modelFolder + "userFactors" + suffix);
		FileIO.serialize(T, modelFolder + "textFactors" + suffix);
		if (V != null)
			FileIO.serialize(V, modelFolder + "visualFactors" + suffix);
	} else {
		suffix = ".txt";
		if (U != null)
			VectorUtil.saveMatrix(U, modelFolder + "userFactors" + suffix);
		if (T != null)
			VectorUtil.saveMatrix(T, modelFolder + "textFactors" + suffix);
		if (V != null)
			VectorUtil.saveMatrix(V, modelFolder + "visualFactors" + suffix);
	}

	suffix = ".txt";
	// save name-id maps
	VectorUtil.saveMap(trainDao.getIdUsers(), modelFolder + "idUsers" + suffix);
	VectorUtil.saveMap(trainDao.getIdItems(), modelFolder + "train_idItems" + suffix);
	VectorUtil.saveMap(testDao.getIdItems(), modelFolder + "test_idItems" + suffix);
	Logs.debug("Learned models are saved to folder \"{}\"", modelFolder);

	return modelFolder;
}
 
开发者ID:kite1988,项目名称:famf,代码行数:36,代码来源:Recommender.java

示例6: probeITrust

import happy.coding.io.FileIO; //导入方法依赖的package包/类
/**
 * Probe implicit trust from user ratings
 * @throws Exception 
 */
private void probeITrust() throws Exception
{
	trustDir = Dataset.DIRECTORY + trustMetric + "-"
			+ params.TRAIN_SET.substring(0, params.TRAIN_SET.lastIndexOf(".base")) + Systems.FILE_SEPARATOR;

	if (FileIO.exist(trustDir)) return;
	else FileIO.makeDirectory(trustDir);

	switch (trustMetric)
	{
		case "TM1":
			TM1();
			break;
		case "TM2":
			TM2();
			break;
		case "TM3a":
			TM3a();
			break;
		case "TM3b":
			TM3b();
			break;
		case "TM4":
			TM4();
			break;
		case "TM5":
			TM5();
			break;
	}

}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:36,代码来源:ITrust_mt.java

示例7: GewaraCrawler

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public GewaraCrawler(String url, String task, int id) throws Exception
{
	super(url, id);

	FileIO.makeDirectory(dir);
	this.task = task;
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:8,代码来源:GewaraCrawler.java

示例8: crawl_web_pages

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public void crawl_web_pages(String url) throws Exception
{
	String html = read_url(url);
	Document doc = Jsoup.parse(html);
	String name = doc.select("div.detail_head_name h1").first().text();
	name = Strings.filterWebString(name, '_');

	String dirPath = dir + name + "/";
	FileIO.makeDirectory(dirPath);
	FileIO.writeString(dirPath + name + ".html", html);
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:12,代码来源:GewaraCrawler.java

示例9: DoubanCrawler

import happy.coding.io.FileIO; //导入方法依赖的package包/类
DoubanCrawler(String url, String task, int id) throws Exception
{
	super(url, id);

	dir = folder + "douban.com/";
	FileIO.makeDirectory(dir);
	this.task = task;
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:9,代码来源:DoubanCrawler.java

示例10: run_web_pages

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public void run_web_pages(String url) throws Exception
{
	String html = read_url(url);
	Document doc = Jsoup.parse(html);
	String name = doc.select("span[property=v:itemreviewed]").text();
	name = Strings.filterWebString(name, '_');

	String dirPath = dir + name + "/";
	FileIO.makeDirectory(dirPath);
	FileIO.writeString(dirPath + name + ".html", html);
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:12,代码来源:DoubanCrawler.java

示例11: run_ratings

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public void run_ratings(String url) throws Exception
{
	String html = read_url(url);
	Document doc = Jsoup.parse(html);
	String name = doc.select("span[property=v:itemreviewed]").text();
	name = Strings.filterWebString(name, '_');

	String dirPath = dir + name + "/ratings/";
	FileIO.makeDirectory(dirPath);

	// save rating pages
	int k = 0;
	while (true)
	{
		String link = url + "collections?start=" + (k * 20);
		String page = read_url(link);

		k++;
		FileIO.writeString(dirPath + "page_" + k + ".html", page);
		Logs.debug("Current processing page: " + k);

		// if finished;
		Document doc2 = Jsoup.parse(page);
		Elements es = doc2.select("div#collections_tab span.next");
		if (es == null || es.size() == 0)
		{
			break;
		}
	}

}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:32,代码来源:DoubanCrawler.java

示例12: ITrust_t

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public ITrust_t(int id)
{
	super(id);
	trustMetric = params.readParam("itrust.probe.method");
	trustDir = FileIO.makeDirectory(Dataset.DIRECTORY,
			trustMetric + "-" + params.TRAIN_SET.substring(0, params.TRAIN_SET.lastIndexOf(".base")));
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:8,代码来源:ITrust_t.java

示例13: output_trust

import happy.coding.io.FileIO; //导入方法依赖的package包/类
private void output_trust(String line, int... indexes) throws Exception {
	String dir = Dataset.DIRECTORY + "Trust/";
	for (int i = 0; i < indexes.length; i++) {
		int index = indexes[i];
		if (i > 0)
			dir += "_";
		dir += index;
	}
	dir += "/";
	FileIO.makeDirectory(dir);
	String file = dir + "trust.txt";

	FileIO.writeString(file, line, true);
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:15,代码来源:MATrust_mt.java

示例14: main

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	// Logs.debug(LibRec.readme());

	// get configuration file
	cf = new Configer("librec.conf");

	// debug info
	debugInfo();

	// prepare data
	rateDao = new DataDAO(cf.getPath("dataset.training"));
	rateMatrix = rateDao.readData(cf.getDouble("val.binary.threshold"));

	// config general recommender
	Recommender.cf = cf;
	Recommender.rateMatrix = rateMatrix;
	Recommender.rateDao = rateDao;

	// required: only one parameter varying for multiple run
	Recommender.params = RecUtils.buildParams(cf);

	// run algorithms
	if (Recommender.params.size() > 0) {
		// multiple run
		for (Entry<String, List<Float>> en : Recommender.params.entrySet()) {
			for (int i = 0, im = en.getValue().size(); i < im; i++) {
				LibRec.paramIdx = i;
				runAlgorithm();

				// useful for some methods which do not use the parameters
				// defined in Recommender.params
				if (!isMultRun)
					break;
			}
		}

	} else {
		// single run
		runAlgorithm();
	}

	// collect results
	String destPath = FileIO.makeDirectory("Results");
	String dest = destPath + algorithm + "@" + Dates.now() + ".txt";
	FileIO.copyFile("results.txt", dest);

	notifyMe(dest);
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:49,代码来源:LibRec.java

示例15: predict

import happy.coding.io.FileIO; //导入方法依赖的package包/类
/**
 * Predict the trusted values for the trustors
 * 
 * @return the path to the prediction results
 */
protected String predict() throws Exception {
	Logs.debug("Predict users' trustworthiness ...");

	// store prediction data to disk
	String path = FileIO.makeDirPath(dirPath, FileIO.getCurrentFolder(), model + "-preds");
	if (FileIO.exist(path))
		FileIO.deleteDirectory(path);
	FileIO.makeDirectory(path);

	Map<String, Float> preds = new HashMap<>();
	for (final String u : testUsers) {

		// predict trustworthiness
		preds.clear();
		for (String v : users) {
			if (u.equals(v))
				continue;

			float tuv = predict(u, v);

			if (tuv > 0)
				preds.put(v, tuv);
		}

		// output trust predictions to save memory
		if (Debug.ON) {
			if (preds.size() > 0) {
				FileIO.writeMap(path + u + ".txt", preds, new MapWriter<String, Float>() {

					@Override
					public String processEntry(String key, Float val) {
						return u + sep + key + sep + val;
					}
				}, false);
			}
		}
	}
	Logs.debug("Done!");

	return path;
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:47,代码来源:TrustModel.java


注:本文中的happy.coding.io.FileIO.makeDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。