feat(ocr): use a slider for confidence

This commit is contained in:
Elian Doran
2026-04-02 11:09:36 +03:00
parent 722efd74c2
commit 6f2296eb05
3 changed files with 7 additions and 7 deletions

View File

@@ -1268,7 +1268,6 @@
"ocr_auto_process": "Auto-process new files",
"ocr_auto_process_description": "Automatically extract text from newly uploaded or pasted files.",
"ocr_min_confidence": "Minimum confidence",
"ocr_confidence_unit": "(0.0-1.0)",
"ocr_confidence_description": "Only extract text above this confidence threshold. Lower values include more text but may be less accurate.",
"batch_ocr_title": "Process Existing Files",
"batch_ocr_description": "Extract text from all existing images, PDFs, and Office documents in your notes. This may take some time depending on the number of files.",

View File

@@ -3,6 +3,7 @@ interface SliderProps {
onChange(newValue: number);
min?: number;
max?: number;
step?: number;
title?: string;
}

View File

@@ -5,6 +5,7 @@ import server from "../../../services/server";
import toast from "../../../services/toast";
import { FormTextBoxWithUnit } from "../../react/FormTextBox";
import FormToggle from "../../react/FormToggle";
import Slider from "../../react/Slider";
import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";
import OptionsRow from "./components/OptionsRow";
import OptionsSection from "./components/OptionsSection";
@@ -77,12 +78,11 @@ function OcrSettings() {
/>
</OptionsRow>
<OptionsRow name="ocr-min-confidence" label={t("images.ocr_min_confidence")} description={t("images.ocr_confidence_description")}>
<FormTextBoxWithUnit
type="number" min="0" max="1" step="0.05"
unit={t("images.ocr_confidence_unit")}
currentValue={ocrMinConfidence}
onChange={setOcrMinConfidence}
<OptionsRow name="ocr-min-confidence" label={`${t("images.ocr_min_confidence")} (${Math.round(parseFloat(ocrMinConfidence ?? "0.75") * 100)}%)`} description={t("images.ocr_confidence_description")}>
<Slider
min={0} max={100} step={5}
value={Math.round(parseFloat(ocrMinConfidence ?? "0.75") * 100)}
onChange={(v) => setOcrMinConfidence(String(v / 100))}
/>
</OptionsRow>