add some files needed by open source projects

This commit is contained in:
nigel 2016-09-02 20:58:45 +08:00
parent 72c5414b4f
commit 55686da42a
30 changed files with 323 additions and 3 deletions

5
AUTHORS.md Normal file
View File

@ -0,0 +1,5 @@
# List of authors involved in developing rec
Xunhui Zhang, zhangxunhui9368@sina.com
Yarong Zeng, 1207296860@qq.com
# Companies involved
NUDT (National University of Defense and Technology)

21
LICENSE.md Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Dockerfile Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

14
Lucene.ABOUT Normal file
View File

@ -0,0 +1,14 @@
name: ik-analyzer
license_spdx: Apache License 2.0
copyright: The Apache Software Foundation
version: 5.0
spec_version: 1.0
download_url: http://download.csdn.net/detail/ai24387511/9443523
home_url: https://code.google.com/archive/p/ik-analyzer/
# when was this ABOUT file created or last updated?
date: 2016-09-02
# files inside this folder and sub-folders
about_resource: lib/IKAnalyzer-5.0.jar

50
README.md Executable file
View File

@ -0,0 +1,50 @@
##this project is mainly used to get the github software recommendation of stackoverflow users
The project mainly consists of five parts
1. the dao(com.ow2.rec.dao) part is the operation of database, which includes:
1) ProjectDao: this is the operation of Github projects
2) SOFFilterDao: this is the operation of filtering the stackoverflow users
3) TagDao: this is the operation of stackoverflow tags
4) UserTagDao: this is the operation of the middle result table, which names user_tags
5) MatchResultDao: this is the operation of processing the match result of stackoverflow users and github projects
2. the lucene(com.ow2.rec.lucene) part includes all the operations relating to lucene, which includes:
1) LuceneIndex: create index
2) LuceneSearch: search projects using lucene index
3. the main(com.ow2.rec.main) part includes all the entrances of "main" functions, which includes:
1) FilterUsers: this is the entrance which used to filter stackoverflow users(those who is not that active in stackoverflow)
2) IndexMain: this is the entrance of creating lucene index
3) Main: this is the entrance of creating queries and calculate relation scores between stackoverflow users and github projects
4) Match: this is auxiliary class for Main class
5) GetGreatPrj: this is used to get projects with high activeness after getting the match result
4. the model(com.ow2.rec.model) part includes all the models used in the whole process:
1) MatchItem: this is the model corresponding to the match result
2) Project: this model is corresponding to Github projects
3) Tag: this model is corresponding to the stackoverflow Tags table
4) User: this model is corresponding to the stackoverflow Users table
5) UserTag: this model is correponding to the middle result table called user_tags, which is used to store the relation between stackoverflow users and their related tags
5. the util(com.ow2.rec.util) part is the auxiliary part:
1) Normalizer: this class is used to normalize the data that we used in the process, which includes the operation of tag, string, number and etc
2) SimilarityCounter: this class is used to calculate the similarity between two texts
##to run the project, we need the following database tables:
1. user_tags1~user_tags12: these tables are used to store the statistical middle result of stackoverflow users ,posts and tags
structure: Id, UserId, PostId, Tag, Updatetime
2. Users: this is the users table of stackoverflow
3. user_tags: this table is used to store the stackoverflow user id and their related tags
structure: Id, UserId, AllTags(eg:<file-io,java>)
4. watchers: this is the watchers table of github
5. stackoverflow_users: this table is used to store users of stackoverflow after filtering
structure: same structure as Users
6. projects: this is the projects table of github
##the database we used in this project is stackoverflow. If you want to change the name, modify applicationContext.xml applicationContext_mybatis.xml in src/main/resources and the java files in com.ow2.rec.datasource

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.dao;
import java.util.List;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.dao;
import java.util.List;

View File

