fix(retrieval): resolved 'synonyms is not iterable' by using Map and Array.isArray v2.68.0
This commit is contained in:
+22
-22
@@ -44,31 +44,31 @@ export function tokenize(text: string): string[] {
|
||||
* 동의어/관련어 확장을 수행합니다.
|
||||
*/
|
||||
export function expandQuery(tokens: string[]): string[] {
|
||||
const synonymMap: Record<string, string[]> = {
|
||||
'성능': ['performance', 'optimization', '최적화', 'speed'],
|
||||
'performance': ['성능', '최적화', 'optimization', 'speed'],
|
||||
'아키텍처': ['architecture', '구조', 'structure', 'design'],
|
||||
'architecture': ['아키텍처', '구조', 'structure', 'design'],
|
||||
'메모리': ['memory', '기억', 'cache', 'storage'],
|
||||
'memory': ['메모리', '기억', 'cache', 'storage'],
|
||||
'버그': ['bug', 'error', '오류', 'issue', 'defect'],
|
||||
'bug': ['버그', 'error', '오류', 'issue'],
|
||||
'설계': ['design', '아키텍처', 'architecture', 'pattern'],
|
||||
'design': ['설계', '아키텍처', 'architecture', 'pattern'],
|
||||
'배포': ['deploy', 'deployment', 'release', 'ci', 'cd'],
|
||||
'deploy': ['배포', 'deployment', 'release'],
|
||||
'테스트': ['test', 'testing', 'spec', 'jest', 'mocha'],
|
||||
'test': ['테스트', 'testing', 'spec'],
|
||||
'프로젝트': ['project', '프로그램', 'repo', 'repository'],
|
||||
'project': ['프로젝트', '프로그램', 'repo'],
|
||||
'방향': ['direction', '전략', 'strategy', '목표', 'goal'],
|
||||
'direction': ['방향', '전략', 'strategy', '목표']
|
||||
};
|
||||
const synonymMap = new Map<string, string[]>([
|
||||
['성능', ['performance', 'optimization', '최적화', 'speed']],
|
||||
['performance', ['성능', '최적화', 'optimization', 'speed']],
|
||||
['아키텍처', ['architecture', '구조', 'structure', 'design']],
|
||||
['architecture', ['아키텍처', '구조', 'structure', 'design']],
|
||||
['메모리', ['memory', '기억', 'cache', 'storage']],
|
||||
['memory', ['메모리', '기억', 'cache', 'storage']],
|
||||
['버그', ['bug', 'error', '오류', 'issue', 'defect']],
|
||||
['bug', ['버그', 'error', '오류', 'issue']],
|
||||
['설계', ['design', '아키텍처', 'architecture', 'pattern']],
|
||||
['design', ['설계', '아키텍처', 'architecture', 'pattern']],
|
||||
['배포', ['deploy', 'deployment', 'release', 'ci', 'cd']],
|
||||
['deploy', ['배포', 'deployment', 'release']],
|
||||
['테스트', ['test', 'testing', 'spec', 'jest', 'mocha']],
|
||||
['test', ['테스트', 'testing', 'spec']],
|
||||
['프로젝트', ['project', '프로그램', 'repo', 'repository']],
|
||||
['project', ['프로젝트', '프로그램', 'repo']],
|
||||
['방향', ['direction', '전략', 'strategy', '목표', 'goal']],
|
||||
['direction', ['방향', '전략', 'strategy', '목표']]
|
||||
]);
|
||||
|
||||
const expanded = new Set(tokens);
|
||||
for (const token of tokens) {
|
||||
const synonyms = synonymMap[token];
|
||||
if (synonyms) {
|
||||
const synonyms = synonymMap.get(token);
|
||||
if (Array.isArray(synonyms)) {
|
||||
for (const syn of synonyms) {
|
||||
expanded.add(syn);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user