cb 3 месяцев назад
Родитель
Сommit
29e8cf8c59
2 измененных файлов с 23 добавлено и 7 удалено
  1. 5 1
      .gitignore
  2. 18 6
      server/services/recommendation.service.ts

+ 5 - 1
.gitignore

@@ -46,4 +46,8 @@ testem.log
 .DS_Store
 Thumbs.db
 
-*.ovpn
+*.ovpn
+
+/docs/provider-archives
+/exports
+/uploads

+ 18 - 6
server/services/recommendation.service.ts

@@ -814,9 +814,20 @@ function scoreContentRelevance(tags: string[], keywords: string[]): number {
 
 function extractMatchTerms(text: string): string[] {
   const clean = text.trim();
-  const domainTerms = ['家居', '家装', '探店', '生活', '精致', '美食', '出行', '旅游', '母婴', '记录'];
-  const terms = domainTerms.filter((term) => clean.includes(term));
-  if (clean.length >= 2) terms.push(clean);
+  const terms: string[] = [clean];
+  // 常见领域子词,用于从复合关键词中提取有意义的短词
+  // 例如 "大象胶原蛋白系列" → 提取 "胶原蛋白","修丽可胶原蛋白精华" → 提取 "胶原蛋白"、"精华"
+  const domainTerms = [
+    '家居', '家装', '探店', '生活', '精致', '美食', '出行', '旅游', '母婴', '记录',
+    '护肤', '美妆', '测评', '种草', '好物', '情侣', '精华', '胶原蛋白', '面膜',
+    '防晒', '美白', '抗老', '补水', '保湿', '祛痘', '敏感肌', '修护', '清洁',
+    '彩妆', '口红', '粉底', '眼影', '穿搭', '健身', '减肥', '养生', '保健',
+    '数码', '科技', '游戏', '娱乐', '影视', '音乐', '教育', '职场', '金融',
+    '好物种草', '个人护理', '身体护理', '抗衰', '紧致', '淡斑', '祛皱',
+  ];
+  for (const term of domainTerms) {
+    if (clean.includes(term)) terms.push(term);
+  }
   return [...new Set(terms)];
 }
 
@@ -826,9 +837,10 @@ function calculateStyleMatch(samples: ContentSample[], keywords: string[]): numb
   let matchingSamples = 0;
   let highEngagement = 0;
 
+  const allMatchTerms = keywords.flatMap(extractMatchTerms);
   for (const sample of samples) {
     const text = `${sample.title} ${sample.content}`.toLowerCase();
-    const hasKeyword = keywords.some(kw => text.includes(kw.toLowerCase()));
+    const hasKeyword = allMatchTerms.some(term => text.includes(term.toLowerCase()));
     if (hasKeyword) matchingSamples++;
     if (sample.likeCount > 500 || sample.collectCount > 200) highEngagement++;
   }
@@ -862,7 +874,7 @@ function normalizeSearchCriteria(criteria: SearchCriteria): SearchCriteria {
     ...criteria,
     fanRange: normalizeFanRange(criteria.fanRange),
     budgetRange: normalizeBudgetRange(criteria.budgetRange),
-    platforms: criteria.platforms?.length ? criteria.platforms : ['xiaohongshu'],
+    platforms: criteria.platforms?.length ? criteria.platforms : ['xiaohongshu', 'douyin'],
     keywords: criteria.keywords?.length ? criteria.keywords : ['生活方式'],
     targetCount: normalizeTargetCount(criteria.targetCount),
   };
@@ -907,7 +919,7 @@ function normalizeBudgetRange(range: { min: number; max: number }): { min: numbe
 function uniquePlatforms(platforms: string[]): string[] {
   const normalized = platforms.map(mapPlatformName).filter(Boolean);
   const supported = normalized.filter((platform) => platform === 'xiaohongshu' || platform === 'douyin');
-  return [...new Set(supported.length > 0 ? supported : ['xiaohongshu'])];
+  return [...new Set(supported.length > 0 ? supported : ['xiaohongshu', 'douyin'])];
 }
 
 function platformsNeedSupplement(candidates: JustOneCreator[], platforms: string[], targetPerPlatform: number): boolean {