@ -0,0 +1,28 @@
//Copyright (c) 2016 Xunhui Zhang, NUDT.
package com.ow2.rec.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.ow2.rec.model.User;
public interface SOFFilterDao {
//读取用户参与的帖子数目
@Select("select count(distinct PostId) from ${table} where UserId=#{UserId}")
public int getPostNum(@Param("table") String table, @Param("UserId") int UserId);
//获取Users表最大的id
@Select("select max(Id) from Users")
public int getMaxId();
//转存数据 从Users表将对应Id的数据转移到stackoverflow_users表中
@Select("select * from Users where Id=#{id}")
public User getUserById(@Param("id") int id);
@Insert("insert into stackoverflow_users values (#{user.Id}, #{user.Reputation}, #{user.CreationDate}, #{user.DisplayName}, "
+ "#{user.LastAccessDate}, #{user.WebsiteUrl}, #{user.Location}, #{user.AboutMe}, #{user.Views}, #{user.UpVotes}, #{user.DownVotes},"
+ "#{user.ProfileImageUrl}, #{user.Age}, #{user.AccountId})")
public void insertUser(@Param("user") User user);
}

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.dao;
import java.util.List;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.dao;
import java.util.List;
@ -14,5 +15,7 @@ public interface UserTagDao {
@Select("select max(Id) from user_tags")
public Integer getMaxId();
@Select("select UserId, AllTags from user_tags where UserId=#{UserId}")
public UserTag getSingleUserTag(@Param("UserId") int UserId);
}

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.datasource;
import org.springframework.stereotype.Component;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.datasource;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.datasource;
public enum DataSources {

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.datasource;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

View File

@ -1,4 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.lucene;
import java.io.IOException;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.lucene;
import java.io.IOException;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.lucene;
import java.io.IOException;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.lucene;
import java.io.IOException;
@ -37,7 +38,7 @@ import com.ow2.rec.dao.ProjectDao;
import com.ow2.rec.dao.TagDao;
import com.ow2.rec.model.Project;
@Component
@Component("lucenesearch")
public class LuceneSearch {
@Resource

View File

@ -0,0 +1,71 @@
//Copyright (c) 2016 Xunhui Zhang, NUDT.
package com.ow2.rec.main;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import com.ow2.rec.dao.SOFFilterDao;
import com.ow2.rec.dao.UserTagDao;
import com.ow2.rec.lucene.LuceneSearch;
import com.ow2.rec.model.User;
import com.ow2.rec.model.UserTag;
@Component
public class FilterUsers {
@Resource
private SOFFilterDao filterDao;
@Resource
private UserTagDao userTagDao;
@Autowired
private LuceneSearch luceneSearch;
//筛选参与了10个帖子的用户
public void start(){
int startId = 1; //从第一个用户开始处理
int maxId = filterDao.getMaxId();
int count = 0; //用于记录一共删选出多少个用户
while(startId <= maxId){
//读取对应id的用户在UserTag_n表中是否有十条以上帖子参与程度
String tableName = luceneSearch.getTargetTable(startId);
//判断是否有tag
UserTag userTag = userTagDao.getSingleUserTag(startId);
if(userTag == null){
startId++;
continue;
}
if(userTag.getAllTags().length() < 3){
//表示一个标签都没有
startId++;
continue;
}
int postNum = filterDao.getPostNum(tableName, startId);
if(postNum > 10){
count++;
//将用户信息存入数据库 stackoverflow_users表中
User user = filterDao.getUserById(startId);
filterDao.insertUser(user);
}
startId++;
}
System.out.println("共筛选出 " + count + " 个用户");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/applicationContext*.xml");
FilterUsers mainClass = applicationContext.getBean(FilterUsers.class);
mainClass.start();
}
}

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.main;
import java.util.ArrayList;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.main;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.main;
import java.text.DecimalFormat;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.main;
import java.io.IOException;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.main;
import java.util.LinkedList;
import java.util.List;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.model;
public class MatchItem {

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.model;
public class Project {

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.model;
public class Tag {

View File

@ -0,0 +1,107 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.model;
public class User {
private int Id;
private String Reputation;
private String CreationDate;
private String DisplayName;
private String LastAccessDate;
private String WebsiteUrl;
private String Location;
private String AboutMe;
private int Views;
private int UpVotes;
private int DownVotes;
private String ProfileImageUrl;
private int Age;
private int AccountId;
public int getId() {
return Id;
}
public void setId(int id) {
Id = id;
}
public String getReputation() {
return Reputation;
}
public void setReputation(String reputation) {
Reputation = reputation;
}
public String getCreationDate() {
return CreationDate;
}
public void setCreationDate(String creationDate) {
CreationDate = creationDate;
}
public String getDisplayName() {
return DisplayName;
}
public void setDisplayName(String displayName) {
DisplayName = displayName;
}
public String getLastAccessDate() {
return LastAccessDate;
}
public void setLastAccessDate(String lastAccessDate) {
LastAccessDate = lastAccessDate;
}
public String getWebsiteUrl() {
return WebsiteUrl;
}
public void setWebsiteUrl(String websiteUrl) {
WebsiteUrl = websiteUrl;
}
public String getLocation() {
return Location;
}
public void setLocation(String location) {
Location = location;
}
public String getAboutMe() {
return AboutMe;
}
public void setAboutMe(String aboutMe) {
AboutMe = aboutMe;
}
public int getViews() {
return Views;
}
public void setViews(int views) {
Views = views;
}
public int getUpVotes() {
return UpVotes;
}
public void setUpVotes(int upVotes) {
UpVotes = upVotes;
}
public int getDownVotes() {
return DownVotes;
}
public void setDownVotes(int downVotes) {
DownVotes = downVotes;
}
public String getProfileImageUrl() {
return ProfileImageUrl;
}
public void setProfileImageUrl(String profileImageUrl) {
ProfileImageUrl = profileImageUrl;
}
public int getAge() {
return Age;
}
public void setAge(int age) {
Age = age;
}
public int getAccountId() {
return AccountId;
}
public void setAccountId(int accountId) {
AccountId = accountId;
}
}

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.model;
public class UserTag {

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.util;
import java.io.IOException;

View File

@ -1,3 +1,4 @@
//Copyright (c) 2016 Yarong Zeng, NUDT.
package com.ow2.rec.util;
import java.util.HashSet;