Ranker
ranker
Symbol importance ranking via PageRank.
Scores every symbol in a package by "importance" using a PageRank-like
algorithm on the symbol reference graph. Symbols that are more imported,
exported (__all__), or inherited rank higher.
Example
from axm_ast.core.ranker import rank_symbols scores = rank_symbols(pkg) sorted(scores, key=scores.get, reverse=True)[:5]['Calculator', 'greet', 'resolve_path', ...]
rank_symbols(pkg)
Rank all symbols in a package by importance.
Uses PageRank on the symbol reference graph to score each function and class. Higher scores mean the symbol is more referenced/exported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg
|
PackageInfo
|
Analyzed package info. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict mapping symbol name → importance score. |
Example
scores = rank_symbols(pkg) top = sorted(scores, key=scores.get, reverse=True) top[0] 'Calculator'