1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Core;
4:
5: /**
6: * Text comparison algorithms
7: *
8: * Text comparison algorithms take two strings and calculate a value between `0`
9: * and `1`, where `0` indicates the strings could not be more similar, and `1`
10: * indicates they could not be more different.
11: */
12: interface TextComparisonAlgorithm
13: {
14: /**
15: * Uncertainty is 0 if values are identical, otherwise 1
16: */
17: public const SAME = 1;
18:
19: /**
20: * Uncertainty is 0 if the longer value contains the shorter value,
21: * otherwise 1
22: */
23: public const CONTAINS = 2;
24:
25: /**
26: * Uncertainty is derived from levenshtein()
27: *
28: * String length cannot exceed 255 characters.
29: *
30: * @see levenshtein()
31: */
32: public const LEVENSHTEIN = 4;
33:
34: /**
35: * Uncertainty is derived from similar_text()
36: *
37: * @see similar_text()
38: */
39: public const SIMILAR_TEXT = 8;
40:
41: /**
42: * Uncertainty is derived from shared ngrams relative to the longest string
43: */
44: public const NGRAM_SIMILARITY = 16;
45:
46: /**
47: * Uncertainty is derived from shared ngrams relative to the shortest string
48: */
49: public const NGRAM_INTERSECTION = 32;
50: }
51: