spellcheck: support transpositions aka Damerau-Levenshtein (PR other/69968)
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 12 Jun 2018 18:28:37 +0000 (18:28 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 12 Jun 2018 18:28:37 +0000 (18:28 +0000)
commitb80a188beea98da44228d6030932af0769946f83
tree30899a1fa363ab017696f4a64c390302d401ce6b
parente3329a782fc0e51b9a4ddfc6938a484ec4b03084
spellcheck: support transpositions aka Damerau-Levenshtein (PR other/69968)

gcc/fortran/ChangeLog:
PR other/69968
* misc.c (gfc_closest_fuzzy_match): Update for renaming of
levenshtein_distance to get_edit_distance.

gcc/ChangeLog:
PR other/69968
* spellcheck-tree.c (levenshtein_distance): Rename to...
(get_edit_distance): ...this, and update for underlying renaming.
* spellcheck-tree.h (levenshtein_distance): Rename to...
(get_edit_distance): ...this.
* spellcheck.c (levenshtein_distance): Rename to...
(get_edit_distance): ...this.  Convert from Levenshtein distance
to Damerau-Levenshtein distance by supporting transpositions of
adjacent characters.  Rename "v1" to "v_next" and "v0" to
"v_one_ago".
(selftest::levenshtein_distance_unit_test_oneway): Rename to...
(selftest::test_edit_distance_unit_test_oneway): ...this, and
update for underlying renaming.
(selftest::levenshtein_distance_unit_test): Rename to...
(selftest::test_get_edit_distance_unit): ...this, and update for
underlying renaming.
(selftest::test_find_closest_string): Add example from PR 69968
where transposition helps
(selftest::test_metric_conditions): Update for renaming.
(selftest::test_metric_conditions): Likewise.
(selftest::spellcheck_c_tests): Likewise.
* spellcheck.h (levenshtein_distance): Rename both overloads to...
(get_edit_distance): ...this.
(best_match::consider): Update for renaming.

gcc/testsuite/ChangeLog:
PR other/69968
* gcc.dg/spellcheck-transposition.c: New test.

From-SVN: r261521
gcc/ChangeLog
gcc/fortran/ChangeLog
gcc/fortran/misc.c
gcc/spellcheck-tree.c
gcc/spellcheck-tree.h
gcc/spellcheck.c
gcc/spellcheck.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/spellcheck-transposition.c [new file with mode: 0644]