A library for classifying GitHub repositories
Project description
Repository Classifier
A Python library for classifying GitHub repositories using both heuristic keyword-based and AI-powered methods.
Installation
pip install repo-classifier
Or install from source:
git clone https://github.com/samhsu-dev/repo_classifier.git
cd repo_classifier
pip install -e .
Features
- Classify repositories using keyword-based heuristic method
- Classify repositories using AI services (OpenAI GPT, DeepSeek, etc.)
- Built-in classifiers for PHP, Python, and JavaScript
- Extensible system for custom classifiers
- Multiple ways to define and load classifiers
Project Structure
repo_classifier/
├── src/
│ └── repo_classifier/ # Package (import repo_classifier)
│ ├── __init__.py # Exports public API
│ ├── core.py # Core interfaces
│ ├── utils.py # Utility functions
│ ├── registry.py # Classifier configuration registry
│ ├── description/ # README classification (heuristic, aimodel)
│ ├── evaluation.py # Ground truth and evaluation
│ ├── file_type.py # File-type inference
│ └── predefine/ # Built-in classifiers (php, python, javascript)
├── examples/ # Example scripts
├── tests/ # Test directory
├── setup.py # Installation configuration
├── requirements.txt # Dependencies
└── README.md # This file
Usage
Basic Usage
from repo_classifier import classify_repository_heuristic, CLASSIFIER_NAMES
# Use built-in PHP classifier
results = classify_repository_heuristic(
"https://github.com/user/repo",
classifier=CLASSIFIER_NAMES.PHP
)
print(results) # {"Web App": 0.85, "Framework": 0.45, "Library": 0.30}
# Use built-in Python classifier
results = classify_repository_heuristic(
"https://github.com/user/repo",
classifier=CLASSIFIER_NAMES.PYTHON
)
print(results) # {"Web Framework": 0.92, "Library/Package": 0.45}
# Use built-in JavaScript classifier
results = classify_repository_heuristic(
"https://github.com/user/repo",
classifier=CLASSIFIER_NAMES.JAVASCRIPT
)
print(results) # {"Frontend Framework": 0.88, "JavaScript Library": 0.40}
Using AI Classification
from repo_classifier import classify_repository_aimodel, CLASSIFIER_NAMES
# Use AI classification with built-in PHP project types
results = classify_repository_aimodel(
"https://github.com/user/repo",
api_key="your_api_key",
classifier=CLASSIFIER_NAMES.PHP,
model_name="gpt-3.5-turbo"
)
print(results)
Using CLASSIFIER_NAMES
The CLASSIFIER_NAMES object provides a convenient way to access the built-in classifier names:
from repo_classifier import CLASSIFIER_NAMES
# Access individual classifier names
php_classifier = CLASSIFIER_NAMES.PHP # "php"
python_classifier = CLASSIFIER_NAMES.PYTHON # "python"
js_classifier = CLASSIFIER_NAMES.JAVASCRIPT # "javascript"
# Get a list of all classifier names
all_classifiers = CLASSIFIER_NAMES.all() # ["php", "python", "javascript"]
# Get a list of available classifier names
available = CLASSIFIER_NAMES.available() # ["php", "python", "javascript"]
Custom Classifier Definition
from repo_classifier import classify_repository_heuristic, register_classifier
# Define custom classifier
custom_config = {
"Web Framework": {
"mvc": 10,
"web framework": 10,
"router": 8,
"controller": 8
},
"API Service": {
"api": 10,
"rest": 10,
"json": 8,
"http": 8
}
}
# Register custom classifier
register_classifier("custom", custom_config)
# Use registered classifier
results = classify_repository_heuristic(
"https://github.com/user/repo",
classifier="custom"
)
print(results)
Loading Classifiers from Python Modules
from repo_classifier import load_classifier_from_module, classify_repository_heuristic
# Import classifiers from a module
load_classifier_from_module("path/to/my_classifiers.py")
# Use imported classifier
results = classify_repository_heuristic(
"https://github.com/user/repo",
classifier="data_science"
)
print(results)
Creating Classifiers from Text Files
from repo_classifier import create_classifier_from_file, register_classifier
# Create classifier from text file
game_dev_config = create_classifier_from_file("path/to/game_dev.txt")
# Register classifier
register_classifier("game_dev", game_dev_config)
# Use registered classifier
results = classify_repository_heuristic(
"https://github.com/user/repo",
classifier="game_dev"
)
print(results)
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run tests with coverage
pytest --cov=repo_classifier
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
repo_classifier-0.1.4.tar.gz
(450.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file repo_classifier-0.1.4.tar.gz.
File metadata
- Download URL: repo_classifier-0.1.4.tar.gz
- Upload date:
- Size: 450.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87cb2908f29585621a55c3c3bb751deeda101bc21ec6e07af8daf3a54c01e4ed
|
|
| MD5 |
52b15058739c4f28c408e8192acc0350
|
|
| BLAKE2b-256 |
1d824b69b2546d1a462351cf9a72ff02d075f787f5e2d12fdae95f444a3a44fa
|
File details
Details for the file repo_classifier-0.1.4-py3-none-any.whl.
File metadata
- Download URL: repo_classifier-0.1.4-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
003bc93fdac32456939e943ddf110ba4fe46c659e67384e7a5cf60c00179f1c0
|
|
| MD5 |
5ac8ec30844b623b0e595017ef40b4f7
|
|
| BLAKE2b-256 |
ba87eb0b3386bee306a88a0db418a5c6f39a5287370ad0bad673033835f371ee
|