ngmarchant / comparator Goto Github PK
View Code? Open in Web Editor NEWSimilarity and distance measures for clustering and record linkage applications in R
License: GNU General Public License v2.0
Similarity and distance measures for clustering and record linkage applications in R
License: GNU General Public License v2.0
These measures are currently implemented in R. Porting to C++ is challenging, as it may be necessary to call an R function (the inner measure) from C++.
@ngmarchant the Levenshtein distance can be implemented using only two rows for dmat
, instead of using a square matrix. That could significantly reduce memory usage when comparing long sequences (400 Mb to 80 Kb when comparing strings of length 10,000).
Would it be worth it to implement this? I could propose the changes.
Example Python implementation:
import numpy as np
dmat = np.zeros((100,2))
def levenshtein(s, t, dmat):
m = len(s)
n = len(t)
dmat[:, 0] = np.arange(dmat.shape[0])
for j in range(1, n+1):
dmat[0, (j-1) % 2] = j-1
dmat[0, j % 2] = j
for i in range(1, m+1):
cost = 0
if s[i-1] != t[j-1]:
cost = 1
dmat[i, j % 2] = min(dmat[i-1, j % 2] + 1, dmat[i, (j-1) % 2] +
1, dmat[i-1, (j-1) % 2] + cost)
return dmat[m, n % 2]
levenshtein("test", "testt", dmat)
The following example emits warning messages about the vectors being of different lengths.
known_names <- c("Roberto", "Umberto", "Alberto")
comparator <- InVocabulary(known_names)
x <- "Roberto"
y <- c("Roberto", "Enberto", "Norberto")
elementwise(comparator, x, y)
StringMeasures currently only support comparisons between strings. It would be desirable to support comparisons between more general sequences---e.g. vectors of integers.
Consider adding support for token-based comparators. After mapping strings to token sets, the similarity of the sets can be measured using:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.