The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [edit-distance]

A class of problems concerned with finding or minimizing the sequence of change operations (such as insertion, deletion, substitution, or transposition) to convert one list or string into another

Filter by
Sorted by
Tagged with
7
votes
2answers
123 views

Document distance in Python

I wrote a script to calculate document distance. It seems working but I couldn't be sure. (I tried for the small strings and it seems working) Also I am not sure that its fast enough for large texts. ...
6
votes
1answer
40 views

Search for strings in a list that have > 90% similarity

Explanation: I am working on String comparison in which I want to cross-compare the list of the same input string. For the same string, I am continuing the loop but if a single string will have ...
5
votes
1answer
70 views

Finding the closest string match for each string in two dataframe columns

I was wondering what's the fastest method to compare similarity between two lists of strings (e.g. two dataframes, documents etc.) using levenshtein distance or other procedures. I am currently using:...
7
votes
3answers
607 views

Cracking the Coding Interview — 1.5 One Away

I would like to know any suggestions about to improve my code solution and your rating of my approach to the problem, I based my code on the fact that if the strings have different length removing one ...
5
votes
2answers
849 views

Find hamming distance between two Strings of equal length in Java

I have a private class that I want to be able to find the shortest Hamming Distance between two Strings of equal length in Java. The private class holds a char[] ...
11
votes
2answers
3k views

Calculate Levenshtein distance between two strings in Python

I need a function that checks how different are two different strings. I chose the Levenshtein distance as a quick approach, and implemented this function: ...
1
vote
1answer
79 views

Programming Challenge from Kattis: Distinctive Characters

I'm currently working on this problem from Kattis. In short, we're supposed to find the string that has the least similarity to any other string given. Every element of a string is either 0 or 1. ...
6
votes
2answers
2k views

Find a best fuzzy match for a string

I am trying to find a best match for a name within a list of names. I came up with the below code, which works, but I feel that the creation of the intermediate ...
3
votes
0answers
59 views

MySQL JSON diff procedure

I'm building a procedure which compares two JSON objects and return two JSON objects with differences between each (compared keys and values). But I have relatively superficial SQL knowledge, so I ...
3
votes
1answer
1k views

Hamming Distance in Python

I was solving this Leetcode challenge about Hamming Distance. Would love feedback on my syntax and code style. Here's the challenge description: The Hamming distance between two integers is the ...
2
votes
0answers
57 views

Document distance in JavaScript

I am looking for the fastest way to find document distance. How can I improve this? Split each document into words. replaceAll() is faster than replace() ...
3
votes
0answers
108 views

Finding differences in strings with Levenshtein distance and soundex

I am trying to find a way to optimize the code runtime. Improvements I have implemented include using dictionaries, removing redundancies and using str.translate. <...
3
votes
2answers
116 views

Testing Video Frames for Uniqueness

I'm working on a program that will (hopefully) eventually allow me to perform frame rate analysis like Digital Foundry does. The code below works (as far as I know), but before I iterate on it, I'd ...
4
votes
1answer
443 views

Code to implement the Jaro similarity for fuzzy matching strings

Problem This code is meant to solve the problem in this software engineering question. To summarize the issue: given a set of strings that are sort of similar, but not similar enough to use regex ...
2
votes
1answer
86 views

Function to check whether two strings are similar at given %

Since the previous question I posted here was not found as interesting as I expected, I decided to post a new one. I made a function solely for the purpose of having fun. That is, a function that ...
6
votes
2answers
356 views

Calculate Hamming distance between DNA sequences in Ruby

I am requesting a review for my solution to this problem from exercism.io. I'm posting it here since there is not always input on solution submitted through exercism. The problem is as stated: ...
1
vote
0answers
187 views

Weighted Jaccard Similarity in Neo4j

I'm very new to Neo4J, and to Jaccard similarity (weighted or non!), so I'd really appreciate someone casting an eye over my code here before I try to use the results. Jaccard similarity for 2 sets ...
7
votes
2answers
5k views

String Similarity using fuzzywuzzy on big data

I have a file in which I was to check the string similarity within the names in a particular column. I use fuzzywuzzy token sort ratio algorithm as it is required for my use case. here is the code, is ...
5
votes
1answer
170 views

Trie based string indexing with edit distance / Levenshtein in Go

This is my first Go program that I've ever written. The code can also be found here. It allows you to create a search index and add words to it. The twist is that when searching for a word within the ...
4
votes
1answer
121 views

Levenshtein Distance of transitively similar words

The code's purpose is this: Two words are friends if they have a Levenshtein distance of 1. That is, you can add, remove, or substitute exactly one letter in word X to create word Y. A word’s social ...
9
votes
3answers
574 views

C++ edit distance / string similarity function based on the Jaro-Winkler algorithm

I wrote a short library function, based on an example from Rosetta, to compare two strings and determine similarity, using Jaro-Winkler. A short copy-paste ready example: main.cpp ...
3
votes
1answer
192 views

Matching entities in SQL Server to replace iterative Python script

I have a SQL (MS SQL Server) database of ~22 million companies (called target_db in my code). For example: ...
2
votes
0answers
88 views

My text comparison algorithm works very slow

I tried to create an algorithm (Translation Memory) that finds similarities between texts and try to predict the closest possible translation of the text, but there is a big problem with the working ...
2
votes
2answers
306 views

Hamming distance

I am wondering how I can improve the runtime of this code. I was solving this task at leetcode, and came up with this solution. But I got the result that my runtime is 88 ms, which beats a bit more ...
1
vote
1answer
109 views

Comparing two n×m matrices

