Did you know ... | Search Documentation: |
Pack lcs -- README |
:- use_module(library(lcs)). go :- lcs("1234", "12245334", "1234"), % assume vowels/3 awards 0.5 points to vowel matches % and 0 points to all other letters. lcs(vowels, "moose", "mouse", [0'o-0'o, 0'o-0'u, 0'e-0'e], 1.5).
Calculate a longest common subsequence for two lists. Two elements are considered common if they are equal.
One can also provide a meta-predicate to perform comparisons. This predicate calculates a similarity score for two elements. The subsequence with the highest total similarity is the LCS.
Source code available and pull requests accepted on GitHub: https://github.com/mndrix/lcs