UNPKG

bowling-analysis-system

Version:

A comprehensive system for analyzing bowling techniques using video processing and metrics calculation

61 lines (53 loc) 1.67 kB
/** * @module bowling_analysis/utils/EventNameMapper * @description Centralized event name mapping and standardization */ const EVENT_NAME_MAPPING = { // Standard event names 'releasePoint': 'releasePoint', 'frontFootLanding': 'frontFootLanding', 'backFootLanding': 'backFootLanding', // Legacy names 'ball_release': 'releasePoint', 'BALL_RELEASE': 'releasePoint', 'release_point': 'releasePoint', 'left_foot_plant': 'frontFootLanding', 'LEFT_FOOT_PLANT': 'frontFootLanding', 'right_foot_plant': 'backFootLanding', 'RIGHT_FOOT_PLANT': 'backFootLanding' }; /** * Get standardized event name * @param {string} eventName - Input event name * @returns {string} Standardized event name */ function getStandardEventName(eventName) { return EVENT_NAME_MAPPING[eventName] || eventName; } /** * Check if event name is standard * @param {string} eventName - Event name to check * @returns {boolean} True if standard name */ function isStandardEventName(eventName) { return ['releasePoint', 'frontFootLanding', 'backFootLanding'].includes(eventName); } /** * Convert event names in an object to standard names * @param {Object} events - Events object * @returns {Object} Events with standardized names */ function standardizeEventNames(events) { const standardized = {}; for (const [key, value] of Object.entries(events)) { const standardName = getStandardEventName(key); standardized[standardName] = value; } return standardized; } module.exports = { EVENT_NAME_MAPPING, getStandardEventName, isStandardEventName, standardizeEventNames };