Text 0.4.0 countvectorizeroptions equals - CyrilB1531/lodestar GitHub Wiki
Lodestar.Text 0.4.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
Value equality, comparing the stop words as a set rather than as a sequence.
public bool Equals(CountVectorizerOptions other)Parameters — other is the options object to compare against.
Returns — bool, true when every setting matches and the two stop-word sets hold the same
words.
Example — the same words in a different order are the same options.
using Lodestar.Text.Vectorization;
var first = new CountVectorizerOptions { StopWords = new HashSet<string> { "the", "and" } };
var second = new CountVectorizerOptions { StopWords = new HashSet<string> { "and", "the" } };
bool same = first.Equals(second); // => TrueRemarks — a record's synthesised equality would compare StopWords by reference, so two
options objects carrying identical words would be unequal — the answer nobody wants and the reason
this is hand-written. SetEquals is what it uses, so order does not matter and neither does
duplication: ["the", "the"] equals ["the"].
That has a consequence worth knowing, and it is stated on
GetHashCode: because equal objects must hash alike, the
hash cannot use the stop-word count, since two equal sets can differ in it.
Applies to — net10.0, netstandard2.0.
See also — CountVectorizerOptions,
CountVectorizerOptions.GetHashCode.