/** * This method provides the contract for implementing weighting models. * @param tf The term frequency in the document * @param docLength the document's length * @return the score assigned to a document with the given tf and * docLength, and other preset parameters */ public final double score(double tf, double docLength) { double TF = tf * WeightingModelLibrary.log(1.0d + (c * averageDocumentLength) / docLength); double NORM = (termFrequency + 1d) / (documentFrequency * (TF + 1d)); //double f = termFrequency / numberOfDocuments; return NORM * keyFrequency * ( - WeightingModelLibrary.log(numberOfDocuments - 1) - WeightingModelLibrary.LOG_2_OF_E + WeightingModelLibrary.stirlingPower( numberOfDocuments + termFrequency - 1d, numberOfDocuments + termFrequency - TF - 2d) - WeightingModelLibrary.stirlingPower(termFrequency, termFrequency - TF)); }
/** * This method provides the contract for implementing weighting models. * @param tf The term frequency in the document * @param docLength the document's length * @return the score assigned to a document with the given tf and * docLength, and other preset parameters */ public final double score(double tf, double docLength) { double TF = tf * WeightingModelLibrary.log(1.0d + (c * averageDocumentLength) / docLength); double NORM = (termFrequency + 1d) / (documentFrequency * (TF + 1d)); //double f = termFrequency / numberOfDocuments; return NORM * keyFrequency * ( - WeightingModelLibrary.log(numberOfDocuments - 1) - WeightingModelLibrary.LOG_2_OF_E + WeightingModelLibrary.stirlingPower( numberOfDocuments + termFrequency - 1d, numberOfDocuments + termFrequency - TF - 2d) - WeightingModelLibrary.stirlingPower(termFrequency, termFrequency - TF)); }