package com.qmth.qrzk.repository.user.model;

import com.qmth.qrzk.repository.utils.StringSimilarityUtils;

/**
 * 
 * <p>
 * 相似题实体类
 * </p>
 * 
 * @author songyue
 * @date 2016-05-12
 */
public class SimilarQuestion implements Comparable<SimilarQuestion>{
	private String similarQuestionNo;// 题目编号
	private String similarQuestionId;// 题目ID
	private String similarQuestionName;// 题目名称（题型＋sortNo）
	private String similarQuestionBody;// 题干摘要
	private String similarity;// 相似度
	private String courseNo;//课程编号
	private String courseName;//课程名称
	private String bookName;//教材名称
	private String typeName;
	private Integer courseId;
	private String similarPaperNo;// 试卷编号 辅助字段

	public String getSimilarQuestionNo() {
		return similarQuestionNo;
	}

	public void setSimilarQuestionNo(String similarQuestionNo) {
		this.similarQuestionNo = similarQuestionNo;
	}

	public String getSimilarQuestionName() {
		return similarQuestionName;
	}

	public void setSimilarQuestionName(String similarQuestionName) {
		this.similarQuestionName = similarQuestionName;
	}

	public String getSimilarQuestionBody() {
		return similarQuestionBody;
	}

	public void setSimilarQuestionBody(String similarQuestionBody) {
		this.similarQuestionBody = similarQuestionBody;
	}

	public String getSimilarity() {
		return similarity;
	}

	public void setSimilarity(String similarity) {
		this.similarity = similarity;
	}

	/**
	 * 
	 * <p>对比相似度，获取相似度范围</p>
	 * @author songyue
	 * @date 2016-05-16
	 */
	public int checkSimilarity(SimilarQuestion o) {
		 double similarity = StringSimilarityUtils.getSimilarityWithCosinesByWords(this.getSimilarQuestionBody(), o.getSimilarQuestionBody())*100;
		if(similarity>=60 && similarity < 70){
			return 60;
		}else if(similarity>=70 && similarity < 80){
			return 70;
		}else if(similarity>=80 && similarity < 90){
			return 80;
		}else if(similarity>=90 && similarity <= 100){
			return 90;
		}else{
			return -1;
		}
	}

	@Override
	public int compareTo(SimilarQuestion o) {
		// TODO Auto-generated method stub
		if(Double.parseDouble(this.getSimilarity()) < Double.parseDouble(o.getSimilarity())){
			return 1;
		}else if(Double.parseDouble(this.getSimilarity()) > Double.parseDouble(o.getSimilarity())){
			return -1;
		}else{
			return 0;
		}
	}

	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	public String getBookName() {
		return bookName;
	}

	public void setBookName(String bookName) {
		this.bookName = bookName;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public String getSimilarQuestionId() {
		return similarQuestionId;
	}

	public void setSimilarQuestionId(String similarQuestionId) {
		this.similarQuestionId = similarQuestionId;
	}

	public Integer getCourseId() {
		return courseId;
	}

	public void setCourseId(Integer courseId) {
		this.courseId = courseId;
	}

	public String getCourseNo() {
		return courseNo;
	}

	public void setCourseNo(String courseNo) {
		this.courseNo = courseNo;
	}

	public String getSimilarPaperNo() {
		return similarPaperNo;
	}

	public void setSimilarPaperNo(String similarPaperNo) {
		this.similarPaperNo = similarPaperNo;
	}
	
}
