/** * A default constructor that initialises the idf i attribute */ public BasicModel() { i = new Idf(); }
/** * This method computes the score for the implemented weighting model. * @param tf The term frequency in the document * @param documentFrequency The document frequency of the term * @param termFrequency the term frequency in the collection * @param documentLength The length of the document. * @return the score returned by the implemented weighting model. */ public double score( double tf, double documentFrequency, double termFrequency, double keyFrequency, double documentLength){ //double f = termFrequency / numberOfDocuments; return keyFrequency * tf * i.idfDFR(documentFrequency); } }
/** * main * @param args */ public static void main(String[] args) { for(String v : args) { System.out.println("log_2("+v+")=" +log(Double.parseDouble(v))); } }
/** Clone this weighting model */ @Override public BasicModel clone() { try{ BasicModel newModel = (BasicModel)super.clone(); newModel.i = (Idf)this.i.clone(); return newModel; } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } }
/** * Sets the number of documents in the collection. * @param numOfDocs the number of documents in the collection. */ public void setNumberOfDocuments(double numOfDocs) { this.numberOfDocuments = numOfDocs; this.i.setNumberOfDocuments(numOfDocs); }
/** Clone this weighting model */ @Override public WeightingModel clone() { try{ WeightingModel newModel = (WeightingModel)super.clone(); newModel.i = (Idf)this.i.clone(); return newModel; } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } }
/** * Sets the number of documents in the collection. * @param numOfDocs the number of documents in the collection. */ public void setNumberOfDocuments(double numOfDocs) { this.numberOfDocuments = numOfDocs; this.i.setNumberOfDocuments(numOfDocs); }
/** * This method computes the score for the implemented weighting model. * @param tf The term frequency in the document * @param documentFrequency The document frequency of the term * @param termFrequency the term frequency in the collection * @param keyFrequency The normalised query term frequency. * @param documentLength The length of the document. * @return the score returned by the implemented weighting model. */ public double score( double tf, double documentFrequency, double termFrequency, double keyFrequency, double documentLength){ return keyFrequency * tf * i.idfDFR(termFrequency); } }
/** * main * @param args */ public static void main(String[] args) { for(String v : args) { System.out.println("log_2("+v+")=" +log(Double.parseDouble(v))); } }
/** * A default constructor that initialises the idf i attribute */ public WeightingModel() { i = new Idf(); }
/** Clone this weighting model */ @Override public BasicModel clone() { try{ BasicModel newModel = (BasicModel)super.clone(); newModel.i = (Idf)this.i.clone(); return newModel; } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } }
/** * prepare */ public void prepare() { averageDocumentLength = cs.getAverageDocumentLength(); numberOfDocuments = (double)cs.getNumberOfDocuments(); i.setNumberOfDocuments(numberOfDocuments); numberOfTokens = (double)cs.getNumberOfTokens(); numberOfUniqueTerms = (double)cs.getNumberOfUniqueTerms(); numberOfPointers = (double)cs.getNumberOfPointers(); documentFrequency = (double)getOverflowed(es.getDocumentFrequency()); termFrequency = (double)getOverflowed(es.getFrequency()); }
/** * This method computes the score for the implemented weighting model. * @param tf The term frequency in the document * @param documentFrequency The document frequency of the term * @param termFrequency the term frequency in the collection * @param documentLength The length of the document. * @return the score returned by the implemented weighting model. */ public double score( double tf, double documentFrequency, double termFrequency, double keyFrequency, double documentLength){ //double f = termFrequency / numberOfDocuments; return keyFrequency * tf * i.idfDFR(documentFrequency); } }
/** * The normalised INQUERY idf formula * @param d the number for which we will compute the normalised idf * @return the normalised INQUERY idf of d */ public double idfNENQUIRY(double d) { return (WeightingModelLibrary.log(numberOfDocuments + 1.0D, d + 0.5D) / log(numberOfDocuments+1.0D)); }
/** * The default constructor. * */ public Normalisation(){ idf = new Idf(); }
/** Clone this weighting model */ @Override public Normalisation clone() { try{ Normalisation newModel = (Normalisation)super.clone(); newModel.idf = (Idf)this.idf.clone(); return newModel; } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } }
/** * prepare */ public void prepare() { averageDocumentLength = cs.getAverageDocumentLength(); numberOfDocuments = (double)cs.getNumberOfDocuments(); i.setNumberOfDocuments(numberOfDocuments); numberOfTokens = (double)cs.getNumberOfTokens(); numberOfUniqueTerms = (double)cs.getNumberOfUniqueTerms(); numberOfPointers = (double)cs.getNumberOfPointers(); documentFrequency = (double)getOverflowed(es.getDocumentFrequency()); termFrequency = (double)getOverflowed(es.getFrequency()); }
/** * This method computes the score for the implemented weighting model. * @param tf The term frequency in the document * @param documentFrequency The document frequency of the term * @param termFrequency the term frequency in the collection * @param keyFrequency The normalised query term frequency. * @param documentLength The length of the document. * @return the score returned by the implemented weighting model. */ public double score( double tf, double documentFrequency, double termFrequency, double keyFrequency, double documentLength){ return keyFrequency * tf * i.idfDFR(termFrequency); } }
/** * Return the normalised idf of the given number. * @param d The number of which the idf is computed. * @return the normalised idf of d */ public double idfN(int d) { return (WeightingModelLibrary.log(numberOfDocuments, (double)d) / log(numberOfDocuments)); }
/** * A default constructor that initialises the idf i attribute */ public BasicModel() { i = new Idf(); }