benchmarkstt icon indicating copy to clipboard operation
benchmarkstt copied to clipboard

Make Levenshtein a proper differ instead of a hacky mode

Open MikeSmithEU opened this issue 3 years ago • 1 comments

Levenshtein should be a proper Differ class, not hacked into metrics.

This PR does the necessary changes to achieve that.

  • [x] extend Dfifer interface to support get_opcode_counts and get_error_rate (especially in the case of Levenshtein this can allow for huge speed and memory gains as for large texts the Levenshtein algorithm needs a big matrix to properly determine the least expensive path)
  • [x] change metrics, tests and documentation to reflect this change, allow WER to be calculated using Levenshtein

Known issues:

  • Currently getting the opcodes using levenshtein is broken
    • tried Levenshtein package (only supports strings, so not usable)
    • using edit-distance package at the moment, but it does not give the proper results for lists. The package is bugged for opcodes and I cannot currently invest the time to fix it or even file a proper error report and unit tests to the maintainer.
    • tried some other packages, but same problems seem to occur, or only the edit distance is supported (not getting opcodes) will look at other solutions again later
    • a pure python implementation seems ill-advised because of the computational and space complexity of the algorithm (quadratic-time complexity of Wagner-Fischer algorithm is the best we can do, and might be solely for the edit distance, not the opcodes), it could be a temporary stop-gap but probably requires too much time investment
    • maybe disable Levenshtein for metrics requiring the opcodes? (currently this is DiffCounts, Diff and WER, WER could be factored out with some code changes - only for MODE_STRICT though, although custom weights should be implementable using Levenshtein)

It seems to me that we should probably only support Levenshtein for distance, not for the opcodes at the moment, editops totals ("opcode counts") might be feasible, have not yet looked at the implementations here as I really wanted to get full and correct opcodes so that we could display the entire diff between ref and hyp.

MikeSmithEU avatar Nov 08 '20 00:11 MikeSmithEU