string metric
{{Short description|Metric that measures the distance between two strings of text}}
{{redirect|String distance|the distance between strings and the fingerboard in musical instruments|Action (music)}}
In mathematics and computer science, a string metric (also known as a string similarity metric or string distance function) is a metric that measures distance ("inverse similarity") between two text strings for approximate string matching or comparison and in fuzzy string searching. A requirement for a string metric (e.g. in contrast to string matching) is fulfillment of the triangle inequality. For example, the strings "Sam" and "Samuel" can be considered to be close.{{cite book
| last = Lu
| first = Jiaheng | title = Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data | chapter = String similarity measures and joins with synonyms |display-authors=etal
| year=2013
| pages=373–384
| chapter-url=https://dl.acm.org/citation.cfm?id=2465313| doi = 10.1145/2463676.2465313
| isbn = 9781450320375
| s2cid = 2091942 }} A string metric provides a number indicating an algorithm-specific indication of distance.
The most widely known string metric is a rudimentary one called the Levenshtein distance (also known as edit distance).{{cite journal
| last = Navarro
| first = Gonzalo
| title = A guided tour to approximate string matching
| journal = ACM Computing Surveys |volume=33 |issue=1
| year=2001
| pages=31–88
| doi=10.1145/375360.375365| hdl=10533/172862
| s2cid = 207551224
| hdl-access=free
}} It operates between two input strings, returning a number equivalent to the number of substitutions and deletions needed in order to transform one input string into another. Simplistic string metrics such as Levenshtein distance have expanded to include phonetic, token, grammatical and character-based methods of statistical comparisons.
String metrics are used heavily in information integration and are currently used in areas including fraud detection, fingerprint analysis, plagiarism detection, ontology merging, DNA analysis, RNA analysis, image analysis, evidence-based machine learning, database data deduplication, data mining, incremental search, data integration, malware detection,{{cite journal |author1=Shlomi Dolev | last2=Mohammad |first2=Ghanayim |last3=Alexander |first3=Binun |last4=Sergey |first4=Frenkel |last5=Yeali |first5=S. Sun |title=Relationship of Jaccard and edit distance in malware clustering and online identification |journal=16th IEEE International Symposium on Network Computing and Applications |date=2017 |pages=369–373}} and semantic knowledge integration.
List of string metrics
- Levenshtein distance, or its generalization edit distance
- Damerau–Levenshtein distance
- Sørensen–Dice coefficient
- Block distance or L1 distance or City block distance
- Hamming distance
- Simple matching coefficient (SMC)
- Jaccard similarity or Jaccard coefficient or Tanimoto coefficient
- Tversky index
- Overlap coefficient
- Variational distance[http://www.coli.uni-saarland.de/courses/LT1/2011/slides/stringmetrics.pdf Sam's String Metrics - Computational Linguistics and Phonetics]
- Hellinger distance or Bhattacharyya distance
- Information radius (Jensen–Shannon divergence)
- Skew divergence
- Confusion probability
- Tau metric, an approximation of the Kullback–Leibler divergence
- Fellegi and Sunters metric (SFS)
- Maximal matches
- Grammar-based distanceRussell, David J., et al. [https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-11-601 "A grammar-based distance metric enables fast and accurate clustering of large sets of 16S sequences."] BMC bioinformatics 11.1 (2010): 1-14.
- TFIDF distance metric{{Cite journal|title = A Comparison of String Distance Metrics for Name-Matching Tasks.|url = https://dl.acm.org/doi/10.5555/3104278.3104293|date = 2003-08-01|pages = 73–78|first1 = William|last1 = Cohen|first2 = Pradeep|last2 = Ravikumar|first3 = Stephen|last3 = Fienberg}}
There also exist functions which measure a dissimilarity between strings, but do not necessarily fulfill the triangle inequality, and as such are not metrics in the mathematical sense. An example of such function is the Jaro–Winkler distance.
Selected string measures examples
class="wikitable" |
Name
! Description ! Example |
---|
Hamming distance
| Only for strings of the same length. Number of changed characters. | "{{mono|1=karolin}}" and "{{mono|1=kathrin}}" is 3. |
Levenshtein distance and Damerau–Levenshtein distance
| Generalization of Hamming distance that allows for different length strings, and (with Damerau) for transpositions | {{mono|kitten}} and {{mono|sitting}} have a distance of 3.
|
Jaro–Winkler distance
| | JaroWinklerDist("MARTHA","MARHTA") = : |
s_2 |
- is the number of matching characters;
- is half the number of transpositions(
"MARTHA"[3]!=H, "MARHTA"[3]!=T
).
|-
|
|MostFreqKeySimilarity('research', 'seeking', 2) = 2
|}
References
{{Reflist}}
External links
- [https://web.archive.org/web/20070304092115/http://www.dcs.shef.ac.uk/~sam/stringmetrics.html#qgram String Similarity Metrics for Information Integration] A fairly complete overview {{webarchive |url=https://web.archive.org/web/*/http://www.dcs.shef.ac.uk/~sam/stringmetrics.html#ukkonen |date=* }}
- [http://www.speech.cs.cmu.edu/ Carnegie Mellon University open source library]
- [http://rockymadden.com/stringmetric/ StringMetric project] a Scala library of string metrics and phonetic algorithms
- [https://github.com/NaturalNode/natural Natural project] a JavaScript natural language processing library which includes implementations of popular string metrics
{{strings}}
{{DEFAULTSORT:String Metric}}