2014-04-13 1 views
0

Lucene을 사용하여 검색 엔진을 만들었지 만 잘 진행되고 있지만 관련성과 연령에 따라 점수를 매기는 알고리즘을 구현하고 알고리즘을 구현해야합니다. 예를 들어이 (UNIX의 시대 형식으로 - 1970 년 이후의 초 예를 들어, 수) - 문서의 2.68065834 득점 검색 결과 기반 또는 관련성 및 연령에 대한 계산

  • 나이 것 - 예를 들어이 1380979800
  • 나이 scew 것 (

    • 관련성 점수 : 나는 3 개 개의 입력을 가지고 이것은 0에서 10 사이이며, 사용자가 지정되고 그것은 그들이 내가 현재하고 있어요 것은 기본적으로

    문서의 나이)이 전체 점수에 얼마나 많은 효과의 제어 할 수 있습니다 :

    ageOfDocumentInHours = age/3600; //this is to avoid any overflows 
        ageModifier = ageOfDocumentInHours * ageScew + 1; // scew of 0 results in relevancy * 1 
        overallScore = relevancy * ageModifier; 
    

    저는 통계에 대해 아무것도 모릅니다. 더 좋은 방법은 없습니까? 이것은 내가하고 결국 무엇

    감사합니다,

  • 답변

    0

    :

    public override float CustomScore(int doc, float subQueryScore, float valSrcScore) 
        { 
         float contentScore = subQueryScore; 
    
         double start = 1262307661d; //2010 
    
         if (_dateVsContentModifier == 0) 
         { 
          return base.CustomScore(doc, subQueryScore, valSrcScore); 
         } 
    
         long epoch = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; 
         long docSinceStartHours = (long)Math.Ceiling((valSrcScore - start)/3600); 
         long nowSinceStartHours = (long)Math.Ceiling((epoch - start)/3600); 
    
         float ratio = (float)docSinceStartHours/(float)nowSinceStartHours; // Get a fraction where a document that was created this hour has a value of 1 
         float ageScore = (ratio * _dateVsContentModifier) + 1; // We add 1 because we dont want the bit where we square it bellow to make the value smaller 
    
         float ageScoreAdjustedSoNewerIsBetter = 1; 
    
         if (_newerContentModifier > 0) 
         { 
          // Here we square it, multiuply it and then get the square root. This serves to make newer content have an exponentially higher score than old content instead of it just being linear 
          ageScoreAdjustedSoNewerIsBetter = (float)Math.Sqrt((ageScore * ageScore) * _newerContentModifier); 
         } 
    
         return ageScoreAdjustedSoNewerIsBetter * contentScore; 
        } 
    

    기본적인 생각이다 연령 점수는 0 2010 년 1 일 수있는 부분이 있고 1 지금 당장. 이 십진수 값에 _dateVsContentModifier가 곱해지며 날짜는 관련성 점수보다 높을 수도 있습니다.

    나이 스크롤은 제곱이며 _newerContentModifier가 곱 해져서 제곱근입니다. 이로 인해 최신 콘텐츠의 콘텐츠가 이전 콘텐츠보다 점수가 높아집니다.

    관련 문제