From: Jeff Law <law@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] spellcheck: support transpositions aka Damerau-Levenshtein (PR other/69968)
Date: Mon, 11 Jun 2018 21:15:00 -0000 [thread overview]
Message-ID: <01c80ac3-b988-7b63-d068-b3b4eae8b3ec@redhat.com> (raw)
In-Reply-To: <1525135053-44850-1-git-send-email-dmalcolm@redhat.com>
On 04/30/2018 06:37 PM, David Malcolm wrote:
> This patch updates the edit-distance algorithm in spellcheck.c to
> support transpositions as well as additions/deletions/substitutions,
> so that a transposition error counts as a distance of 1 rather than 2.
>
> This leads to saner suggestions for such cases.
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
>
> OK for trunk?
>
> 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.
Going to trust you've got the algorithm right :-)
OK
jeff
prev parent reply other threads:[~2018-06-11 21:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-01 0:29 David Malcolm
2018-06-11 21:15 ` Jeff Law [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=01c80ac3-b988-7b63-d068-b3b4eae8b3ec@redhat.com \
--to=law@redhat.com \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).