How to use StringDistance class in JPA

I found the StringDistance utility class in JPA. I want to know how to use this class in JPA? You can get the API here .

I want to know how to use the method getClosestLevenshteinDistance

? Any help should be noticed.

+3


source to share


2 answers


The class is StringDistance

not part of the JPA spec , but a utility class from apache OpenJPA

The class StringDistance

is useful for calculating Levenshtein distance



+3


source


The Levenshtein distance between two lines is the minimum number of changes that must be applied to the first line in order to move to the second line. You can see here for the details of the algorithm.

The class StringDistance

has nothing to do with the JPA specification. It's just a utility class used by OpenJPA, which is one of the variants of the JPA specification. Apache Common also offers this feature



If OpenJPA encounters an invalid config property while parsing the openJPA config file, it will use the Levenshtein distance algorithm, calling getClosestLevenshteinDistance()

to find out the closest string of a valid property to that invalid property, so that it can provide a suggestion to fix that invalid property.

+2


source







All Articles