PromptGarage / tagger.py
smlflg's picture
Initial public upload from Projekte/PromptGarage
77c25ef verified
Raw History Blame Contribute Delete
1.14 kB
"""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)