File size: 1,144 Bytes
77c25ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Keyword-based auto-tagging for Prompt Garage."""

import re

# Top 30 keyword -> tag mappings
TAG_RULES = {
    "python": "python",
    "javascript": "javascript",
    "typescript": "typescript",
    "react": "react",
    "fastapi": "fastapi",
    "django": "django",
    "flask": "flask",
    "docker": "docker",
    "kubernetes": "kubernetes",
    "sql": "sql",
    "sqlite": "sqlite",
    "api": "api",
    "rest": "api",
    "graphql": "graphql",
    "test": "testing",
    "pytest": "testing",
    "unittest": "testing",
    "refactor": "refactor",
    "debug": "debugging",
    "bug": "debugging",
    "git": "git",
    "bash": "bash",
    "shell": "bash",
    "linux": "linux",
    "css": "css",
    "html": "html",
    "markdown": "markdown",
    "yaml": "yaml",
    "json": "json",
    "regex": "regex",
}


def suggest_tags(content: str) -> list[str]:
    """Extract tags from content based on keyword rules."""
    content_lower = content.lower()
    tags = set()
    for keyword, tag in TAG_RULES.items():
        if re.search(r'\b' + re.escape(keyword) + r'\b', content_lower):
            tags.add(tag)
    return sorted(tags)