# String distance that satisfies triangle equality [closed]

Need to determine similarity of sentences in some body of text. The sentences are not exactly human language (internal technical terms and abbreviations), so word2vec and similar approach is not useful.

Trying to line up all the sentences in 1-dimensional space and apply clustering. For that purpose I'm thinking of using some string distance measure from empty string to the given string.

Question: is there any string distance measure that satisfies triangle equality (d(a, b) = d(a) + d(b))? Distances like Levenshtein distance satisfy triangle inequality, while it seems to me distance that gives equality would be a much better predictor of "closeness" for strings (considering they are lined up in 1-d space by distance from empty string, that is strings are close if abs(d(a, '') - d(b, '') < ε)

Clarification: From definition of metric distance properties 1, 2, 3, but property 4 should be d(x, z) = d(x, y) + d(y, z)

## closed as unclear what you're asking by whuber♦Aug 22 at 12:58

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• You may interest in Levenshtein distance en.wikipedia.org/wiki/Levenshtein_distance. – Ben Dai Dec 4 '17 at 7:22
• As far as I understand, Levenshtein distance doesn't produce strong equality for all cases of triangle inequality. – ssanin82 Dec 4 '17 at 7:24
• The relation you cite is not the triangle inequality (it isn't even an inequality): it's additivity. Is that what you really meant? – whuber Aug 22 at 12:58