public override double GetElementFactor(string term, SpaceDocumentModel document) { if (!IsEnabled) { return(1); } TokenDictionary docDict = document.GetTerms(true, true); Double TF = docDict.GetTokenFrequency(term); switch (computation) { case TFComputation.modifiedTF: if (!index.ContainsKey(term)) { return(0); } Double Tt = index[term]; // training_terms.GetTokenFrequency(term); Double length_d = docDict.Count; //.GetTokenCount(); Double mTF_above = TF * Math.Log(SqrTc / Tt); Double mTF_below_2nd = (length_d * length_d) / SqrTc; Double mTF_below = Math.Log(docDict.GetSumSquareFrequencies() * mTF_below_2nd); return(mTF_above / mTF_below); break; } Double divisor = GetDivisor(docDict); //if (TFN_index.ContainsKey(document)) //{ // divisor = TFN_index[document]; //} //else //{ // divisor //} switch (computation) { default: case TFComputation.normal: return(TF / divisor); break; case TFComputation.squareRooted: return(Math.Sqrt(TF / divisor)); break; case TFComputation.glasgow: return(Math.Log(TF + 1) / divisor); break; } }