本文整理汇总了Java中happy.coding.system.Dates类的典型用法代码示例。如果您正苦于以下问题:Java Dates类的具体用法?Java Dates怎么用?Java Dates使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dates类属于happy.coding.system包,在下文中一共展示了Dates类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultInstance
import happy.coding.system.Dates; //导入依赖的package包/类
private void defaultInstance() {
props.setProperty("mail.debug", "false");
final String userName = "[email protected]";
final String password = "[email protected]";
props.setProperty("mail.smtp.user", userName);
props.setProperty("mail.smtp.password", password);
props.setProperty("mail.from", userName);
props.setProperty("mail.to", "[email protected]");
props.setProperty("mail.subject", "Program Notifier from Gmail");
props.setProperty("mail.text", "Program was finished @" + Dates.now());
Session.getDefaultInstance(props, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
});
}
示例2: initFolders
import happy.coding.system.Dates; //导入依赖的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();
}
}
示例3: printEvalInfo
import happy.coding.system.Dates; //导入依赖的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);
}
示例4: notifyMe
import happy.coding.system.Dates; //导入依赖的package包/类
/**
* @throws Exception
*
*/
private static void notifyMe(String dest) throws Exception {
if (!cf.isOn("is.email.notify"))
return;
EMailer notifier = new EMailer();
Properties props = notifier.getProps();
props.setProperty("mail.debug", "false");
String host = cf.getString("mail.smtp.host");
String port = cf.getString("mail.smtp.port");
props.setProperty("mail.smtp.host", host);
props.setProperty("mail.smtp.port", port);
props.setProperty("mail.smtp.auth", cf.getString("mail.smtp.auth"));
props.put("mail.smtp.socketFactory.port", port);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
final String user = cf.getString("mail.smtp.user");
final String pwd = cf.getString("mail.smtp.password");
props.setProperty("mail.smtp.user", user);
props.setProperty("mail.smtp.password", pwd);
props.setProperty("mail.from", user);
props.setProperty("mail.to", cf.getString("mail.to"));
props.setProperty("mail.subject", FileIO.getCurrentFolder() + "." + algorithm + " [" + Systems.getIP() + "]");
props.setProperty("mail.text", "Program was finished @" + Dates.now());
String msg = "Program [" + algorithm + "] has been finished !";
notifier.send(msg, dest);
}
示例5: reportProgress
import happy.coding.system.Dates; //导入依赖的package包/类
protected void reportProgress(int size) {
int step = params.RUNTIME_PROGRESS_STEP;
if (size < step)
step = size / 5;
++progress;
if (step > 0 && progress % step == 0) {
sw.stop();
long remaining = (long) ((size - progress + 0.0) / step * sw.elapsed(TimeUnit.MILLISECONDS));
Logs.debug("{} progress: {}/{}, remaining {}", new Object[] { Thread.currentThread().getName(), progress,
size, Dates.parse(remaining) });
sw.start();
}
}
示例6: collectResults
import happy.coding.system.Dates; //导入依赖的package包/类
public static void collectResults() throws Exception
{
String mode = params.BATCH_RUN ? DatasetMode.batch.label : params.DATASET_MODE.label;
String program = methodId + " [" + mode + "]";
/* Collect result files to specific directory */
Path source = FileSystems.getDefault().getPath("results.txt");
Path target = FileSystems.getDefault().getPath(
FileIO.makeDirectory(AbstractCF.params.RESULTS_DIRECTORY + Dataset.LABEL) + program + "@"
+ Dates.now() + ".txt");
Files.copy(source, target);
if (params.BATCH_RUN && params.numRunMethod > 1 && numRunMethod < params.numRunMethod) FileIO.empty(source
.toString());
/* Send email to notify results */
if (params.EMAIL_NOTIFICATION)
{
String text = FileIO.readAsString(source.toString());
Gmailer notifier = new Gmailer();
//notifier.getProps().setProperty("mail.to", "[email protected]");
//notifier.getProps().setProperty("mail.to", "[email protected]");
notifier.getProps().setProperty("mail.to", "[email protected]");
//notifier.getProps().setProperty("mail.bcc", "[email protected]");
notifier.getProps()
.setProperty("mail.subject", Dataset.LABEL + ": " + program + " From " + Systems.getIP());
notifier.send(text, target.toString());
}
}
示例7: printSpecs
import happy.coding.system.Dates; //导入依赖的package包/类
public void printSpecs() {
Logs.info("Starts at {}", Dates.now());
Logs.info(null);
String suffix = Strings.repeat('-', 22);
Logs.info(suffix + " Global Setting " + suffix);
Logs.info("Currently data set = {} ({})", Dataset.LABEL, Dataset.DIRECTORY);
Logs.info("Validation approach = {}", VALIDATE_METHOD.name());
Logs.info("Prediction method = {}", PREDICT_METHOD.name());
Logs.info("Calculate similarity = {}", params.SIMILARITY_METHOD);
Logs.info(null);
Logs.info(suffix + " Method Results " + suffix);
}
示例8: notifyMe
import happy.coding.system.Dates; //导入依赖的package包/类
/**
* copy result file (default: "results.txt") to destination fold (default: "./Results"), and then notify me by email
*
*
* @param algo
* the algorithm or method executed
*
* @param mailTo
* the email address of receiver
* @param isNotify
* whether to notify me by Gmail
*
* @throws Exception
*/
public static void notifyMe(String algo, String mailTo, boolean isNotify) throws Exception {
String destPath = FileIO.makeDirectory("Results");
String dest = destPath + algo + "@" + Dates.now() + ".txt";
FileIO.copyFile("results.txt", dest);
if (isNotify) {
Gmailer notifier = new Gmailer();
notifier.getProps().setProperty("mail.to", mailTo);
notifier.getProps().setProperty("mail.subject",
FileIO.getCurrentFolder() + "." + algo + "@" + Systems.getIP());
notifier.send("Program [" + algo + "] has been finished !", dest);
}
}
示例9: main
import happy.coding.system.Dates; //导入依赖的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);
}
示例10: main
import happy.coding.system.Dates; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Logs.config(FileIO.getResource("log4j.properties"), false);
conf = new Configer("tp.conf");
dataset = conf.getString("dataset");
testView = conf.getString("test.view");
dirPath = FileIO.makeDirPath(conf.getPath("dataset.dir"), dataset);
switch (conf.getString("method")) {
case "ETAF":
ETAF tm = new ETAF();
for (Float alpha : conf.getRange("val.ETAF.alpha")) {
// alpha for trust combination
tm.alpha = alpha.floatValue();
for (Float gamma : conf.getRange("val.ETAF.gamma")) {
// gamma for ability combination
tm.gamma = gamma.floatValue();
tm.isIn = conf.isOn("is.ETAF.in");
if (tm.isIn) {
for (Float eta : conf.getRange("val.ETAF.eta")) {
// eta for integrity combination
tm.eta = eta.floatValue();
Logs.debug("Settings: alpha = {}, gamma = {}, eta = {}, in = {}",
new Object[] { alpha.floatValue(), gamma.floatValue(), eta.floatValue(), tm.isIn });
settings = alpha + sep + gamma + sep + eta + sep + tm.isIn;
tm.execute();
}
} else {
// not to consider integrity at all
tm.eta = 1f;
Logs.debug("Settings: alpha = {}, gamma = {}, in = {}", new Object[] { alpha.floatValue(),
gamma.floatValue(), tm.isIn });
settings = alpha + sep + gamma + sep + tm.isIn;
tm.execute();
}
}
}
break;
case "TAF":
new TAF().execute();
break;
case "EPT":
EPT ept = new EPT();
List<Float> Nmins = conf.getRange("num.EPT.Nmin");
for (Float n : Nmins) {
ept.Nmin = n.intValue();
Logs.debug("Settings: Nmin = {}", ept.Nmin);
settings = "" + ept.Nmin;
ept.execute();
}
break;
default:
break;
}
String destPath = FileIO.makeDirectory(dirPath, "Results");
String dest = destPath + model + "@" + Dates.now() + ".txt";
FileIO.copyFile("results.txt", dest);
if (conf.isOn("is.email.notify")) {
Gmailer notifier = new Gmailer();
notifier.getProps().setProperty("mail.to", "[email protected]");
notifier.getProps().setProperty("mail.subject",
FileIO.getCurrentFolder() + "-" + model + " is finished @ " + Systems.getIP());
notifier.send("Program " + model + " has been finished!", dest);
}
}
示例11: printEvalInfo
import happy.coding.system.Dates; //导入依赖的package包/类
private void printEvalInfo(long trainTime, long testTime) throws IOException {
String result = getEvalInfo(measures, numIters);
measures.put(Measure.TrainTime, (double) trainTime);
measures.put(Measure.TestTime, (double) testTime);
String evalInfo = result + "\nTime: " + Dates.parse(measures.get(Measure.TrainTime).longValue()) + ", "
+ Dates.parse(measures.get(Measure.TestTime).longValue());
resultPW.println(evalInfo);
resultPW.flush();
}