Skip to content

Commit

Permalink
add thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdc2 committed Feb 22, 2024
1 parent 26c02c4 commit ad28e31
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Pure/lemmatise.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { editDistance } from "../Pure/stringedit.js";

const latinForms = Object.keys(lemmataLatin)
const greekForms = Object.keys(lemmataGreek)

const stringEditThreshold = 1
const formLengthThreshold = 2

/**
*
Expand All @@ -25,7 +26,7 @@ export const lemmatise = (lang) =>
return lemmataLatin[form]
} else {

if (form.length < 4) {
if (form.length <= formLengthThreshold) {
return null
}
const editDists = latinForms.map(
Expand All @@ -40,7 +41,7 @@ export const lemmatise = (lang) =>
const sorted = editDists.sort( ( [form1, dist1], [form2, dist2]) => dist1 - dist2 )
const [closestForm, dist] = sorted[0]

if (dist <= 1) {
if (dist <= stringEditThreshold) {
return lemmataLatin[closestForm]
}

Expand All @@ -53,7 +54,7 @@ export const lemmatise = (lang) =>
if (greekForms.includes(form)) {
return lemmataGreek[form]
} else {
if (form.length < 4) {
if (form.length < formLengthThreshold) {
return
}
const editDists = greekForms.map(
Expand All @@ -68,7 +69,7 @@ export const lemmatise = (lang) =>
const sorted = editDists.sort( ( [form1, dist1], [form2, dist2]) => dist1 - dist2 )
const [closestForm, dist] = sorted[0]

if (dist <= 1) {
if (dist <= stringEditThreshold) {
return lemmataGreek[closestForm]
}

Expand Down

0 comments on commit ad28e31

Please sign in to comment.