|
| 1 | +# Matching.Core |
| 2 | + |
| 3 | +This library provides the core functionality for the matching engine. It defines the main interfaces and classes for implementing different matching strategies. |
| 4 | + |
| 5 | +## Core Components |
| 6 | + |
| 7 | +### `IMatcher<T, Result>` |
| 8 | + |
| 9 | +This is the primary interface for implementing a matcher. It has a single method: |
| 10 | + |
| 11 | +```csharp |
| 12 | +Result Match(T source, T target); |
| 13 | +``` |
| 14 | + |
| 15 | +- `T`: The type of the objects to compare. |
| 16 | +- `Result`: A type that inherits from `MatcherResult`, representing the result of the match. |
| 17 | + |
| 18 | +### `IMatcher` |
| 19 | + |
| 20 | +This is a non-generic version of the `IMatcher` interface, intended for use when the types are not known at compile time. |
| 21 | + |
| 22 | +### `Matcher<T, Result>` |
| 23 | + |
| 24 | +This abstract class provides a base implementation of `IMatcher`. It handles type checking and casting, and provides an abstract `Match` method for subclasses to implement: |
| 25 | + |
| 26 | +```csharp |
| 27 | +protected abstract Result Match(T? source, T? target); |
| 28 | +``` |
| 29 | + |
| 30 | +### `MatcherResult` |
| 31 | + |
| 32 | +This abstract class represents the result of a matching operation. It contains the source and target objects and properties to indicate if one or both are missing. |
| 33 | + |
| 34 | +## Available Matchers |
| 35 | + |
| 36 | +The following matchers are available in the `Matching.Core.Matchers` namespace: |
| 37 | + |
| 38 | +- `CaverMatcher`: Matches based on the CAVER algorithm. |
| 39 | +- `DateMatcher`: Matches dates with a configurable tolerance. |
| 40 | +- `EqualityMatcher`: Performs a simple equality check. |
| 41 | +- `JaroWinklerMatcher`: Uses the Jaro-Winkler distance algorithm for string comparison. |
| 42 | +- `LevenshteinMatcher`: Uses the Levenshtein distance algorithm for string comparison. |
| 43 | +- `PostcodeMatcher`: Matches UK postcodes. |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +Here is an example of how to use the `EqualityMatcher`: |
| 48 | + |
| 49 | +```csharp |
| 50 | +using Matching.Core.Matchers; |
| 51 | + |
| 52 | +var matcher = new EqualityMatcher(); |
| 53 | +var result = matcher.Match("hello", "hello"); |
| 54 | + |
| 55 | +Console.WriteLine(result.Equal); // True |
| 56 | +``` |
| 57 | + |
| 58 | +## Search |
| 59 | + |
| 60 | +### `Precedence` |
| 61 | + |
| 62 | +The `Precedence` class is a static class used to calculate a precedence score for a match. This score is used to rank potential matches. It takes in identifiers, last names, and dates of birth, and uses a combination of exact and fuzzy matching to generate a score. |
| 63 | + |
| 64 | +## Attributes |
| 65 | + |
| 66 | +### `MatcherAttribute` |
| 67 | + |
| 68 | +This attribute is used to decorate a matcher class with a key. This key can be used to dynamically discover and register matchers. |
| 69 | + |
| 70 | +```csharp |
| 71 | +[Matcher("Equality")] |
| 72 | +public class EqualityMatcher : Matcher<string, EqualityMatcherResult> |
| 73 | +{ |
| 74 | + // ... |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +## Utils |
| 79 | + |
| 80 | +The `Matching.Core.Utils` namespace contains various utility classes for string manipulation, date calculations, and implementations of the matching algorithms. |
| 81 | + |
| 82 | + |
0 commit comments