Skip to content

Blog

Many Ways to Be Similar

A family of string-distance metrics behind one interface, because there is no single answer to 'how close.'

There is no such thing as the string-similarity metric. A typo wants edit distance; a name wants prefix weighting; a jumbled word wants shared letters; a misspelling wants sound. The twenty-second familiar admits this and ships a whole family, edit distance, Jaro-Winkler, Jaccard, Dice, and more, all behind one interface, so choosing the right notion of close is a matter of picking a class.

Smith and Schmidt

Matching names by how they sound, not how they are spelled.

Smith and Schmidt are the same name, spelled two ways. Any system that matches on exact spelling will never connect them, which is a problem if you are searching for people, whose names arrive spelled every possible way. The twenty-first familiar reads a word the way it is said, not written, and emits two keys so that a name and its foreign cousin finally meet.

The Earth Is Not a Ball

Turning latitude and longitude into vectors you can do geometry on, on an Earth that is lumpier than a sphere.

Latitude and longitude are angles on a curved surface, and you cannot take the dot product of two angles. To do real geometry on the Earth, measure an angle between two cities, feed a region to a spatial index, you first turn each point into a vector in space. The twentieth familiar does that conversion, honestly, across an Earth that is neither round nor drawn on a single map.

Asking the Machine

Reading a host's own limits, on systems that each hide the answer somewhere different.

A long-running server should know its own limits: how many file descriptors it is burning against the cap, how much RAM the process holds, how much disk is left before writes start failing. None of those numbers has a portable source. The nineteenth familiar is the small, unglamorous library that asks each operating system for them in its own dialect, so the rest of the engine can just ask once.