Skip to main content
Glama
extractionStrategies.ts2.08 kB
/** * This file implements various strategies for extracting dependency information from text. * It uses a pattern-matching approach to identify external dependencies mentioned in Jira issues, * focusing on contextual patterns where dependencies might be mentioned. The file implements * multiple extraction strategies (checking words before, two words before, and words after an * indicator word) and combines them in a prioritized order to maximize the chances of correctly * identifying dependencies mentioned in natural language text. */ import { isValidDependencyWord } from './validators' /** * Strategy pattern for extracting dependency names */ export function extractDependencyName(words: string[], indicatorIndex: number): string | null { // Try each extraction strategy in order return ( checkWordsBefore(words, indicatorIndex) || checkTwoWordsBefore(words, indicatorIndex) || checkWordsAfter(words, indicatorIndex) ) } /** * Checks for dependencies in words before the indicator */ export function checkWordsBefore(words: string[], indicatorIndex: number): string | null { if (indicatorIndex <= 0) { return null } const previousWord = words[indicatorIndex - 1] if (isValidDependencyWord(previousWord)) { return `${previousWord} ${words[indicatorIndex]}` } return null } /** * Checks for dependencies in two words before the indicator */ export function checkTwoWordsBefore(words: string[], indicatorIndex: number): string | null { if (indicatorIndex <= 1) { return null } const twoWordsBefore = `${words[indicatorIndex - 2]} ${words[indicatorIndex - 1]}` if (twoWordsBefore.length > 5) { return `${twoWordsBefore} ${words[indicatorIndex]}` } return null } /** * Checks for dependencies in words after the indicator */ export function checkWordsAfter(words: string[], indicatorIndex: number): string | null { if (indicatorIndex >= words.length - 1) { return null } const nextWord = words[indicatorIndex + 1] if (isValidDependencyWord(nextWord)) { return `${words[indicatorIndex]} ${nextWord}` } return null }

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/tbreeding/jira-mcp'

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