Skip to main content
Glama
planActions.ts1.42 kB
import type { AlignmentPair, AlignmentPlan, PlannedAction, SimilarityOptions, } from './types'; export const planAlignmentActions = ( alignment: AlignmentPair[], changedEnglishBlockIndexes: Set<number>, similarityOptions: SimilarityOptions ): AlignmentPlan => { const actions: PlannedAction[] = []; const seenFrench = new Set<number>(); alignment.forEach((pair) => { const englishIndex = pair.englishIndex; const frenchIndex = pair.frenchIndex; if (englishIndex === -1 && frenchIndex !== null) { // french only -> delete if (!seenFrench.has(frenchIndex)) { actions.push({ kind: 'delete', frenchIndex }); seenFrench.add(frenchIndex); } return; } if (englishIndex >= 0 && frenchIndex === null) { // new english block actions.push({ kind: 'insert_new', englishIndex }); return; } if (englishIndex >= 0 && frenchIndex !== null) { // matched pair const isChanged = changedEnglishBlockIndexes.has(englishIndex); const isHighSimilarity = pair.similarityScore >= similarityOptions.minimumMatchForReuse; if (!isChanged && isHighSimilarity) { actions.push({ kind: 'reuse', englishIndex, frenchIndex }); } else { actions.push({ kind: 'review', englishIndex, frenchIndex }); } seenFrench.add(frenchIndex); return; } }); return { actions }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server