From 2ba50981acdae086e45000194d35816ea3a09695 Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 7 Mar 2026 10:00:53 +0000 Subject: [PATCH] definition changes --- hdyc-svelte/src/lib/data/unitDefinitions.ts | 105 ++++++++++++++------ 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/hdyc-svelte/src/lib/data/unitDefinitions.ts b/hdyc-svelte/src/lib/data/unitDefinitions.ts index 9ebc14b..428ec48 100644 --- a/hdyc-svelte/src/lib/data/unitDefinitions.ts +++ b/hdyc-svelte/src/lib/data/unitDefinitions.ts @@ -1,40 +1,87 @@ import { calculators } from './calculators'; -const domainDescriptions: Record = { - length: 'linear or spatial distance measurement', - weight: 'mass or force quantity', - temperature: 'thermal energy level', - volume: 'three-dimensional capacity', - area: 'two-dimensional surface measurement', - speed: 'rate of change of position', - pressure: 'force exerted per unit area', - energy: 'capacity to do work', - power: 'rate of energy transfer', - data: 'digital information volume', - time: 'temporal duration', - angle: 'angular measurement', - 'number-systems': 'numeric representation systems', - radiation: 'ionizing emission metrics', - electrical: 'electricity-related magnitude', - force: 'force or torque measurement', - light: 'luminous intensity', - other: 'specialized measurement', +const domainDefinitions: Record = { + length: { + summary: 'describes the linear or spatial distance between two points.', + context: 'Use it when explaining how far apart objects are, how long surfaces run, or how tall structures rise.', + }, + weight: { + summary: 'quantifies mass or the gravitational force exerted on an object.', + context: 'Apply these units when comparing loads, weights on a scale, or quantities of matter.', + }, + temperature: { + summary: 'captures thermal energy along a fixed scale such as Celsius, Fahrenheit, or Kelvin.', + context: 'They help compare how warm or cold something is and how heat flows between systems.', + }, + volume: { + summary: 'measures three-dimensional capacity inside containers or spaces.', + context: 'Useful for describing liquids, gases, or any amount of space you can fill.', + }, + area: { + summary: 'tracks two-dimensional surface coverage.', + context: 'Helpful when sizing plots of land, floor space, or sheets of material.', + }, + speed: { + summary: 'expresses how quickly an object changes position relative to time.', + context: 'Speed and velocity units tell you how fast you are moving across a distance or around a path.', + }, + pressure: { + summary: 'quantifies the amount of force applied over a specific unit of area.', + context: 'Essential when working with gases, fluids, or loads pressing onto a surface.', + }, + energy: { + summary: 'represents the capacity to do work or release heat.', + context: 'Energy units compare calories, joules, or BTUs when tracking work, heat, or stored energy.', + }, + power: { + summary: 'measures the rate at which energy is transferred or converted.', + context: 'Use them to compare engines, appliances, or systems that deliver energy over time.', + }, + data: { + summary: 'counts digital information in bytes, bits, or other storage grains.', + context: 'Data units help you compare file sizes, bandwidth, and storage capacity.', + }, + time: { + summary: 'denotes duration, intervals, or counts of ticks such as seconds, minutes, and hours.', + context: 'These units frame anything that changes over time or requires scheduling.', + }, + angle: { + summary: 'measures rotation between two rays or the sweep of a circle.', + context: 'Angle units are useful for describing turns, sweeps, bearings, and geometric layouts.', + }, + 'number-systems': { + summary: 'names positional numeral systems such as binary, decimal, or hexadecimal.', + context: 'They specify the base used to represent integers and guide how digits are interpreted.', + }, + radiation: { + summary: 'records ionizing emissions or the absorbed dose from radioactive sources.', + context: 'Radiation units show how much exposure, decay, or energy deposition is happening.', + }, + electrical: { + summary: 'covers electrical quantities like current, voltage, resistance, and capacitance.', + context: 'They keep circuit values aligned so you can balance loads, voltages, and energy transfer.', + }, + force: { + summary: 'describes pushes, pulls, or torque applied to an object.', + context: 'Force units help you quantify mechanical effort, tension, or rotation in machines and systems.', + }, + light: { + summary: 'relates to luminous intensity, illuminance, or optical flux.', + context: 'Use them to describe brightness, how much light reaches a surface, or the output of a lamp.', + }, + other: { + summary: 'covers specialized metrics that do not neatly fit the standard categories.', + context: 'That includes frequencies, compound conversions, and other domain-specific scales such as RPM or wavelength.', + }, }; const definitions: Record = {}; -const formatLabel = (label: string): string => { - if (!label) return ''; - return label - .replace(/\b([A-Z])/g, ' $1') - .replace(/\s+/g, ' ') - .trim(); -}; - const buildDefinition = (label: string, categoryKey: string): string => { if (!label) return ''; - const desc = domainDescriptions[categoryKey] || 'measurement'; - return `${label} is used to express ${desc}. Understanding ${label} keeps calculations aligned across the ${categoryKey} domain.`; + const domain = domainDefinitions[categoryKey] || domainDefinitions.other; + const description = [domain.summary, domain.context].filter(Boolean).join(' '); + return `${label} ${description}`; }; calculators.forEach(calc => {