提交 e2ac8a52 编写于 作者: T Tom Qian

sth new

sth new
上级 2b43a98e
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/res"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RecommandSystem</name>
<name>TomNewsRecommender</name>
<comment></comment>
<projects>
</projects>
......@@ -10,6 +10,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
......@@ -18,6 +23,7 @@
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//res/log4j.properties=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
......
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
</faceted-project>
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
2017-12-11 22:41:54 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:41:54 [ main:8 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:41:54 [ main:16 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:41:54 [ main:23 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:44:40 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:44:40 [ main:12 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:44:40 [ main:24 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:44:40 [ main:31 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:46:24 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:46:24 [ main:5 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:46:24 [ main:12 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:46:51 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:46:51 [ main:15 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:46:51 [ main:17 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:48:01 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:48:01 [ main:10 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:48:01 [ main:19 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:48:32 [ main:1 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:48:32 [ main:11 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:48:32 [ main:18 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:48:43 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:48:43 [ main:2 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:50:20 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:50:20 [ main:5 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:50:24 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:50:24 [ main:3 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:50:40 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:50:40 [ main:4 ] - [ ERROR ] 数据库连接初始化错误!
2017-12-11 22:51:24 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:51:37 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
2017-12-11 22:52:04 [ main:0 ] - [ ERROR ] 读取属性文件--->失败!- 原因:文件路径错误或者文件不存在
文件模式从 100644 更改为 100755
url = jdbc:mysql://121.42.36.199/recommender-system?useUnicode=true&characterEncoding=utf8
url = jdbc:mysql://121.42.36.199:3306/tom_recommender?useUnicode=true&characterEncoding=utf8
user = root
password = qxysay1+1=2
\ No newline at end of file
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
package top.qianxinyao.Main;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
......@@ -12,72 +12,132 @@ import top.qianxinyao.algorithms.PropGetKit;
import top.qianxinyao.algorithms.RecommendKit;
import top.qianxinyao.contentbasedrecommend.ContentBasedRecommender;
import top.qianxinyao.contentbasedrecommend.quartz.CBCronTriggerRunner;
import top.qianxinyao.dbconnection.DBKit;
import top.qianxinyao.hotrecommend.HotRecommender;
import top.qianxinyao.hotrecommend.quartz.HRCronTriggerRunner;
import top.qianxinyao.model.Users;
/**
* @author Tom Qian
* @email tomqianmaple@outlook.com
* @github https://github.com/bluemapleman
* @date 2017年12月11日
* 使用Quartz库设定推荐系统每天固定的工作时间(默认为每天0点开始工作)
* 当启用该类时,推荐系统可以保持运行,直到被强制关闭。
* 设定/启动推荐任务的类
*/
public class JobSetter
{
public static final Logger logger=Logger.getLogger(JobSetter.class);
boolean enableCF,enableCB,enableHR;
/**
* 使用Quartz的表达式进行时间设定,详情请参照:http://www.quartz-scheduler.org/api/2.2.1/index.html(CronExpression)
* 参数forActiveUsers表示是否只针对活跃用户进行新闻推荐,true为是,false为否。
* @param forActiveUsers
*
* @param enableCF 是否启用协同过滤(Collaborative Filtering)
* @param enableCB 是否启用基于内容的推荐(Content-Based Recommendation)
* @param enableHR 是否启用热点新闻推荐(Hot News Recommendation)
*/
public void executeQuartzJob(boolean forActiveUsers) {
public JobSetter(boolean enableCF,boolean enableCB,boolean enableHR) {
//加载系统配置文件
PropGetKit.loadProperties("paraConfig");
List<Users> userList=forActiveUsers?RecommendKit.getActiveUsers():RecommendKit.getAllUsers();
//初始化操作:主要是数据库的连接
DBKit.initalize();
this.enableCF=enableCF;
this.enableCB=enableCB;
this.enableHR=enableHR;
}
/**
* 使用Quartz的表达式进行时间设定(默认为每天0点开始工作),详情请参照:http://www.quartz-scheduler.org/api/2.2.1/index.html(CronExpression)
* 当启用该方法时,推荐系统可以保持运行,直到被强制关闭。
* @param userList
*/
private void executeQuartzJob(List<Long> userList) {
//设定推荐任务每天的执行时间
String cronExpression=PropGetKit.getString("startAt");
try
{
new CFCronTriggerRunner().task(userList,cronExpression);
new CBCronTriggerRunner().task(userList,cronExpression);
new HRCronTriggerRunner().task(userList,cronExpression);
if(enableCF)
new CFCronTriggerRunner().task(userList,cronExpression);
if(enableCB)
new CBCronTriggerRunner().task(userList,cronExpression);
if(enableHR)
new HRCronTriggerRunner().task(userList,cronExpression);
}
catch (SchedulerException e)
{
e.printStackTrace();
}
logger.info("本次推荐结束!");
System.out.println("本次推荐结束于"+new Date());
}
/**
* 为指定用户执行定时新闻推荐
* @param goalUserList 目标用户的id列表
*/
public void executeQuartzJobForCertainUsers(List<Long> goalUserList) {
executeQuartzJob(goalUserList);
}
/**
* 为所有用户执行定时新闻推荐
*/
public void executeQuartzJobForAllUsers() {
executeQuartzJob(RecommendKit.getAllUsers());
}
/**
* 为活跃用户进行定时新闻推荐。
* @param goalUserList
*/
public void executeQuartzJobForActiveUsers() {
executeQuartzJob(RecommendKit.getActiveUsers());
}
/**
* 执行一次新闻推荐
* 参数forActiveUsers表示是否只针对活跃用户进行新闻推荐,true为是,false为否。
* @param forActiveUsers
*/
public void executeInstantJob(boolean forActiveUsers) {
//加载系统配置文件
PropGetKit.loadProperties("paraConfig");
List<Users> userList=forActiveUsers?RecommendKit.getActiveUsers():RecommendKit.getAllUsers();
List<Long> userIDList=new ArrayList<Long>();
for(Users user:userList)
userIDList.add(user.getId());
private void executeInstantJob(List<Long> userIDList) {
//让热点新闻推荐器预先生成今日的热点新闻
HotRecommender.formTodayTopHotNewsList();
new MahoutUserBasedCollaborativeRecommender().recommend(userIDList);
new ContentBasedRecommender().recommend(userIDList);
new HotRecommender().recommend(userIDList);
logger.info("本次推荐结束!");
if(enableCF)
new MahoutUserBasedCollaborativeRecommender().recommend(userIDList);
if(enableCB)
new ContentBasedRecommender().recommend(userIDList);
if(enableHR)
new HotRecommender().recommend(userIDList);
System.out.println("本次推荐结束于"+new Date());
}
/**
* 执行一次新闻推荐
* 参数forActiveUsers表示是否只针对活跃用户进行新闻推荐,true为是,false为否。
* @param forActiveUsers
*/
public void executeInstantJobForCertainUsers(List<Long> goalUserList) {
executeInstantJob(goalUserList);
}
/**
* 为所用有用户执行一次新闻推荐
*/
public void executeInstantJobForAllUsers() {
executeInstantJob(RecommendKit.getAllUsers());
}
/**
* 为活跃用户进行一次推荐。
* @param goalUserList
*/
public void executeInstantJobForActiveUsers() {
executeInstantJob(RecommendKit.getActiveUsers());
}
}
/**
*
*/
package top.qianxinyao.Main;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import top.qianxinyao.algorithms.PropGetKit;
import top.qianxinyao.dbconnection.DBKit;
/**
* @author qianxinyao
* @email tomqianmaple@gmail.com
* @github https://github.com/bluemapleman
* @date 2016年10月20日
* 推荐系统入口类,在此启动推荐系统。
*/
public class Main
{
public static final Logger logger = Logger.getLogger(Main.class);
// static ResultSet rs=null;
/**
* 推荐系统运行入口
* @param args
* @throws SQLException
*/
public static void main(String[] args) throws SQLException
public static void main(String[] args)
{
//加载系统配置文件
PropGetKit.loadProperties("paraConfig");
//在测试数据上运行
new TestDataRunner().runTestData();
//初始化操作:主要是数据库的连接
DBKit.initalize();
new JobSetter().executeInstantJob(true);
// //选择要在推荐系统中运行的推荐算法
// boolean enableCF=false,enableCB=false,enableHR=true;
//
// List<Long> userList=new ArrayList<Long>();
// userList.add(1l);
// userList.add(2l);
// userList.add(3l);
//
//
//
// //为指定用户执行一次推荐
// new JobSetter(enableCF,enableCB,enableHR).executeInstantJobForCertainUsers(userList);
// //为活跃用户执行定时推荐
//// new JobSetter(enableCF,enableCB,enableHR).executeQuartzJobForActiveUsers();
}
}
......@@ -17,9 +17,9 @@ import top.qianxinyao.dbconnection.DBKit;
import top.qianxinyao.model.News;
import top.qianxinyao.model.Newsmodules;
public class TestDataProcessor{
public class NewsScraper{
public static final Logger logger=Logger.getLogger(TestDataProcessor.class);
public static final Logger logger=Logger.getLogger(NewsScraper.class);
/**
* 从新闻门户抓取一次新闻
......
package top.qianxinyao.Main;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.jfinal.plugin.activerecord.Db;
import top.qianxinyao.algorithms.RecommendKit;
/**
* @author Tom Qian
* @email tomqianmaple@outlook.com
* @github https://github.com/bluemapleman
* @date 2017年12月13日
*/
public class TestDataRunner
{
public void runTestData() {
System.out.println("开始测试数据的运行!");
//选择要在推荐系统中运行的推荐算法
boolean enableCF=false,enableCB=false,enableHR=true;
JobSetter jobSetter=new JobSetter(enableCF,enableCB,enableHR);
//更新测试数据的时间
databaseReady();
List<Long> userList=new ArrayList<Long>();
userList.add(1l);
userList.add(2l);
userList.add(3l);
//为指定用户执行一次推荐
jobSetter.executeInstantJobForCertainUsers(userList);
System.out.println("测试数据运行结束!");
}
public void databaseReady() {
Db.update("update news set news_time=?",new Date());
for(int id=1;id<8;id++) {
Db.update("update users set latest_log_time=? where id=?",RecommendKit.getInRecTimestamp(25+id),id);
}
Db.update("update newslogs set view_time=?",new Date());
}
}
......@@ -14,8 +14,6 @@ import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.CronTriggerImpl;
import top.qianxinyao.model.Users;
/**
* @author qianxinyao
* @email tomqianmaple@gmail.com
......@@ -24,7 +22,7 @@ import top.qianxinyao.model.Users;
*/
public class CFCronTriggerRunner
{
public void task(List<Users> users,String cronExpression) throws SchedulerException
public void task(List<Long> users,String cronExpression) throws SchedulerException
{
// Initiate a Schedule Factory
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
......
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
......@@ -278,13 +278,16 @@ public class RecommendKit
*
* @return
*/
public static List<Users> getActiveUsers()
public static List<Long> getActiveUsers()
{
try
{
int activeDay=PropGetKit.getInt("activeDay");
List<Users> userList=Users.dao.find("select distinct id,name from users where latest_log_time>" + getInRecDate(activeDay));
return userList;
List<Long> userIDList=new ArrayList<Long>();
for(Users user:userList)
userIDList.add(user.getId());
return userIDList;
}
catch (Exception e)
{
......@@ -295,11 +298,14 @@ public class RecommendKit
return null;
}
public static List<Users> getAllUsers(){
public static List<Long> getAllUsers(){
try
{
List<Users> userList=Users.dao.find("select distinct id,name from users");
return userList;
List<Long> userIDList=new ArrayList<Long>();
for(Users user:userList)
userIDList.add(user.getId());
return userIDList;
}
catch (Exception e)
{
......
文件模式从 100644 更改为 100755
......@@ -14,8 +14,6 @@ import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.CronTriggerImpl;
import top.qianxinyao.model.Users;
/**
* @author qianxinyao
* @email tomqianmaple@gmail.com
......@@ -24,7 +22,7 @@ import top.qianxinyao.model.Users;
*/
public class CBCronTriggerRunner
{
public void task(List<Users> users,String cronExpression) throws SchedulerException
public void task(List<Long> users,String cronExpression) throws SchedulerException
{
// Initiate a Schedule Factory
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
......
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
......@@ -14,8 +14,6 @@ import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.CronTriggerImpl;
import top.qianxinyao.model.Users;
/**
* @author qianxinyao
* @email tomqianmaple@gmail.com
......@@ -24,7 +22,7 @@ import top.qianxinyao.model.Users;
*/
public class HRCronTriggerRunner
{
public void task(List<Users> users,String cronExpression) throws SchedulerException
public void task(List<Long> users,String cronExpression) throws SchedulerException
{
// Initiate a Schedule Factory
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
......
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
#Generated by Maven Integration for Eclipse
#Mon Dec 11 21:12:02 CST 2017
#Fri Mar 02 17:24:53 CST 2018
version=0.0.1-SNAPSHOT
groupId=top.tomqian
m2e.projectName=Recommender System
m2e.projectLocation=/Users/hanbo/Desktop/\u8FB9\u57CE/work_space/Recommender System
m2e.projectName=RecommandSystem
m2e.projectLocation=/Users/hanbo/Desktop/NewsRecommendSystem-master
artifactId=recommender-system
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册