import { useState } from "react"; import { api, getErrorMessage } from "../api"; import type { MatchResponse } from "../types"; import { useApiCall } from "../hooks/useApiCall"; import ScoreBar from "./ScoreBar"; import StatusMessage from "./StatusMessage"; export default function KeywordMatcher() { const [keyword, setKeyword] = useState(""); const [meaningsText, setMeaningsText] = useState(""); const { data: results, loading, error, setError, run } = useApiCall(); async function handleMatch() { if (!keyword.trim() || !meaningsText.trim()) return; const candidates = meaningsText.split("\n").map((s) => s.trim()).filter(Boolean); if (candidates.length < 2) { setError("Provide at least 2 candidate meanings (one per line)."); return; } await run(() => api.matchKeyword({ keyword, candidate_meanings: candidates })); } return (

Keyword Meaning Matcher

Match each occurrence of a keyword to the most likely intended meaning. For example: keyword "pizza" with candidates "food" and "school".

setKeyword(e.target.value)} placeholder="e.g. pizza" />