public Normalizer(DocumentVectorCollection documents) { lengths = new NormalizedVector("DocumentVectorLengths"); vectors = new NormalizedVectorCollection(); foreach (KeyValuePair <string, DocumentVector> kvp in documents) { String id = kvp.Key; NormalizedVector vec = Normalize(id, kvp.Value); vectors.Add(vec); } }
public Normalizer(DocumentVectorCollection documents) { lengths = new NormalizedVector("DocumentVectorLengths"); vectors = new NormalizedVectorCollection(); foreach (KeyValuePair<string, DocumentVector> kvp in documents) { String id = kvp.Key; NormalizedVector vec = Normalize(id, kvp.Value); vectors.Add(vec); } }
public static NormalizedVectorCollection Compute(NormalizedVectorCollection tf, NormalizedVector idf) { NormalizedVectorCollection tfidf = new NormalizedVectorCollection(); foreach (KeyValuePair <string, NormalizedVector> doc in tf) { NormalizedVector vec = new NormalizedVector(doc.Key); foreach (KeyValuePair <string, double> term in doc.Value) { vec.Add(term.Key, term.Value * idf[term.Key]); } tfidf.Add(vec); } return(tfidf); }
public static NormalizedVectorCollection Compute(NormalizedVectorCollection tf, NormalizedVector idf) { NormalizedVectorCollection tfidf = new NormalizedVectorCollection(); foreach (KeyValuePair<string, NormalizedVector> doc in tf) { NormalizedVector vec = new NormalizedVector(doc.Key); foreach (KeyValuePair<string, double> term in doc.Value) { vec.Add(term.Key, term.Value * idf[term.Key]); } tfidf.Add(vec); } return tfidf; }