match_program match_result_table RelativeMemo model

This commit is contained in:
zhanyun 2016-02-29 09:39:48 +08:00
parent e6f03d7436
commit 3a7fe1fa84
5 changed files with 119 additions and 207 deletions

View File

@ -197,12 +197,12 @@ public class LuceneIndex {
List<RelativeMemo> memos = memoDao.getMemoInfo(startId, endId);
for(RelativeMemo memo : memos) {
lastMemoId = memo.getId();
if (memo.getSubject() == null) {
if (memo.getTitle() == null) {
continue;
}
Document doc = new Document();
doc.add(new StringField(memoIdFieldName, String.valueOf(lastMemoId), Store.YES));
doc.add(new TextField(titleFieldName, memo.getSubject(), Store.NO));
doc.add(new TextField(titleFieldName, memo.getTitle(), Store.NO));
String memoTagsString = memo.getTags();
if (memoTagsString == null) {
memoTagsString = "";
@ -253,12 +253,12 @@ public class LuceneIndex {
int rsId = -1;
for(RelativeMemo memo : memos) {
rsId = memo.getId();
if (memo.getSubject() == null) {
if (memo.getTitle() == null) {
continue;
}
Document doc = new Document();
doc.add(new StringField(memoIdFieldName, String.valueOf(rsId), Store.YES));
doc.add(new TextField(titleFieldName, memo.getSubject(), Store.NO));
doc.add(new TextField(titleFieldName, memo.getTitle(), Store.NO));
String memoTagsString = memo.getTags();
if (memoTagsString == null) {
memoTagsString = "";

View File

@ -207,39 +207,46 @@ public class Match {
* @param osp_id
* @return
*/
public static String getTargetTable(int osp_id){
public static String getTargetTable(int ospId){
String targetTableName = "";
if (osp_id < 500) {
targetTableName = "relative_memo_to_open_source_projects_1";
}
else if (osp_id >= 500 && osp_id < 1000) {
targetTableName = "relative_memo_to_open_source_projects_2";
}
else if (osp_id >= 1000 && osp_id < 1500) {
targetTableName = "relative_memo_to_open_source_projects_3";
}
else if (osp_id >= 1500 && osp_id < 2000) {
targetTableName = "relative_memo_to_open_source_projects_4";
}
else if (osp_id >= 2000 && osp_id < 3000) {
targetTableName = "relative_memo_to_open_source_projects_5";
}
else if (osp_id >= 3000 && osp_id < 5000) {
targetTableName = "relative_memo_to_open_source_projects_6";
}
else if (osp_id >= 5000 && osp_id < 7500) {
targetTableName = "relative_memo_to_open_source_projects_7";
}
else if (osp_id >= 7500 && osp_id < 10000) {
targetTableName = "relative_memo_to_open_source_projects_8";
}
else if (osp_id >= 10000 && osp_id < 310000) {
int a = 7 + osp_id/5000;
targetTableName = "relative_memo_to_open_source_projects_" + a;
}
else if (osp_id >= 310000) {
if(ospId >= 770000){
targetTableName = "relative_memo_to_open_source_projects_70";
}
else{
int a = 1 + ospId/11000;
targetTableName = "relative_memo_to_open_source_projects_" + a;
}
// if (osp_id < 500) {
// targetTableName = "relative_memo_to_open_source_projects_1";
// }
// else if (osp_id >= 500 && osp_id < 1000) {
// targetTableName = "relative_memo_to_open_source_projects_2";
// }
// else if (osp_id >= 1000 && osp_id < 1500) {
// targetTableName = "relative_memo_to_open_source_projects_3";
// }
// else if (osp_id >= 1500 && osp_id < 2000) {
// targetTableName = "relative_memo_to_open_source_projects_4";
// }
// else if (osp_id >= 2000 && osp_id < 3000) {
// targetTableName = "relative_memo_to_open_source_projects_5";
// }
// else if (osp_id >= 3000 && osp_id < 5000) {
// targetTableName = "relative_memo_to_open_source_projects_6";
// }
// else if (osp_id >= 5000 && osp_id < 7500) {
// targetTableName = "relative_memo_to_open_source_projects_7";
// }
// else if (osp_id >= 7500 && osp_id < 10000) {
// targetTableName = "relative_memo_to_open_source_projects_8";
// }
// else if (osp_id >= 10000 && osp_id < 310000) {
// int a = 7 + osp_id/5000;
// targetTableName = "relative_memo_to_open_source_projects_" + a;
// }
// else if (osp_id >= 310000) {
// targetTableName = "relative_memo_to_open_source_projects_70";
// }
return targetTableName;
//return "relative_memo_to_open_source_projects";
}
@ -268,13 +275,13 @@ public class Match {
String memoTitle = "";
String memoTags = "";
memoId = memo.getId();
if (memo.getSubject() == null || memo.getSubject().length() == 0) {
if (memo.getTitle() == null || memo.getTitle().length() == 0) {
continue;
}
if (memo.getTags() != null && memo.getTags().length() > 0) {
memoTags = memo.getTags().toLowerCase();
}
memoTitle = memo.getSubject().toLowerCase();
memoTitle = memo.getTitle().toLowerCase();
if (memoTitle.length() == 0) {
continue;
}

View File

@ -1,7 +1,5 @@
package com.ossean.match.model;
import java.util.HashMap;
public class Project {
private int id;
private String url;
@ -12,7 +10,6 @@ public class Project {
private double rank_star = -1.0;
private String tags;
private String source;
private HashMap<String, String> urls;
@Override
public String toString() {
// TODO Auto-generated method stub
@ -43,9 +40,6 @@ public class Project {
public void setSynonyms(String synonyms) {
this.synonyms = synonyms;
}
public void setUrls(HashMap<String, String> urls) {
this.urls = urls;
}
public int getRank(){
return rank;

View File

@ -3,51 +3,32 @@ package com.ossean.match.model;
public class RelativeMemo {
private int id;
private int osp_id;
private String subject;
private String title;
private String content;
private String author;
private int replies_num;
private int lock;
private int sticky;
private String created_time;
private String updated_time;
private String url;
private int view_num_crawled;
private int vote_up_num;
private int collection_num;
private String abstractText;
private String memo_type;
private String source;
private String category;
private int view_num_trustie;
private int author_id;
private int parent_id;
private int last_reply_id;
private int is_quote;
private String username;
private String userhomeurl;
private String crawled_time;
private String author_url;
private String url_md5;
private String type;
private String tags;
private String source;
private String url;
private String url_md5;
private String author;
private String author_url;
private int view_num;
private int review_num;
private int view_num_ossean;
private String extracted_time;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getOsp_id() {
return osp_id;
public String getTitle() {
return title;
}
public void setOsp_id(int osp_id) {
this.osp_id = osp_id;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
@ -55,30 +36,6 @@ public class RelativeMemo {
public void setContent(String content) {
this.content = content;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getReplies_num() {
return replies_num;
}
public void setReplies_num(int replies_num) {
this.replies_num = replies_num;
}
public int getLock() {
return lock;
}
public void setLock(int lock) {
this.lock = lock;
}
public int getSticky() {
return sticky;
}
public void setSticky(int sticky) {
this.sticky = sticky;
}
public String getCreated_time() {
return created_time;
}
@ -91,113 +48,11 @@ public class RelativeMemo {
public void setUpdated_time(String updated_time) {
this.updated_time = updated_time;
}
public String getUrl() {
return url;
public String getType() {
return type;
}
public void setUrl(String url) {
this.url = url;
}
public int getView_num_crawled() {
return view_num_crawled;
}
public void setView_num_crawled(int view_num_crawled) {
this.view_num_crawled = view_num_crawled;
}
public int getVote_up_num() {
return vote_up_num;
}
public void setVote_up_num(int vote_up_num) {
this.vote_up_num = vote_up_num;
}
public int getCollection_num() {
return collection_num;
}
public void setCollection_num(int collection_num) {
this.collection_num = collection_num;
}
public String getAbstractText() {
return abstractText;
}
public void setAbstractText(String abstractText) {
this.abstractText = abstractText;
}
public String getMemo_type() {
return memo_type;
}
public void setMemo_type(String memo_type) {
this.memo_type = memo_type;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getView_num_trustie() {
return view_num_trustie;
}
public void setView_num_trustie(int view_num_trustie) {
this.view_num_trustie = view_num_trustie;
}
public int getAuthor_id() {
return author_id;
}
public void setAuthor_id(int author_id) {
this.author_id = author_id;
}
public int getParent_id() {
return parent_id;
}
public void setParent_id(int parent_id) {
this.parent_id = parent_id;
}
public int getLast_reply_id() {
return last_reply_id;
}
public void setLast_reply_id(int last_reply_id) {
this.last_reply_id = last_reply_id;
}
public int getIs_quote() {
return is_quote;
}
public void setIs_quote(int is_quote) {
this.is_quote = is_quote;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserhomeurl() {
return userhomeurl;
}
public void setUserhomeurl(String userhomeurl) {
this.userhomeurl = userhomeurl;
}
public String getCrawled_time() {
return crawled_time;
}
public void setCrawled_time(String crawled_time) {
this.crawled_time = crawled_time;
}
public String getAuthor_url() {
return author_url;
}
public void setAuthor_url(String author_url) {
this.author_url = author_url;
}
public String getUrl_md5() {
return url_md5;
}
public void setUrl_md5(String url_md5) {
this.url_md5 = url_md5;
public void setType(String type) {
this.type = type;
}
public String getTags() {
return tags;
@ -205,5 +60,59 @@ public class RelativeMemo {
public void setTags(String tags) {
this.tags = tags;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUrl_md5() {
return url_md5;
}
public void setUrl_md5(String url_md5) {
this.url_md5 = url_md5;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getAuthor_url() {
return author_url;
}
public void setAuthor_url(String author_url) {
this.author_url = author_url;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public int getView_num() {
return view_num;
}
public void setView_num(int view_num) {
this.view_num = view_num;
}
public int getReview_num() {
return review_num;
}
public void setReview_num(int review_num) {
this.review_num = review_num;
}
public int getView_num_ossean() {
return view_num_ossean;
}
public void setView_num_ossean(int view_num_ossean) {
this.view_num_ossean = view_num_ossean;
}
public String getExtracted_time() {
return extracted_time;
}
public void setExtracted_time(String extracted_time) {
this.extracted_time = extracted_time;
}
}

View File

@ -65,6 +65,8 @@ public class Normalizer {
public static void main(String []args) {
String content = "大声道Corvette123 *&%9&^&%&^%(*_asd's_12 L'Aur--ore, 1766-1775";
int a = 1 + 11000/11000;
String targetTableName = "relative_memo_to_open_source_projects_" + a;
//System.out.println(StringFilter(content));
String result = content.replaceAll("[^0-9a-zA-Z]"," ");
System.out.println(result);