I am using the Damerau-Levenshtein code available from here in my similarity measurements. The problem is that when I apply the Damerau-Levenshtein on two strings such as cat sat on a mat and dog sat mat, I am getting edit distance as 8. This similarity results can get any number regarding insertion, deletion or substitution like any range from 0, 1, 2, ... . Now I am wondering if there is any way that we can assume or find a maximum of this distance (similarity) and converted between 0 and 1 or how can we set the max value that at least I can say: distance =1 - similarity.
The reason for this post is that I am setting a threshold for a few distance metrics like cosine, Levenstein and damerau levenstein and outputs of all should be betweeb zero and 1.
How to choose the proper maximum value for Damerau-Levenshtein distance?
1.7k Views Asked by Bilgin At
2
There are 2 best solutions below
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in DISTANCE
- Algorithm to find neighbours of point by distance with no repeats
- distance matrix api gives incorrect data
- How to make this sensor keep taking readings once its when_in_range function has been activated?
- Threshold scaling along a straight line
- How to subtract large binary numbers?
- sf_distance within for within for each parallelisation
- How do I update the coordinates based on most recent datetime?
- Prediction Accuracy Zero (y_pred == y_test) & ValueError after Binary Projection, kNN Hamming, Xtrain/y_train appear accurate
- Mahalanobis distance between two multivariate Gaussian distribution
- problem with inputs for estimating earth mover distance with emd from python ot package
- Finding the most-similar color palette
- scipy.spatial.distance: cityblock between lat/long points: What is the unit of the results?
- How can i add measure tool in openlayers3?
- Is calculating the distance between two floating-point numbers symmetrical?
- Fast computation of squared norm and normalized vector with Eigen
Related Questions in SIMILARITY
- Similar Questions but Different Response Set Up in Survey Data Sets
- Measures of similarity for time series data
- similarity between two numpy arrays based on shape but not distance
- How to detect if two sentences are simmilar, not in meaning, but in syllables/words?
- How can I compare the similarity between multiple sets?
- Similarity search within vector database records
- Langchain FAISS | Any solutions or alternatives for similarity search on vector DBs for slightly repetitive short words with numerics?
- I have plots of points that I extract from an image. How can I determine a similarity measure between two different plots?
- How to combine a column containing score value with knn score of rest of the columns
- Shared triples between two knowledge graphs
- record matching/similarity calculation for numbers and characters
- Dealing with Pearson Similarity returning 0 for users with equal item counts - Mahout
- VBA collect consecutive similar cells in the row
- Textual similarity between two tags in Nodejs
- Get similarity within a column based on another column
Related Questions in LEVENSHTEIN-DISTANCE
- Stop OpenSearch from counting mispelled words (from fuzziness) in score when a correct word is matched
- Reduce the amount of entries read for the smallest Levenshtein distance in a data bank
- Jaccard vs Cosine similarity for addresses string comparison
- Python aligning audio transcription to script for subtitles using word similarity
- C#: of two methods which calculate Levenshtein distance, why does the heap-allocated "cost" array outperform the stack-allocated "cost" array?
- How does Oracle DB compute edit distance and similarity with non-ASCII characters?
- How can I get this LAMBDA function to accept an array as input?
- Levenshtein Distance using Azure Search
- How do I figure out which word sounds most similar to a given word?
- Mutation/mismatch counts among sequences/strings in Python
- Levenshtein distance for words from list in Bigquery
- Meaning behind 'thefuzz' / 'rapidfuzz' similarity metric when comparing strings
- How to find the changes from levenshtein string distance
- Match county names to predefined list
- The theoretical complexity of Tries and the distances of Levenshtein to suggest similar words
Related Questions in DAMERAU-LEVENSHTEIN
- Strange output of the `adist` fuction in R (string distance)
- using Damerau-Levenshtein distance to compare sets of text in code.org
- Is there public data for OCR-based character distance?
- Damerau-Levenshtein distance between two vectors
- Finding which error(s) are detected by Damerau-Levenshtein edit distance algorithm
- Algorithm to find one edit distance words from input word using Levenshtein distance?
- How to choose the proper maximum value for Damerau-Levenshtein distance?
- Fuzziness not behaving as expected in Elasticsearch
- Find all pairs of similar words
- Levenstein distance, multiple paths
- Damerau-Levenshtein algorithm isn't working on short strings
- Using Python to extract the specific edit when Damerau-Levenshtein distance equals 1
- Modify Damerau-Levenshtein algorithm to track transformations (insertions, deletions, etc)
- Text correction Damereau Levenshtein python
- Suggestion for limiting fuzzy search suggestion results
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The difficult thing is that the upper bound of Damerau-Levenshtein is infinite (given infinitely long words), but we can't practically make infinite strings.
If you wanted to be safe, you can use something that maps the range 0-> max length of a string onto the range 0->1. The max length of a string depends on the amount of memory you have (assuming 64 bit), so I'd recommend doing...not this. Source
Practically, you can also just check all of the strings you are about to compare and choose the length of the longest string in that list as the max value. Another solution is to compute all of the scores beforehand and apply the conversion factor after you know the max score. Some code that could do that:
These happen to give identical answers because most of the words are very different from each other but either of these approaches should work for most cases.
Long story short, the max distance between two strings is the length of the longer string.
Notes: if this maps in the wrong direction (i.e. high scores are showing low and vice versa, just add "1-" between the open bracket and x in adjustscore)
Also, if you want it to map do a different range, replace the 1 with a different max value.