private decimal CalculateSimilarity() { if (!shinglesA.Any() || !shinglesB.Any()) { return(0); } SimilarElements = shinglesA.Intersect(shinglesB); // Gets the Intersections of the two HashSets of shingles AllElements = shinglesA.Union(shinglesB); // Gets the Union of the two HashSets of shingles // Number og elements in the Intersection devided by number of elements in the Union return((decimal)SimilarElements.Count() / (decimal)AllElements.Count()); }