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


Java Logs类代码示例

本文整理汇总了Java中happy.coding.io.Logs的典型用法代码示例。如果您正苦于以下问题:Java Logs类的具体用法?Java Logs怎么用?Java Logs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testSerialization

import happy.coding.io.Logs; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception {
	String filePath = Systems.getDesktop() + "vec.dat";

	DenseVector vec = new DenseVector(11);
	for (int i = 10, j = 0; i >= 0; i--, j++)
		vec.set(j, i);

	FileIO.serialize(vec, filePath);

	DenseVector v2 = (DenseVector) FileIO.deserialize(filePath);
	Logs.debug(v2.toString());

	DenseMatrix mat = new DenseMatrix(3, 4);
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 4; j++)
			mat.set(i, j, i + j);
	Logs.debug(mat);

	String matPath = Systems.getDesktop() + "mat.dat";
	FileIO.serialize(mat, matPath);

	DenseMatrix mat2 = (DenseMatrix) FileIO.deserialize(matPath);
	Logs.debug(mat2);

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

示例2: run_web_pages

import happy.coding.io.Logs; //导入依赖的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: load_confidences

import happy.coding.io.Logs; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void load_confidences() throws Exception
{ 
	if (userConfidencesMap == null)
	{
		String confidenceSet = Dataset.DIRECTORY + "Confidences" + Systems.FILE_SEPARATOR
				+ (isVR ? "confidences-all-vr.txt" : "confidences-all-ws.txt");
		Logs.debug("Loading confidence data {}", confidenceSet);

		Map[] data = Dataset.loadTrainSet(confidenceSet);
		userConfidencesMap = data[0];
		itemConfidencesMap = data[1];

		Logs.debug("Done!");
	}
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:17,代码来源:VirRatingsCF.java

示例4: center

import happy.coding.io.Logs; //导入依赖的package包/类
@Test
public void center()
{
	double[] prices = { 4, 4, 2, 2, 4, 3, 4, 4, 4, 4, 3, 3, 2, 5, 3, 4, 2, 5, 5, 4, 3, 5, 1, 2, 3, 2, 3, 3, 3, 3,
			2, 2, 3, 2, 3, 2, 2, 2, 3, 3, 3, 4, 4, 3, 2, 2, 5, 4, 2, 2, 2, 1, 2, 5, 1, 1, 3, 2, 2, 2, 2, 2, 2, 2,
			4, 3, 5, 2, 4, 1, 2, 4, 2, 2, 3, 4, 1, 4, 3, 4, 4, 3, 3, 4, 3, 3, 3, 5, 4, 4, 3, 2, 3, 3, 3, 2, 3, 3,
			3, 4, 3, 3, 4, 4, 5, 4, 5, 4, 3, 3, 5, 3, 4, 4, 4, 4, 4, 3, 3, 3, 5, 4, 4, 3, 4, 4, 4, 3, 4, 3, 2, 4,
			3, 1, 4, 3, 5, 3, 3, 3, 1, 1, 1, 4, 4, 3, 2, 3, 3, 4, 3, 3, 4, 4, 3, 1, 5, 2, 5, 3, 2, 3, 3, 1, 2, 3,
			3, 2, 4, 4, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, 4, 4, 4, 4, 2, 4, 3, 4, 2, 4, 4, 3, 4, 4, 3, 3, 3, 4, 3, 4,
			3, 3, 3, 3, 4, 3, 3, 5, 4, 5, 4, 4, 4, 4, 5, 2, 2, 4, 4, 4, 5, 3, 5, 3, 3, 3, 3, 3, 3, 3, 3, 1, 5, 3,
			3, 3, 3, 5, 2, 3, 3, 4, 4, 3, 4, 4, 3, 5, 4, 3, 2, 3, 2, 3, 3, 4, 4, 2, 4, 3, 3, 4, 4, 3, 2, 2, 4, 2,
			1, 1, 2, 2, 3, 2, 3, 3, 2, 3, 3, 3, 4, 5, 4, 4, 5, 5, 3, 4, 5, 4, 4, 2, 3, 1, 3, 4, 4, 3, 4, 3, 3, 4,
			3, 5, 3, 3, 2, 3, 2, 2, 5, 2, 1, 3, 3, 3, 3, 3, 2, 3, 3, 5, 4, 4, 4, 4, 3, 4, 4, 3, 4, 4, 2, 3, 4, 5,
			2, 5, 4, 5, 1, 5, 5, 5, 5, 2, 2, 2, 3, 3, 4, 2, 3, 1, 4, 4, 4, 4, 4, 4, 1, 3, 5, 3, 2, 4, 3, 3, 1, 2,
			3, 4, 3, 4, 3, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 4, 5, 4, 4, 3, 4, 4, 3, 2, 4, 5, 4, 4, 2, 4, 4, 4,
			4, 3, 2, 2, 5, 3, 4, 3, 3, 4, 4, 4, 3, 3, 3, 3, 2, 3, 2, 2, 5, 5, 5, 5, 5, 5, 5, 5, 4, };

	double mean = Stats.mean(prices);
	double median = Stats.median(prices);
	double mode = Stats.mode(prices);

	Logs.debug("Mean = {}, Median = {}, Mode = {}", new Object[] { mean, median, mode });
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:24,代码来源:VirRatingsCF.java

示例5: sampleByItems

import happy.coding.io.Logs; //导入依赖的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

示例6: retrieveTrustData

import happy.coding.io.Logs; //导入依赖的package包/类
public static void retrieveTrustData(String dirPath, String trustPath) throws Exception
{
	ConfigParams.defaultInstance();
	String ratingSet = dirPath + Dataset.RATING_SET;
	Map<String, Map<String, Rating>> userMap = Dataset.loadRatingSet(ratingSet);

	BufferedReader br = new BufferedReader(new FileReader(trustPath));
	StringBuilder sb = new StringBuilder();
	String line = null;

	while ((line = br.readLine()) != null)
	{
		if (line.isEmpty()) continue;

		String[] data = line.split(Dataset.REGMX);
		String trustor = data[0];
		String trustee = data[1];

		if (userMap.containsKey(trustor) && userMap.containsKey(trustee)) sb.append(line + "\n");
	}
	br.close();

	String filePath = dirPath + Dataset.TRUST_SET;
	FileIO.writeString(filePath, sb.toString());
	Logs.debug("Saved the trust sample to: " + filePath);
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:27,代码来源:DatasetUtils.java

示例7: load_trusts

import happy.coding.io.Logs; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void load_trusts() throws Exception
{
	if (userTNsMap == null)
	{
		switch (Dataset.dataset)
		{
			case MOVIELENS:
			case JESTER:
			case NETFLIX:
				break;
			default:
				String trustSet = Dataset.DIRECTORY + Dataset.TRUST_SET;
				Logs.debug("Loading trust data ...");
				Map[] data = DatasetUtils.loadTrustSet2(trustSet);
				userTrusteesMap = data[0];
				userTrustorsMap = data[1];
				userTrustRatingsMap = data[2];
				Logs.debug("Done!");
				break;
		}

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

示例8: probeTTTnScores

import happy.coding.io.Logs; //导入依赖的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

示例9: run

import happy.coding.io.Logs; //导入依赖的package包/类
@Override
public void run()
{
	Logs.debug(this.thread_id + " is started with link: " + url);

	try
	{
		run_thread();
	} catch (Exception e)
	{
		e.printStackTrace();
	}

	Logs.debug(this.thread_id + " is finished with link: " + url);

}
 
开发者ID:guoguibing,项目名称:HappyCoding,代码行数:17,代码来源:WebCrawler.java

示例10: listen

import happy.coding.io.Logs; //导入依赖的package包/类
public void listen() throws Exception
{
	while (true)
	{
		if (ss == null) return;
		Socket conn = ss.accept();
		Logs.debug("Get Connection from " + conn.getRemoteSocketAddress());

		InputStream is = conn.getInputStream();
		StringBuilder sb = new StringBuilder();
		int ch;

		while ((ch = is.read()) != -1)
			sb.append((char) ch);
		
		Logs.info("Message from Client: {}", sb.toString());

		is.close();
		conn.close();
	}
}
 
开发者ID:guoguibing,项目名称:HappyCoding,代码行数:22,代码来源:SocketServer.java

示例11: saveModel

import happy.coding.io.Logs; //导入依赖的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

示例12: printEvalInfo

import happy.coding.io.Logs; //导入依赖的package包/类
/**
 * print out the evaluation information for a specific algorithm
 */
private static void printEvalInfo(Recommender algo, Map<Measure, Double> ms) {

	String result = Recommender.getEvalInfo(ms);
	String time = Dates.parse(ms.get(Measure.TrainTime).longValue()) + ","
			+ Dates.parse(ms.get(Measure.TestTime).longValue());
	String evalInfo = String.format("%s,%s,%s,%s", algo.algoName, result, algo.toString(), time);

	Logs.info(evalInfo);
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:13,代码来源:LibRec.java

示例13: run_category_ratings

import happy.coding.io.Logs; //导入依赖的package包/类
/**
 * Concate all the dvd ratings about the products in a specific category
 * 
 * @param url
 * @throws Exception
 */
public void run_category_ratings(String url) throws Exception {
	String[] data = url.split(": ");
	String category = data[0];

	String catPath = FileIO.makeDirPath(desktop, domain, category);
	File Dir = new File(catPath);
	File[] prodDirs = Dir.listFiles();
	int tk = prodDirs.length;

	String ratingFile = catPath + "movie-ratings.txt";
	FileIO.deleteFile(ratingFile);

	for (int k = 0; k < tk; k++) {
		File prodDir = prodDirs[k];
		// for each product
		String productID = prodDir.getName();
		if (productID.equals("webPages"))
			continue;
		if (!prodDir.isDirectory())
			continue;

		Logs.debug("{}: {} ({}/{})", new Object[] { category, productID,
				(k + 1), tk });

		String prodPath = FileIO.makeDirPath(catPath, productID);
		String dvdPath = prodPath + "dvd-ratings.txt";
		if (!FileIO.exist(dvdPath))
			continue;

		List<String> dvd_ratings = FileIO.readAsList(dvdPath);

		FileIO.writeList(ratingFile, dvd_ratings, null, true);
	}
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:41,代码来源:CiaoCrawler.java

示例14: statistics

import happy.coding.io.Logs; //导入依赖的package包/类
/**
 * Compute the statistics of the CiaoDVDs dataset
 * 
 * @param dirPath
 *            the directory path of the dataset
 * @throws Exception
 */
@Test
public void statistics() throws Exception {
	// movie ratings: {user, movie, rating}
	Table<String, String, Integer> ratings = loadRatingSet(ratingSet);

	Multiset<Integer> scales = HashMultiset.create();
	scales.addAll(ratings.values());
	Logs.info("Movie rating scales:");
	Logs.info(scales.toString());
	Logs.info("Users: {}, movies: {}, ratings: {}\n", new Object[] {
			ratings.rowKeySet().size(), ratings.columnKeySet().size(),
			ratings.size() });

	// review ratings: {user, review, rating}
	Table<String, String, Integer> reviews = loadReviewSet(reviewSet);
	scales.clear();
	scales.addAll(reviews.values());
	Logs.info("Movie review scales:");
	Logs.info(scales.toString());
	Logs.info("Users: {}, reviews: {}, ratings: {}\n", new Object[] {
			reviews.rowKeySet().size(), reviews.columnKeySet().size(),
			reviews.size() });

	// trust ratings: {trustor, trustee, rating}
	Table<String, String, Integer> trusts = loadTrustSet(trustSet);
	Logs.info("Trustors: {}, trustees: {}, trusts: {}\n",
			new Object[] { trusts.rowKeySet().size(),
					trusts.columnKeySet().size(), trusts.size() });

	Set<String> users = new HashSet<>();
	users.addAll(ratings.rowKeySet());
	users.addAll(reviews.rowKeySet());
	users.addAll(trusts.rowKeySet());
	users.addAll(trusts.columnKeySet());
	Logs.info("Overall users: {}", users.size());

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

示例15: crawl_data

import happy.coding.io.Logs; //导入依赖的package包/类
public static void crawl_data() throws Exception
{
	String filePath = FileIO.getResource("gewara.txt");

	List<String> urls = FileIO.readAsList(filePath);
	String[] tasks = { "comments" };

	int nd = 4;
	for (String task : tasks)
	{
		Logs.info("Current task: " + task);
		for (int i = 0; i < urls.size(); i += nd)
		{
			Thread[] tds = new Thread[nd];

			boolean flag = false;
			for (int j = 0; j < nd; j++)
			{
				if (i + j >= urls.size())
				{
					flag = true;
					break;
				}

				String url = urls.get(i + j).trim();
				tds[j] = new Thread(new GewaraCrawler(url, task, i + j + 1));
				tds[j].start();
			}

			for (Thread td : tds)
			{
				if (td != null) td.join();
			}

			if (flag) break;
		}
	}
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:39,代码来源:GewaraCrawler.java


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