Public
Edited
Feb 19, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
similarities = {
return names1
.map((name1) =>
names2.reduce((acc, name2) => {
const words1 = name1.name.split(" ");
const words2 = name2.name.split(" ");

// Check if the last names match
if (
words1[words1.length - 1].trim() ==
words2[words2.length - 1].trim() &&
(!words1.slice(0, -1).some((word) => ignored.includes(word)) ||
!words2.slice(0, -1).some((word) => ignored.includes(word)))
) {
const commonWords = words1
.filter((word) => word.length > 0)
.slice(0, -1)
.filter((word) => !ignored.includes(word))
.filter((word) => words2.includes(word));

if (
commonWords.length > 0 &&
name1.name.trim().length > 0 &&
name2.name.trim().length > 0
) {
acc.push(
`Matching words: ${name1.name} and ${name2.name}: ${commonWords.length}: ${name1.id} : ${name2.id}`
);
}

if (checksimilar) {
const name1Chars = name1.name.split("");
const name2Chars = name2.name.split("");

const commonChars = name1Chars.filter((char) =>
name2Chars.includes(char)
);

const similarity =
commonChars.length /
Math.max(name1Chars.length, name2Chars.length);

if (similarity > similarityThreshold) {
acc.push(
`Similar letters: ${name1.name} and ${name2.name}: ${commonWords.length} : ${name1.id} : ${name2.id}`
);
}
}
}
return acc;
}, [])
)
.flat()
.filter((d) => d.length > 0)
.sort();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more