I have to do a pairwise compare of a couple of text files. They have the following format: ...
2
votes
1answer
531 views

Code to calculate similarity between strings - R

I have a large datafile with names and I want to create a similarity distance matrix. With this matrix I want to get similar names that could be the same person (or not) and that I could compare these ...
3
votes
0answers
126 views

Message classification with Levenshtein Distance

I have a Python script that classifies messages. Each message carries a score, which is tallied up later in the script. It looks for messages that look alike, and puts them into a category. ...
1
vote
0answers
527 views

Which function is faster levenshtein() or similar_text()?

Brief I wrote two functions using levenshtein() and similar_text(). The functions will find similar words from the dictionary ...
3
votes
0answers
78 views

Minimum number of basic operations to convert str1 into str2

I am to convert a given string into another using only three basic operations, that is by deleting, inserting or replacing a character. Changes can only be made to string 1 and it is given that the ...
2
votes
2answers
575 views

Calculation of Hamming distance between two adjacency lists

I have written a Java program to calculate the Hamming distance between two adjacency lists. The program calculates the Hamming distance correctly, but it takes a very long time, especially when ...
7
votes
1answer
3k views

Approximate string search in Python

I have a long text (about 6,000,000 chars) and a short text (about 6,000 chars). The long text contains the short text, but not exactly - a small number of words are missing, abbreviated or just ...
2
votes
2answers
419 views

Compare two files and save the result into a pickle file

My code should compare two vectors saved as dictionary (two pickle files) and save the result into a pickle file too. This works but very slowly. For one compare result I'm waiting about 7:20 min. ...
2
votes
2answers
371 views

Damerau Levenshtein Implementation in Kotlin

This is an implementation of the Damerau-Levenshtein distance in Kotlin which I created as an exercise, but might be also useful, if it proves to be correct. The implementation is based on this ...
5
votes
2answers
306 views

Test whether the edit-distance of two strings is at most 1

There are three types of edits that can be performed on strings: insert a character, remove a character, or replace a character. EXAMPLES: ...
2
votes
1answer
104 views

Get Levenshtein Distance

Logic based of this site which had a VB example I used as a base. ...
4
votes
3answers
109 views

Count number of bits to convert one integer to another integer

Return the number of bits (N) that will need to be changed in order to convert an integer(X), into another integer(Y). Constraint: 0 <= X <= Y <= 2**128 Example: X = 1, Y = 2 => ...
3
votes
0answers
64 views

Space efficient revision history storage with diffs

I've written a tool to store a files history more efficiently by only generating diffs and storing them whereas whole file would otherwise have to be stored. I would like to to hear about ways to ...
1
vote
0answers
158 views

Optimizing Levenshtein Distance with nested loop

Brief illustration: I have 2 classes - tbCustomer and tbDHN which is stored inside a list....
1
vote
0answers
76 views

One-off string detection

Problem spec from CareerCup. Given two strings, return boolean True/False if they are only one edit apart. Edit can be insert/delete/update of only one character in the string. Eg. True xyz,xz xyz,...
10
votes
2answers
760 views

Finding roughly matching genome sequences in Python dictionary

The purpose of my code here is to play a part in genome sequencing analysis, and while functional it takes days to run, so I am looking for any way I can improve speed. The input is up to 500 million ...
7
votes
1answer
1k views

Edit Distance Implementation

I was doing some reading on the Wagner Fischer algorithm algorithm for computing the edit distance on strings. None of the examples in the literature I have read showed how to recover the edit ...
5
votes
2answers
2k views

Hamming distance between numbers in JavaScript

In Leetcode it states that my runtime is only faster than 38% all of submitted JavaScript solutions. Is there anything I can change to make it more efficient? ...
2
votes
1answer
466 views

Implementation of Wagner-Fischer-algorithm

I'm working on an implementation of a Wagner-Fischer-Algorithm for an online programming challenge site, but I can't seem to push the time down to where it needs to be. The assignment is to, for a ...
3
votes
1answer
106 views

Analyzing pair by pair DNA sequences with for loops in Python

Here is a code I would need to make far faster: it is made to analyse more than 3000 DNA sequences of more than 100 000 characters each. The matter is I have to compare it by pair, so that would be ...
3
votes
3answers
5k views

Given two strings, a and b, determine the minimum number of character deletions required to make a and b anagrams

I'm trying to figure out how my code could be improved. I solved a HackerRank problem from the Cracking the Coding Interview section, and am thinking that it should be able to be solved a simpler than ...
5
votes
2answers
84 views

A telephone book command line program in ANSI C - follow-up 2

(See the previous iteration.) What does this program do? This program gives you a command line interface for managing your personal telephone book. The program supports three actions: Adding a ...
1
vote
1answer
57 views

A telephone book command line program in ANSI C - follow-up

(See the next iteration.) This question is a slight improvement over A telephone book command line program in ANSI C I have incorporated almost all points stated by Toby Speight. Now I have this: ...
3
votes
0answers
396 views

Edit distance (Optimal Alignment) - follow up

This is a follow up of this question Optimal substructure of ED: Here is the reasoning behind my solution: let \$x = (\alpha _{1},\alpha _{2},\alpha _{3},...,\alpha _{m})\$ and \$y = (\beta_{1},\...
3
votes
1answer
35 views

Get string distance for a pseudo fuzzy search

We are using the following for evaluating strings for a pseudo fuzzy search. Curious if anything sticks out as needing optimization ...
4
votes
1answer
90 views

A telephone book command line program in ANSI C

(See the next iteration.) Introduction I was in the mood for some C code and wrote this program for handling a personal telephone record book. One of the goals is strict portability; the code ...