View Javadoc

    1   /*
    2    * This file is part of dependency-check-core.
    3    *
    4    * Dependency-check-core is free software: you can redistribute it and/or modify it
    5    * under the terms of the GNU General Public License as published by the Free
    6    * Software Foundation, either version 3 of the License, or (at your option) any
    7    * later version.
    8    *
    9    * Dependency-check-core is distributed in the hope that it will be useful, but
    10   * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11   * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    12   * details.
    13   *
    14   * You should have received a copy of the GNU General Public License along with
    15   * dependency-check-core. If not, see http://www.gnu.org/licenses/.
    16   *
    17   * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
    18   */
    19  package org.owasp.dependencycheck.data.lucene;
    20
    21  import org.apache.lucene.search.similarities.DefaultSimilarity;
    22
    23  /**
    24   *
    25   * @author Jeremy Long (jeremy.long@owasp.org)
    26   */
    27  public class DependencySimilarity extends DefaultSimilarity {
    28
    29      /**
    30       * the serial version uid.
    31       */
    32      private static final long serialVersionUID = 1L;
    33
    34      /**
    35       * <p>Override the default idf implementation so that frequency within all
    36       * document is ignored.</p>
    37       *
    38       * See <a
    39       * href="http://www.lucenetutorial.com/advanced-topics/scoring.html">this
    40       * article</a> for more details.
    41       *
    42       * @param docFreq - the number of documents which contain the term
    43       * @param numDocs - the total number of documents in the collection
    44       * @return 1
    45       */
    46      @Override
    47      public float idf(long docFreq, long numDocs) {
    48          return 1;
    49      }
    50  }