Skip to content

Commit

Permalink
sth new
Browse files Browse the repository at this point in the history
sth new
  • Loading branch information
bluemapleman committed Mar 2, 2018
1 parent e2ac8a5 commit e037e46
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public class Main
测试数据中包含以下几个部分:

- users表:7个测试用户
- news表:307个2017-12-12日从网易首页抓取的测试新闻
- news表:306个2017-12-12日从网易首页抓取的测试新闻
- newsmodules表:17个测试模块
- newslogs:测试推荐算法效果用的9条浏览记录

Expand All @@ -200,9 +200,9 @@ new TestDataRunner().runTestData();

1.com.qianxinyao.TomNewsRecommender下的NewsScraper类是抓取网易的测试新闻时用的类,大家也可以用这个类继续采集新闻。该类默认对网易新闻首页的所有新闻进行一次抓取入库。

2. 协同过滤的效果目前不太稳定/可控,因为采用的是Mahout内置的协同过滤工具。一般来说,新闻模块的活跃用户越多,则协同过滤效果越好,也越明显。若有需求,我会在后期自己实现能稳定生成指定数量的推荐结果的协同过滤算法。
2.协同过滤的效果目前不太稳定/可控,因为采用的是Mahout内置的协同过滤工具。一般来说,新闻模块的活跃用户越多,则协同过滤效果越好,也越明显。若有需求,我会在后期自己实现能稳定生成指定数量的推荐结果的协同过滤算法。

3. 一般当协同过滤与基于内容的推荐算法生成的推荐数目不足时,可以用基于热点新闻的推荐进行数量补充。
3.一般当协同过滤与基于内容的推荐算法生成的推荐数目不足时,可以用基于热点新闻的推荐进行数量补充。



Expand Down
6 changes: 3 additions & 3 deletions res/dbconfig.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
url = jdbc:mysql://121.42.36.199:3306/tom_recommender?useUnicode=true&characterEncoding=utf8
user = root
password = qxysay1+1=2
url = jdbc:mysql://[ip]/[database]?useUnicode=true&characterEncoding=utf8
user =
password =
2 changes: 1 addition & 1 deletion src/top/qianxinyao/Main/TestDataRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void runTestData() {
System.out.println("开始测试数据的运行!");

//选择要在推荐系统中运行的推荐算法
boolean enableCF=false,enableCB=false,enableHR=true;
boolean enableCF=false,enableCB=true,enableHR=false;

JobSetter jobSetter=new JobSetter(enableCF,enableCB,enableHR);

Expand Down
4 changes: 2 additions & 2 deletions src/top/qianxinyao/algorithms/JsonKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public static CustomizedHashMap<Integer,CustomizedHashMap<String,Double>> jsonPr
ObjectMapper objectMapper=new ObjectMapper();
CustomizedHashMap<Integer,CustomizedHashMap<String,Double>> map=null;
try
{
{
System.out.println("srcJson:"+srcJson);
map=objectMapper.readValue(srcJson, new TypeReference<CustomizedHashMap<Integer,CustomizedHashMap<String,Double>>>(){});
}
catch (JsonParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (JsonMappingException e)
Expand Down
2 changes: 1 addition & 1 deletion src/top/qianxinyao/algorithms/RecommendKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void filterOutDateNews(Collection<Long> col, Long userId)
String newsids = getInQueryString(col.iterator());
if (!newsids.equals("()"))
{
List<News> newsList = News.dao.find("select news_id,news_time from news where id in " + newsids);
List<News> newsList = News.dao.find("select id,news_time from news where id in " + newsids);
for(News news:newsList)
{
if (news.getNewsTime().before(getInRecTimestamp(beforeDays)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private HashMap<String,Object> getNewsTFIDFMap(){
if(newsIdListQuery.length()>1){
newsIdListQuery=newsIdListQuery.substring(0, newsIdListQuery.length()-1)+")";
//提取出所有新闻的关键词列表及对应TF-IDf值,并放入一个map中
List<News> newsList=News.dao.find("select id,title,content,module_id from news where newsid in "+newsIdListQuery);
List<News> newsList=News.dao.find("select id,title,content,module_id from news where id in "+newsIdListQuery);

newsTFIDFMap=new HashMap<String,Object>();
for(News news:newsList){
Expand Down
Binary file modified target/classes/top/qianxinyao/Main/TestDataRunner.class
Binary file not shown.
Binary file modified target/classes/top/qianxinyao/algorithms/JsonKit$3.class
Binary file not shown.
Binary file modified target/classes/top/qianxinyao/algorithms/JsonKit.class
Binary file not shown.
Binary file modified target/classes/top/qianxinyao/algorithms/RecommendKit.class
Binary file not shown.
Binary file not shown.
18 changes: 10 additions & 8 deletions test_data.sql
100755 → 100644

Large diffs are not rendered by default.

0 comments on commit e037e46

Please sign in to comment.