Files
gods-eye-view/src/voice/speechLint.js
T
Sameh Khamis 73e789489b chore: drop exports nothing imports
Knip, configured with the application, package exports, scripts, QA
harnesses, workers, tools and tests as entry points, reports exports
that no module imports. Each was checked by hand against string-based
and namespace imports.

- Symbols that are still used inside their own module lose only the
  `export` keyword (176 constants and helpers).
- Unused re-exports are removed from barrel modules (flight, military,
  vessel, CCTV, directions, transit history, local ADS-B and street-level
  policy modules).
- Declarations that nothing uses at all are deleted, among them
  AIS_WATCHDOG_STATUSES, applyFilter, isRadioCountryCode, compactText,
  DENSITY_STOPS, the unused CCTV endpoint constants, and the SDR band
  constants.
- Default exports that nothing imports are removed. The ones in
  src/data/earthquakes.js, src/data/telegeographySubmarineCables.js,
  src/data/wind.js and src/data/bhoteKoshiLocator.js each constructed a
  layer instance at import time that nothing used; those instances are
  no longer created.

Every export of a package.json entry stays, as does TOMTOM_CREDIT,
which the traffic layer reads from the credits namespace it is given.
2026-10-22 19:00:40 -07:00

55 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Spoken-reply lint shared by the turn spans, the unit tests and the QA
* harnesses. Pure: no browser or provider dependencies.
*/
/**
* Phrases that add length without adding an answer. Tool numbers are spoken
* verbatim, so approximations are hedges too.
*/
const HEDGE_PHRASES = Object.freeze([
'keep in mind',
"it's worth noting",
'it is worth noting',
'please note',
'note that',
'based on the data available',
'based on the available data',
'i should mention',
'as of my',
'it seems',
'it appears',
'approximately',
'roughly',
'let me think',
'let me check',
'one moment while',
'bear with me',
'just to be clear',
]);
const WORD = /[\p{L}\p{N}][\p{L}\p{N}'’-]*/gu;
/**
* Count spoken words in a transcript.
* @param {string} text
* @returns {number}
*/
export function countWords(text) {
return String(text || '').match(WORD)?.length || 0;
}
/**
* Return every hedge phrase found in a transcript, in list order.
* @param {string} text
* @returns {string[]}
*/
export function findHedges(text) {
const normalized = ` ${String(text || '')
.toLowerCase()
.replace(/[’]/g, "'")
.replace(/[^\p{L}\p{N}' ]+/gu, ' ')
.replace(/\s+/g, ' ')} `;
return HEDGE_PHRASES.filter((phrase) => normalized.includes(` ${phrase} `));
}