public IEnumerable<SearchResult> Search(Document query) { var queryTfIdf = new TfIdf(new Tf(new BagOfWords(query)), _idf); var results = new List<SearchResult>(); foreach (TfIdfWithDocument tfIdfWithDocument in _tfIdfWithDocuments) { double probability = _probabilityMatrixCalculator.CalculateProbability(queryTfIdf, tfIdfWithDocument.TfIdf, _termsCollection); results.Add(new SearchResult(tfIdfWithDocument.Document, probability)); } return results.OrderByDescending(x => x.Probability); }
public TfIdfWithDocument(TfIdf tfIdf, Document document) { TfIdf = tfIdf; Document = document; }