1.系统源码和使用方法见GitHub链接。。。
https://github.com/snowlixue/wanfangPaperSystem
2.系统爬取数据和清洗的方法见博客https://blog.csdn.net/dreamtheworld1/article/details/80634611
这里没有使用爬取下的全部数据。
3.系统主要用词向量模型来进行相似文章的推荐。 词向量是用来表示词的向量,通常也被认为是词的特征向量。关于词向量推荐可以参照其他博客。
首先使用hanlp包进行实体抽取。hanlp关键词抽取使用的是TextRank方法。
词向量使用Word2VEC进行训练。训练后为.bin .model或无后缀名文件。
这里使用关键词的两个相似词和自身作为基础进行搜索和推荐。
4.系统的故事线生成分为,输入关键词->基于论文内容查询数据库并按时间排序->过滤不合法时间->生成故事线
https://github.com/snowlixue/wanfangPaperSystem
2.系统爬取数据和清洗的方法见博客https://blog.csdn.net/dreamtheworld1/article/details/80634611
这里没有使用爬取下的全部数据。
3.系统主要用词向量模型来进行相似文章的推荐。 词向量是用来表示词的向量,通常也被认为是词的特征向量。关于词向量推荐可以参照其他博客。
首先使用hanlp包进行实体抽取。hanlp关键词抽取使用的是TextRank方法。
词向量使用Word2VEC进行训练。训练后为.bin .model或无后缀名文件。
关键词抽取和推荐代码如下:
Word2VECKeyWords.java
public static String[] getDistanceWord(String word) {
Word2VEC w1 = new Word2VEC() ;
try {
w1.loadJavaModel("D:\\workspace\\eclipse-workspace\\cnki\\library\\AbstractVector") ;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] distance = new String[2];
distance[0] = (w1.distance(word).toArray()[0].toString());
distance[1] = (w1.distance(word).toArray()[1].toString());
return distance;
}
CnkiInfoImpl.java
// TODO Auto-generated method stub
List<Map> selectCnki = new ArrayList<Map>();
//调dao里的方法
List<CnkiinfoPO> updateid = cdao.updateid(po);
String needResult = updateid.get(0).getKeywords();
System.out.println("needResult"+needResult);
Hanlp hanlp = new Hanlp();
List<String> result = hanlp.getkeywords(needResult);
Word2VECKeyWords word2veckeywords = new Word2VECKeyWords();
String distancewords[] = word2veckeywords.getDistanceWord(result.get(0).toString());
System.out.println("distancewords[0]"+distancewords[0]);
System.out.println("distancewords[1]"+distancewords[1]);
Map map1 = new HashMap();
map1.put("keywords", result.get(0).toString());
List<Map> selectCnki1 = cdao.selecttitle(map1);
Map map2 = new HashMap();
map2.put("abstracts", distancewords[0]);
List<Map> selectCnki2 = cdao.selecttitle(map2);
Map map3 = new HashMap();
map3.put("abstracts", distancewords[0]);
List<Map> selectCnki3 = cdao.selecttitle(map3);
//selectCnki.addAll(selectCnki1);
selectCnki1.addAll(selectCnki2);
selectCnki1.addAll(selectCnki3);
return selectCnki1;
}
这里使用关键词的两个相似词和自身作为基础进行搜索和推荐。
4.系统的故事线生成分为,输入关键词->基于论文内容查询数据库并按时间排序->过滤不合法时间->生成故事线
关键代码如下:
cnkiinfo-mapper.xml
<select id="select" resultMap="cnkiinfoMap" parameterType="java.util.Map">
<!-- 用include标签引入sql片段,refid写定义sql片段的id,where标签不要写在片段里 -->
select <include refid="zd"></include> from cnkiinfo
<!-- 当页面没有输入用户名和选择权限,就让它的条件永远为真,就变成全查询了 -->
<where>
<if test="title == null and title = ''">
and 1=1
</if>
<if test="title != null and title !=''">
and title LIKE '%${title}%'
</if>
</where>
<if test="title != null and title !=''">
ORDER BY ${time}
</if>
</select>
SortTime.java
//利用正则删除不符合日期结构的数据
String pattern = "\\d+年\\d+月\\d+日";
for(int i = 0;i<stid.size();i++) {
if(!Pattern.matches(pattern, ((CnkiinfoPO) stid.get(i)).getTime())) {
System.out.println("------------------"+((CnkiinfoPO) stid.get(i)).getTime());
stid.remove(i);
}
}
5.整个系统使用ssm框架。系统实现的难度在与List<Map>和 javabean:CnkiinfoPO容易混淆,导致调用出错。这里的List
内存储的是CnkiinfoPO的编号。用get()取得List后需要转为CnkiinfoPO在调用CnkiinfoPO的get方法获取具体参数