Skip to content

Results header can report more mapped than inputs ("11 out of 10 mapped") #47

Description

@jamesamcl

With the example inputs, the results header shows Results (11 out of 10 mapped).

Cause: frontend/src/pages/Home.tsx:33 computes mappedCount by counting result rows with mappingConfidence >= 0.9:

const mappedCount = useMemo(() => resultsRef.current.filter(r => parseFloat(r.mappingConfidence) >= 0.9).length, [resultsVersion])

but resultsRef.current holds one row per annotation, and a single input property can yield several rows (multiple candidate terms). The denominator at line 556 is lastSearchParams.properties.length — the number of distinct inputs — so any input with two or more high-confidence annotations pushes the numerator past the denominator.

Fix: count distinct mapped inputs instead of rows, e.g.

const mappedCount = useMemo(
  () => new Set(
    resultsRef.current
      .filter(r => parseFloat(r.mappingConfidence) >= 0.9)
      .map(r => r.textToMap)
  ).size,
  [resultsVersion])

(textToMap is the input-property column used for the TSV export at line 291; if inputs can repeat with different propertyType, key the set on textToMap + '\t' + r.propertyType instead.)

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions