1 /*
2 * This file is part of dependency-check-core.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
17 */
18 package org.owasp.dependencycheck.data.lucene;
19
20 import org.apache.lucene.search.similarities.DefaultSimilarity;
21
22 /**
23 *
24 * @author Jeremy Long
25 */
26 public class DependencySimilarity extends DefaultSimilarity {
27
28 /**
29 * the serial version uid.
30 */
31 private static final long serialVersionUID = 1L;
32
33 /**
34 * <p>
35 * Override the default idf implementation so that frequency within all document is ignored.</p>
36 *
37 * See <a href="http://www.lucenetutorial.com/advanced-topics/scoring.html">this article</a> for more details.
38 *
39 * @param docFreq - the number of documents which contain the term
40 * @param numDocs - the total number of documents in the collection
41 * @return 1
42 */
43 @Override
44 public float idf(long docFreq, long numDocs) {
45 return 1;
46 }
47 }