using System; using System.Collections.Generic; using System.Text; namespace LinFu.Common { public class FuzzyItem<T> { private int _testCount; private int _matches; private T _item; public FuzzyItem(T item) { _item = item; } public void Test(Predicate<T> predicate) { if (predicate == null) return; if (predicate(_item)) _matches++; _testCount++; } public void Reset() { _testCount = 0; _matches = 0; } public double Confidence { get { double result = 0; if (_testCount == 0) return 0; result = ((double)_matches) / ((double)_testCount); return result; } } public T Item { get { return _item; } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)