Classes
LinkSuggestion
dataclass
A suggested link between two pages.
Represents a recommendation to add a link from source page to …
LinkSuggestion
dataclass A suggested link between two pages.
Represents a recommendation to add a link from source page to target page based on topic similarity, importance, and connectivity analysis.
Attributes
| Name | Type | Description |
|---|---|---|
source |
Page |
Page where the link should be added |
target |
Page |
Page that should be linked to |
score |
float |
Recommendation score (0.0-1.0, higher is better) |
reasons |
list[str] |
List of reasons why this link is suggested |
Internal Methods 1
__repr__
__repr__
def __repr__(self) -> str
Returns
str
LinkSuggestionResults
dataclass
Results from link suggestion analysis.
Contains all link suggestions generated for the site, along…
LinkSuggestionResults
dataclass Results from link suggestion analysis.
Contains all link suggestions generated for the site, along with statistics and methods for querying suggestions.
Attributes
| Name | Type | Description |
|---|---|---|
suggestions |
list[LinkSuggestion] |
List of all link suggestions, sorted by score |
total_suggestions |
int |
Total number of suggestions generated |
pages_analyzed |
int |
Methods 3
get_suggestions_for_page
Get link suggestions for a specific page.
get_suggestions_for_page
def get_suggestions_for_page(self, page: Page, limit: int = 10) -> list[LinkSuggestion]
Get link suggestions for a specific page.
Parameters 2
page |
Page |
Page to get suggestions for |
limit |
int |
Maximum number of suggestions |
Returns
List of LinkSuggestion objects sorted by scorelist[LinkSuggestion]
—
get_top_suggestions
Get top N suggestions across all pages.
get_top_suggestions
def get_top_suggestions(self, limit: int = 50) -> list[LinkSuggestion]
Get top N suggestions across all pages.
Parameters 1
limit |
int |
Returns
list[LinkSuggestion]
get_suggestions_by_target
Get all suggestions that point to a specific target page.
get_suggestions_by_target
def get_suggestions_by_target(self, target: Page) -> list[LinkSuggestion]
Get all suggestions that point to a specific target page.
Parameters 1
target |
Page |
Returns
list[LinkSuggestion]
LinkSuggestionEngine
Generate smart link suggestions to improve site connectivity.
Uses multiple signals to recommend l…
LinkSuggestionEngine
Generate smart link suggestions to improve site connectivity.
Uses multiple signals to recommend links:
- Topic Similarity: Pages with shared tags/categories
- PageRank: Prioritize linking to important pages
- Navigation Value: Link to bridge pages
- Link Gaps: Find underlinked valuable content
Methods 1
generate_suggestions
Generate link suggestions for all pages.
generate_suggestions
def generate_suggestions(self) -> LinkSuggestionResults
Generate link suggestions for all pages.
Returns
LinkSuggestionResults with all suggestionsLinkSuggestionResults
—
Internal Methods 5
__init__
Initialize link suggestion engine.
__init__
def __init__(self, graph: KnowledgeGraph, min_score: float = 0.3, max_suggestions_per_page: int = 10)
Initialize link suggestion engine.
Parameters 3
graph |
KnowledgeGraph |
KnowledgeGraph with page connections |
min_score |
float |
Minimum score threshold for suggestions |
max_suggestions_per_page |
int |
Maximum suggestions per page |
_generate_suggestions_for_page
Generate link suggestions for a single page.
_generate_suggestions_for_page
def _generate_suggestions_for_page(self, source: Page, all_pages: list[Page], page_tags: dict[Page, set[str]], page_categories: dict[Page, set[str]], pagerank_scores: dict[Page, float], betweenness_scores: dict[Page, float]) -> list[LinkSuggestion]
Generate link suggestions for a single page.
Parameters 6
source |
Page |
|
all_pages |
list[Page] |
|
page_tags |
dict[Page, set[str]] |
|
page_categories |
dict[Page, set[str]] |
|
pagerank_scores |
dict[Page, float] |
|
betweenness_scores |
dict[Page, float] |
Returns
list[LinkSuggestion]
_calculate_link_score
Calculate link score between two pages.
_calculate_link_score
def _calculate_link_score(self, source: Page, target: Page, page_tags: dict[Page, set[str]], page_categories: dict[Page, set[str]], pagerank_scores: dict[Page, float], betweenness_scores: dict[Page, float]) -> tuple[float, list[str]]
Calculate link score between two pages.
Parameters 6
source |
Page |
|
target |
Page |
|
page_tags |
dict[Page, set[str]] |
|
page_categories |
dict[Page, set[str]] |
|
pagerank_scores |
dict[Page, float] |
|
betweenness_scores |
dict[Page, float] |
Returns
Tuple of (score, reasons)tuple[float, list[str]]
—
_build_tag_map
Build mapping of page -> set of tags.
_build_tag_map
def _build_tag_map(self, pages: list[Page]) -> dict[Page, set[str]]
Build mapping of page -> set of tags.
Parameters 1
pages |
list[Page] |
Returns
dict[Page, set[str]]
_build_category_map
Build mapping of page -> set of categories.
_build_category_map
def _build_category_map(self, pages: list[Page]) -> dict[Page, set[str]]
Build mapping of page -> set of categories.
Parameters 1
pages |
list[Page] |
Returns
dict[Page, set[str]]
Functions
suggest_links
Convenience function for link suggestions.
suggest_links
def suggest_links(graph: KnowledgeGraph, min_score: float = 0.3, max_suggestions_per_page: int = 10) -> LinkSuggestionResults
Convenience function for link suggestions.
Parameters 3
| Name | Type | Default | Description |
|---|---|---|---|
graph |
KnowledgeGraph |
— | KnowledgeGraph with page connections |
min_score |
float |
0.3 |
Minimum score threshold |
max_suggestions_per_page |
int |
10 |
Max suggestions per page |
Returns
LinkSuggestionResults with all suggestionsLinkSuggestionResults
—