Download tagger.py from smlflg/PromptGarage: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/smlflg/PromptGarage/resolve/main/tagger.py
- Command line
-
hf download hf://smlflg/PromptGarage/tagger.py
-
curl -L -o tagger.py https://huggingface.co/smlflg/PromptGarage/resolve/main/tagger.py
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) | |