GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "spellcheck.h"
#include "selftest.h"
Macros | |
#define | CASE_COST 1 |
#define | BASE_COST 2 |
Functions | |
edit_distance_t | get_edit_distance (const char *s, int len_s, const char *t, int len_t) |
edit_distance_t | get_edit_distance (const char *s, const char *t) |
const char * | find_closest_string (const char *target, const auto_vec< const char * > *candidates) |
edit_distance_t | get_edit_distance_cutoff (size_t goal_len, size_t candidate_len) |
#define BASE_COST 2 |
Cost of another kind of edit.
Referenced by get_edit_distance(), and get_edit_distance_cutoff().
#define CASE_COST 1 |
Find near-matches for strings. Copyright (C) 2015-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Cost of a case transformation.
Referenced by get_edit_distance().
const char * find_closest_string | ( | const char * | target, |
const auto_vec< const char * > * | candidates ) |
Given TARGET, a non-NULL string, and CANDIDATES, a non-NULL ptr to an autovec of non-NULL strings, determine which element within CANDIDATES has the lowest edit distance to TARGET. If there are multiple elements with the same minimal distance, the first in the vector wins. If more than half of the letters were misspelled, the suggestion is likely to be meaningless, so return NULL for this case.
References candidate(), candidates, best_match< GOAL_TYPE, CANDIDATE_TYPE >::consider(), FOR_EACH_VEC_ELT, gcc_assert, best_match< GOAL_TYPE, CANDIDATE_TYPE >::get_best_meaningful_candidate(), and i.
Referenced by candidates_list_and_hint(), gcc::dump_manager::dump_switch_p(), and option_proposer::suggest_option().
edit_distance_t get_edit_distance | ( | const char * | s, |
const char * | t ) |
Get the edit distance between two nil-terminated strings.
References get_edit_distance().
edit_distance_t get_edit_distance | ( | const char * | s, |
int | len_s, | ||
const char * | t, | ||
int | len_t ) |
Get the edit distance between the two strings: the minimal number of edits that are needed to change one string into another, where edits can be one-character insertions, removals, or substitutions, or transpositions of two adjacent characters (counting as one "edit"). This implementation uses a modified variant of the Wagner-Fischer algorithm for the Damerau-Levenshtein distance; specifically, the "optimal string alignment distance" or "restricted edit distance" variant. This implementation has been further modified to take case into account.
References BASE_COST, CASE_COST, debug, i, and MIN.
Referenced by best_match< GOAL_TYPE, CANDIDATE_TYPE >::consider(), and get_edit_distance().
edit_distance_t get_edit_distance_cutoff | ( | size_t | goal_len, |
size_t | candidate_len ) |
Generate the maximum edit distance for which we consider a suggestion to be meaningful, given a goal of length GOAL_LEN and a candidate of length CANDIDATE_LEN. This is a third of the length of the candidate or of the goal, whichever is bigger.
References BASE_COST, gcc_assert, MAX, and MIN.