|  | @@ -1,11 +1,11 @@
 | 
	
		
			
				|  |  |  package com.tzld.longarticle.recommend.server.service.rank;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -<<<<<<< HEAD
 | 
	
		
			
				|  |  | -=======
 | 
	
		
			
				|  |  | +<<<<<<<HEAD
 | 
	
		
			
				|  |  | +        =======
 | 
	
		
			
				|  |  |  import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.Content;
 | 
	
		
			
				|  |  | ->>>>>>> e5f14a8 (init)
 | 
	
		
			
				|  |  | +>>>>>>>e5f14a8(init)
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 | 
	
	
		
			
				|  | @@ -16,12 +16,12 @@ import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -<<<<<<< HEAD
 | 
	
		
			
				|  |  | +<<<<<<<HEAD
 | 
	
		
			
				|  |  |  import java.util.Collections;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  =======
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  | ->>>>>>> e5f14a8 (init)
 | 
	
		
			
				|  |  | +>>>>>>>e5f14a8(init)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * @author dyp
 | 
	
	
		
			
				|  | @@ -82,52 +82,4 @@ public class RankService {
 | 
	
		
			
				|  |  |          return scoreParam;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -<<<<<<< HEAD
 | 
	
		
			
				|  |  | -=======
 | 
	
		
			
				|  |  | -    private List<Content> removeDuplicateContent(List<Content> contentList, Set<String> existsContentTitle) {
 | 
	
		
			
				|  |  | -        List<Content> result = new ArrayList<>();
 | 
	
		
			
				|  |  | -        for (Content content : contentList) {
 | 
	
		
			
				|  |  | -            if (existsContentTitle.contains(content.getTitle())
 | 
	
		
			
				|  |  | -                    || isDuplicateContent(content.getTitle(), existsContentTitle)) {
 | 
	
		
			
				|  |  | -                continue;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            result.add(content);
 | 
	
		
			
				|  |  | -            existsContentTitle.add(content.getTitle());
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return result;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    private static final double SIMILARITY_THRESHOLD = 0.8; // 相似度阈值
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    private boolean isDuplicateContent(String title, Set<String> existsContentTitle) {
 | 
	
		
			
				|  |  | -        boolean result = false;
 | 
	
		
			
				|  |  | -        for (String existsTitle : existsContentTitle) {
 | 
	
		
			
				|  |  | -            if (isSimilar(title, existsTitle, SIMILARITY_THRESHOLD)) {
 | 
	
		
			
				|  |  | -                return true;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return result;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    private boolean isSimilar(String titleA, String titleB, double threshold) {
 | 
	
		
			
				|  |  | -        if (titleA.isEmpty() || titleB.isEmpty()) {
 | 
	
		
			
				|  |  | -            return false;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        Set<Character> setA = new HashSet<>();
 | 
	
		
			
				|  |  | -        for (char c : titleA.toCharArray()) {
 | 
	
		
			
				|  |  | -            setA.add(c);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        Set<Character> setB = new HashSet<>();
 | 
	
		
			
				|  |  | -        for (char c : titleB.toCharArray()) {
 | 
	
		
			
				|  |  | -            setB.add(c);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        Set<Character> setCross = new HashSet<>(setA);
 | 
	
		
			
				|  |  | -        setCross.retainAll(setB);
 | 
	
		
			
				|  |  | -        int minLen = Math.max(Math.min(setA.size(), setB.size()), 1);
 | 
	
		
			
				|  |  | -        double rate = (double) setCross.size() / minLen;
 | 
	
		
			
				|  |  | -        return rate >= threshold;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | ->>>>>>> e5f14a8 (init)
 | 
	
		
			
				|  |  |  }
 |