fix: Crash when comparing two long words
This commit is contained in:
@@ -27,7 +27,8 @@ import {
|
||||
} from "../models/vocab";
|
||||
import { ReviewType, IReviewMetadata } from "../models/review";
|
||||
|
||||
import { levW } from "../algorithms/levenshtein";
|
||||
//@ts-ignore
|
||||
import lev from "js-levenshtein";
|
||||
import {
|
||||
LEVENSHTEIN_MAX_DISTANCE, MAX_ERROR_THRESHOLD,
|
||||
REVIEW_HELP_MOD
|
||||
@@ -213,7 +214,7 @@ const ReviewPageWithRouter = withRouter(
|
||||
// Map all possible answers to lowercase ( => ignore casing)
|
||||
const answers = current.answers.map((el) => el.toLowerCase());
|
||||
// Calculate the distances to all possible answers
|
||||
const dists = answers.map((el) => levW(input.toLowerCase(), el));
|
||||
const dists = answers.map((el) => lev(input.toLowerCase(), el));
|
||||
// Find the lowest distance
|
||||
const minDist = Math.min(...dists);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user