GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

Gestalt pattern matching

Gestalt pattern matching, also Ratcliff/Obershelp pattern recognition, is a string-matching algorithm for determining the similarity of two strings. It was developed in 1983 by John W. Ratcliff and John A. Obershelp and published in the Dr. Dobb's Journal in July 1988. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

Gestalt pattern matching, also Ratcliff/Obershelp pattern recognition, is a string-matching algorithm for determining the similarity of two strings. It was developed in 1983 by John W. Ratcliff and John A. Obershelp and published in the Dr. Dobb's Journal in July 1988. D_{ro} = \frac{2K_m} where the similarity metric can take a value between zero and one: 0 \leq D_{ro} \leq 1 The value of 1 stands for the complete match of the two strings, whereas the value of 0 means there is no match and not even one common letter. === Sample=== The longest common substring is WIKIM (light grey) with 5 characters. There is no further substring on the left. The non-matching substrings on the right side are EDIA and ANIA . They again have a longest common substring IA (dark gray) with length 2. The similarity metric is determined by: \frac{2K_m} = \frac{2 \cdot (|\text{“WIKIM”}|+|\text{“IA”}|)} = \frac{2 \cdot (5 + 2)}{9 + 9} = \frac{14}{18} = 0.\overline{7} The Ratcliff/Obershelp matching characters can be substantially different from each longest common subsequence of the given strings. For example S_1 = q \; ccccc \; r \; ddd \; s \; bbbb \; t \; eee \; u and S_2 = v \; ddd \; w \; bbbb \; x \; eee \; y \; ccccc \; z have ccccc as their only longest common substring, and no common characters right of its occurrence, and likewise left, leading to K_m = 5 . However, the longest common subsequence of S_1 and S_2 is (ddd) \; (bbbb) \; (eee) , with a total length of 10 . S_1 = \text{GESTALT PATTERN MATCHING} and S_2 = \text{GESTALT PRACTICE} the metric result for D_{ro}(S_1, S_2) is \frac{24}{40} with the substrings GESTALT P , A , T , E and for D_{ro}(S_2, S_1) the metric is \frac{26}{40} with the substrings GESTALT P , R , A , C , I . D_{rqr} = \frac{2 \cdot \min(|S1|, |S2|)} , The second upper bound calculates twice the sum of all used characters S_1 which occur in S_2 divided by the length of both strings but the sequence is ignored. D_{qr} = \frac{2 \cdot \big | \{\!\vert S1 \vert\!\} \cap \{\!\vert S2 \vert\!\} \big |} Dqr Implementation in Python import collections def quick_ratio(s1: str, s2: str) -> float: """Return an upper bound on ratio() relatively quickly.""" length = len(s1) + len(s2) if not length: return 1.0 intersect = (collections.Counter(s1) & collections.Counter(s2)) matches = sum(intersect.values()) return 2.0 * matches / length Trivially the following applies: 0 \leq D_{ro} \leq D_{qr} \leq D_{rqr} \leq 1 and 0 \leq K_m \leq | \{\!\vert S1 \vert\!\} \cap \{\!\vert S2 \vert\!\} \big | \leq \min(|S1|, |S2|) \leq \frac {2} .

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Gestalt pattern matching". 1754919202. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1305354093

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·