Gestalt pattern matching
Gestalt pattern matching, also Ratcliff/Obershelp pattern recognition, is a string-matching algorithm for determining the similarity of two strings.[src] It was developed in 1983 by John W.[src] Ratcliff and John A.[src] Obershelp and published in the Dr.[src] Dobb's Journal in July 1988.[src]
Gestalt pattern matching, also Ratcliff/Obershelp pattern recognition, is a string-matching algorithm for determining the similarity of two strings.[src] It was developed in 1983 by John W.[src] Ratcliff and John A.[src] Obershelp and published in the Dr.[src] Dobb's Journal in July 1988.[src] 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.[src] === Sample=== The longest common substring is WIKIM (light grey) with 5 characters.[src] There is no further substring on the left.[src] The non-matching substrings on the right side are EDIA and ANIA .[src] They again have a longest common substring IA (dark gray) with length 2.[src] 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.[src] 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 .[src] However, the longest common subsequence of S_1 and S_2 is (ddd) \; (bbbb) \; (eee) , with a total length of 10 .[src] 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 .[src] 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.[src] 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} .[src]
21 sentences · 21 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Gestalt pattern matching." encyclopegia.org, 2025, https://encyclopegia.org/wiki/gestalt-pattern-matching. Accessed 04 December 2026.
Chicago
"Gestalt pattern matching." encyclopegia.org. Accessed December 4, 2026. https://encyclopegia.org/wiki/gestalt-pattern-matching.
APA
encyclopegia.org. (2025). Gestalt pattern matching. Retrieved December 4, 2026, from https://encyclopegia.org/wiki/gestalt-pattern-matching
Accessed December 4, 2026 · CC BY-SA 4.0 · citation page · JSON