text
stringlengths
3
8.33k
repo
stringclasses
52 values
path
stringlengths
6
141
language
stringclasses
35 values
sha
stringlengths
64
64
chunk_index
int32
0
273
n_tokens
int32
1
896
license": "mixed", "license_note": "Most arXiv papers allow redistribution under arXiv license or CC BY", "robots_txt_compliant": true, "rate_limit_delay_seconds": 3, "requires_javascript": false, "file_types": [ "pdf" ], "avg_pages": 12, "priority": "high", ...
jku-encyclopedia
data/sources.json
JSON
32028978b8c09336f08fc5f3c6670711f03fca17018fd97b753c1e0b3ba40fed
10
896
://query.wikidata.org/sparql?query=ASK{wd:Q682739 ?p ?o}&format=json" } }, { "source_id": "dbpedia_jku", "name": "DBpedia JKU Entity", "category": "metadata", "url": "https://dbpedia.org/page/Johannes_Kepler_University_Linz", "listing_mechanism": "api", "auth_required":...
jku-encyclopedia
data/sources.json
JSON
bf157792e7ac63d7f5f1ea03a3bae6fd9d5a193e6285e6bfbf9ad1f1985abf94
11
896
statistics, financial data. Data tables downloadable as CSV/XLSX.", "quality": { "expected_min_items": 0, "min_text_length": 0 } }, { "source_id": "numa_uni_linz", "name": "Institut für Numerische Mathematik (Old Domain)", "category": "lecture_materials", "url...
jku-encyclopedia
data/sources.json
JSON
87a68f172ec06d474dd611f540876ff6c8584d271481ea3af1ea5c868fecff17
12
896
, "auth_required": false, "auth_note": "Search is public but deep access may need auth", "embedding_modality": "text", "chunking_strategy": "token_windows", "estimated_item_count": 500000, "language": "mixed", "license": "public_domain", "robots_txt_compliant": true, ...
jku-encyclopedia
data/sources.json
JSON
1be8824a8dbbc7cd9daae05be94daf1fd597ebab43ef64f0dfea6a9b961b4fea
13
896
, "min_text_length": 0 } }, { "source_id": "forschungsinfra_jku", "name": "Austrian Research Infrastructure Registry - JKU", "category": "metadata", "url": "https://forschungsinfrastruktur.bmfwf.gv.at/en/institution/jku-johannes-kepler-university-linz_14", "listing_me...
jku-encyclopedia
data/sources.json
JSON
163b7aa8d9648d5a6c2b9f59e46147237783c8de4653541aa00c57796a8a0013
14
896
en", "license": "unknown", "license_note": "Varies by source page", "robots_txt_compliant": true, "rate_limit_delay_seconds": 2.0, "requires_javascript": false, "file_types": ["jpg", "jpeg", "png", "gif", "webp", "mp4", "webm", "mp3", "m4a", "wav"], "priority": "normal", ...
jku-encyclopedia
data/sources.json
JSON
1f30badf1ab22ecc9e45fc1e450d139d2107777d4cfeb58f7bb8ed27d872eb97
15
120
{ "topics": [ {"name": "deep_learning", "domain": "machine_learning", "keywords": ["deep learning", "neural network", "backpropagation", "transformer", "attention mechanism", "convolutional", "recurrent", "LSTM", "xLSTM", "GRU"]}, {"name": "reinforcement_learning", "domain": "machine_learning", "keywords": ["...
jku-encyclopedia
data/taxonomy.json
JSON
808305ff3071f863e955c1c03b53209e43c8f3b0cfb134e24217a10b7d971938
0
896
, "scheduling", "memory management"]}, {"name": "program_analysis", "domain": "software_systems", "keywords": ["program analysis", "static analysis", "dynamic analysis", "type system"]}, {"name": "numerical_analysis", "domain": "mathematics", "keywords": ["numerical analysis", "finite element", "numerical metho...
jku-encyclopedia
data/taxonomy.json
JSON
da2017284133d25573db33ff13fe9d5e5e5f0c16f5dd3b29bae1876b3d9dbe5a
1
671
"""Embed all JKU chunks with Gemini, UMAP to 2D, export Cosmograph CSV. Pipeline: 1. Load text from all chunks_manifest.jsonl (title + text_content[:200]) 2. Batch-embed via Gemini (100 texts/call, 49 RPS) 3. UMAP reduce 3072-dim → 2D 4. Write cosmograph CSV with real X/Y Usage: .venv/Scripts/python.exe scr...
jku-encyclopedia
scripts/embed_umap_cosmograph.py
Python
8966edaeba48098b2f5e17714c5df19600aca04765c48e76574f73a9e1129342
0
896
("Author:"): author = line.split(":", 1)[1].strip() return year, author # ── Step 1: Load all chunk metadata + embed text ────────────────────────── def load_chunks() -> tuple[list[dict], list[str]]: """Return (metadata_rows, embed_texts).""" rows = [] texts = [] for source_dir in sor...
jku-encyclopedia
scripts/embed_umap_cosmograph.py
Python
741bed8ddd697b337165c09acd74e0e13677b2e0794da60940de8266cb2289b3
1
896
= texts[start:start + BATCH_SIZE] async with sem: for attempt in range(5): try: result = await asyncio.to_thread( client.models.embed_content, model=model, contents=batch, ...
jku-encyclopedia
scripts/embed_umap_cosmograph.py
Python
802de59573ef4902067ab8fc0024d8add8605ae67f3701e08a6f9ae7b5d3bcef
2
896
) writer.writeheader() for i, row in enumerate(rows): cat_parts = [row["faculty"], row["domain"]] if row["topic"]: cat_parts.append(row["topic"]) row["x"] = round(float(xy[i, 0]), 4) row["y"] = round(float(xy[i, 1]), 4) row["cat...
jku-encyclopedia
scripts/embed_umap_cosmograph.py
Python
c869c95b8ef8e75f12d30b129fd9c1065b9aaf59697a943b62d5159b76113b38
3
583
"""Export all cached chunk data to Cosmograph-ready CSV files. Produces two files in data/: - cosmograph_nodes.csv (one row per chunk) - cosmograph_edges.csv (edges: NEXT_CHUNK + seed-edge projections) Cosmograph column mapping: Nodes: id → pointId, source_id → pointColor, title → pointLabel, token_c...
jku-encyclopedia
scripts/export_cosmograph.py
Python
ff3ea1d3c7a718bfc4106c2cf5f87f660aa6bda21fd1f8ec7faab795b07b9427
0
896
"#7F8C8D" def load_all_chunks() -> list[dict]: """Load all chunks from all sources' chunks_manifest.jsonl files.""" chunks = [] sources = sorted(CACHE_DIR.iterdir()) for source_dir in sources: manifest = source_dir / "chunks_manifest.jsonl" if not manifest.exists(): continu...
jku-encyclopedia
scripts/export_cosmograph.py
Python
61803dab81642145a69c73cee8e3b6d4fa044de21f262cbdf20dfb677cad8361
1
896
) for c in chunks: chunk_by_source[c["source_id"]].append(c["id"]) seed_count = 0 import random random.seed(42) for edge in SEED_EDGES.get("edges", []): src_source = edge["source_id"] tgt_source = edge["target_id"] edge_type = edge["edge_type"] src_chunks = ...
jku-encyclopedia
scripts/export_cosmograph.py
Python
90856615a3112b9ee9d067689bc6e6e42bc8431f5113dd7c9d73a65d700c4813
2
896
}\n", file=sys.stderr) print("Building edges...", file=sys.stderr) edges = build_edges(chunks) print(f"Total edges: {len(edges):,}\n", file=sys.stderr) write_nodes_csv(chunks) write_edges_csv(edges) # Print summary stats from collections import Counter src_counts = Counter(c["source_i...
jku-encyclopedia
scripts/export_cosmograph.py
Python
db4f6f6d58001bfc4e6eb4b1b5c6b0c29f10493e64f8a387638886bf20bdf33d
3
472
"""Export all JKU cached data to a single Cosmograph-ready CSV with X/Y layout. Layout: Gaussian cluster model - 13 domains placed as cluster centers on a large canvas - Sources spread within their domain cluster - Topics create sub-clusters within sources - Chunks get Gaussian jitter scaled to sqrt(source_cou...
jku-encyclopedia
scripts/export_cosmograph_xy.py
Python
6fb01ea242a79b2431eab75468ea86e8c918a5d79f6272f6af614ecb4444b45e
0
896
": "TNF", "openalex_jku": "Cross-Faculty", "semantic_scholar_jku": "Cross-Faculty", "europe_pmc_jku": "MED", "wikidata_jku": "Central", "youtube_jku": "Central", "jku_web": "Central", "jku_podcasts": "Central", ...
jku-encyclopedia
scripts/export_cosmograph_xy.py
Python
e271036c2f0672d53eee17ca1770ef7d5a89dc5a8449077d895e64a2cc9c93f0
1
896
: dict[tuple[str, str], tuple[float, float]] = {} domain_sources: dict[str, list[str]] = defaultdict(list) for (dom, sid) in domain_source_counts: if sid not in domain_sources[dom]: domain_sources[dom].append(sid) for dom, sources in domain_sources.items(): ...
jku-encyclopedia
scripts/export_cosmograph_xy.py
Python
45c007eb1ca122fc96c0db34c725b4b0b1a5a533fe814dd8de33fa4ac4b51019
2
896
──────────────────── def main() -> None: print("Pre-scanning per (domain, source) counts...", file=sys.stderr) ds_counts = count_chunks_per_domain_source() total_expected = sum(ds_counts.values()) print(f"Expected total: {total_expected:,}\n", file=sys.stderr) engine = LayoutEngine(ds_counts) ...
jku-encyclopedia
scripts/export_cosmograph_xy.py
Python
133c3aeaa937c343bcaa9c4e901518080475cb4b6212c53e3c235cd411f36b20
3
814
"""Generate Cosmograph CSV with real semantic X/Y — fast subsample strategy. Pipeline: 1. Load all 450K chunks + cached SVD vectors 2. UMAP on a 100K stratified subsample (5-10 min) 3. Interpolate remaining 350K via nearest-neighbor in SVD space 4. Write Cosmograph CSV This produces the same visual quality as...
jku-encyclopedia
scripts/tfidf_umap_cosmograph.py
Python
130ae598430b693b742d3feab2519052af78b850aa4a38c9d47e358055482579
0
896
) return year, author # ── Step 1: Load ────────────────────────────────────────────────────────── def load_chunks() -> tuple[list[dict], list[str]]: rows: list[dict] = [] texts: list[str] = [] for source_dir in sorted(CACHE_DIR.iterdir()): manifest = source_dir / "chunks_manifest.jsonl" ...
jku-encyclopedia
scripts/tfidf_umap_cosmograph.py
Python
bf8f394b3be26c0189075caf5c9df17ede9671ce70f0c39703a438be7c05ae9c
1
896
.stderr) print(f" SVD reducing to 50D...", file=sys.stderr) t0 = time.time() svd = TruncatedSVD(n_components=50, random_state=42) dense = svd.fit_transform(tfidf).astype(np.float32) print(f" SVD done in {time.time() - t0:.1f}s — {svd.explained_variance_ratio_.sum():.1%} variance", file=sys.stde...
jku-encyclopedia
scripts/tfidf_umap_cosmograph.py
Python
e72d0e7e68ee2284e384410e04eaf158791bc7b6be51079a1192b282388e7848
2
896
─────────────────────────────────────────────────── def write_csv(rows: list[dict], xy: np.ndarray) -> None: fieldnames = [ "id", "x", "y", "category", "source", "faculty", "domain", "topic", "modality", "title", "author", "year", "url", "color", "size", ] with open(OUT, "w", newline="", en...
jku-encyclopedia
scripts/tfidf_umap_cosmograph.py
Python
aff19ed4e0b78a0afe2c12036e1a13472de96174b485dc51e7c674f74710dfea
3
619
"""JKU Knowledge Base -- automated pipeline for scraping, chunking, embedding, and knowledge-graphing JKU Linz data."""
jku-encyclopedia
src/jku_kb/__init__.py
Python
590ecf1eb4e6cbe9ba346b319febc0315305917bad539ac217a064586082ece6
0
28
"""JKU Knowledge Base — config module. All configuration is loaded from environment variables via pydantic-settings. """ from __future__ import annotations from pathlib import Path from typing import Literal from pydantic import BaseModel, Field from pydantic_settings import BaseSettings, SettingsConfigDict class...
jku-encyclopedia
src/jku_kb/config.py
Python
c4a624f3010694341fa9fa8d67d7a66d5a0a5763bd517042060df9618bb40e85
0
896
bioinf.jku.at/research/", "https://www.bioinf.jku.at/publications/", ], max_pages=500, include_patterns=[], exclude_patterns=[], ), "fmv_jku": CrawlVariantConfig( scraper_class="web_crawl", start_urls=[ ...
jku-encyclopedia
src/jku_kb/config.py
Python
6887e5d98e652b56ba8cf199e1c7815c622ba3b0bf7242d422b6404cb526e61d
1
387
"""JKU Knowledge Base — structured logging setup.""" from __future__ import annotations import logging import sys import structlog def setup_logging(log_level: str = "WARNING") -> None: """Configure structlog with human-readable output on stderr. Logs go to *stderr* so they never interfere with Rich progr...
jku-encyclopedia
src/jku_kb/logging.py
Python
9ea5a61258786eb6412adf4c500951f9ae49135642904af6201eed4de391944f
0
428
"""JKU Knowledge Base — data models. All core domain types used across the pipeline. """ from __future__ import annotations from datetime import UTC, datetime from enum import StrEnum from typing import Any from pydantic import BaseModel, ConfigDict, Field class Modality(StrEnum): """Content modality types fo...
jku-encyclopedia
src/jku_kb/models.py
Python
88a02e8305fabd7c38770121eb5c12ee2b88faf995c32c5bc264d3aea9485933
0
896
modality: Modality chunk_index: int chunk_total: int title: str = "" url: str = "" language: str = "en" author: str = "" year: int | None = None institute_id: str = "" topic_tags: list[str] = Field(default_factory=list) license: str = "unknown" # Modality-specific fields ...
jku-encyclopedia
src/jku_kb/models.py
Python
7873f75fe551a978e4b7c02201ba30c5d6c76bf1a957913796606c2c1752adc9
1
751
"""Concurrency probe — tests increasing parallelism levels against a target endpoint.""" from __future__ import annotations import asyncio import statistics import time from typing import Any import httpx import structlog PROBE_URL = "https://media.jku.at/search/episode.json" PROBE_LEVELS = [1, 3, 5, 10, 15, 20] PR...
jku-encyclopedia
src/jku_kb/probe.py
Python
55edfbc64b3647d33951871c68bbc6a1dcedf61dffa03b6d25577029b0836469
0
597
"""JKU Knowledge Base -- source quality gates. Provides pre-run health probes, post-discover content validation, and threshold enforcement for the pipeline. """ from __future__ import annotations import asyncio import json import time from pathlib import Path import httpx from jku_kb.logging import get_logger from ...
jku-encyclopedia
src/jku_kb/quality.py
Python
227be86cd719d2d44ab0b5eacdd761846a4632ba263dc16c7b419dcb26ce3931
0
896
total=len(results), healthy=healthy) return results def validate_discovered_items( items: list[RawItem], quality: SourceQuality, source_id: str, ) -> list[RawItem]: """Filter items below min_text_length. Log per-source summary.""" if not items or quality.min_text_length <= 0: # Still c...
jku-encyclopedia
src/jku_kb/quality.py
Python
e2a5b148402ea5302fa52c786665df7558ee40198146391413570c7f3cd25eb6
1
298
"""JKU Knowledge Base — chunker registry and dispatcher.""" from __future__ import annotations from jku_kb.chunkers.audio_chunker import AudioChunker from jku_kb.chunkers.base import BaseChunker from jku_kb.chunkers.caption_chunker import CaptionChunker from jku_kb.chunkers.code_chunker import CodeChunker from jku_kb...
jku-encyclopedia
src/jku_kb/chunkers/__init__.py
Python
56a703b2df241f0a1b00eeba45492badcf9d13d6ca8a481cb58d3ac2fd2630ef
0
268
"""Audio chunker — splits audio into 75s segments with 10s overlap via ffmpeg.""" from __future__ import annotations import asyncio from pathlib import Path import ffmpeg from jku_kb.chunkers.base import BaseChunker from jku_kb.chunkers.video_chunker import _compute_segments, _get_duration from jku_kb.models import...
jku-encyclopedia
src/jku_kb/chunkers/audio_chunker.py
Python
2c189fd30c7597efaf743fac5707a2aea23ea9aaeef64141a2812199659a00a8
0
561
"""JKU Knowledge Base — BaseChunker ABC. Provides the interface and common utilities for all modality-specific chunkers. """ from __future__ import annotations from abc import ABC, abstractmethod from pathlib import Path from jku_kb.logging import get_logger from jku_kb.models import Chunk, Modality, RawItem clas...
jku-encyclopedia
src/jku_kb/chunkers/base.py
Python
6e3bc3b342d07a57a7254cba8b5b3f2a5fa4a4b921a797be90ba1d23046e43d1
0
276
"""Caption chunker — parses VTT/SRT caption files into text chunks.""" from __future__ import annotations import re from dataclasses import dataclass from pathlib import Path from jku_kb.chunkers.base import BaseChunker from jku_kb.chunkers.text_chunker import TextChunker from jku_kb.models import Chunk, Modality, R...
jku-encyclopedia
src/jku_kb/chunkers/caption_chunker.py
Python
0ce57e70d3033957cc86e14f68407ee889de090742c2c04411f9669ebbd0dbae
0
896
end)}] {c.text}" for c in cues) output_dir.mkdir(parents=True, exist_ok=True) text_path = output_dir / f"{item.item_id}_caption.txt" text_path.write_text(combined, encoding="utf-8") chunks = await self._text_chunker.chunk(item, text_path, output_dir) # Add caption_source metadat...
jku-encyclopedia
src/jku_kb/chunkers/caption_chunker.py
Python
a46ae28ca97b6e05b04c534da204309069ec404881674727887cafbec5e0da5b
1
113
"""Code chunker — AST-aware splitting via chonkie CodeChunker (tree-sitter).""" from __future__ import annotations import asyncio from pathlib import Path import tiktoken from chonkie import CodeChunker as _ChonkieCodeChunker from jku_kb.chunkers.base import BaseChunker from jku_kb.models import Chunk, ChunkStatus,...
jku-encyclopedia
src/jku_kb/chunkers/code_chunker.py
Python
048dc0fb24ab42e6bf18ea8924cdb06ed8f4422f28ef6b05fb662c32c5fd8d09
0
896
if tree-sitter fails, split at midpoint self.log.warning("treesitter_fallback", item_id=item.item_id, lang=lang) lines = text.split("\n") mid = len(lines) // 2 chonkie_chunks_raw = ["\n".join(lines[:mid]), "\n".join(lines[mid:])] chonkie_chunks_raw = [s for s ...
jku-encyclopedia
src/jku_kb/chunkers/code_chunker.py
Python
5404ef0052185bfa835adcc3a2b884a4d552afc763b0d04a7936c3af12e61c2b
1
381
"""Image chunker — pass-through (one image = one chunk).""" from __future__ import annotations from pathlib import Path from jku_kb.chunkers.base import BaseChunker from jku_kb.models import Chunk, ChunkStatus, Modality, RawItem class ImageChunker(BaseChunker): """Image pass-through: each image is a single chu...
jku-encyclopedia
src/jku_kb/chunkers/image_chunker.py
Python
fd0ee6ed49a6bb037ebf56aa1a7ad9563a9f8dfcad2f8073915194cb6027f3cf
0
304
"""PDF chunker — splits PDFs into 6-page segments with overlap via pymupdf.""" from __future__ import annotations import asyncio from pathlib import Path import fitz # pymupdf from jku_kb.chunkers.base import BaseChunker from jku_kb.models import Chunk, ChunkStatus, Modality, RawItem # Skip PDFs larger than 200 M...
jku-encyclopedia
src/jku_kb/chunkers/pdf_chunker.py
Python
e98e39492eec5fe47d9ad5ad44f29f9e3c1ad70860a00944a2e4b96188b0cb28
0
885
"""Text chunker — splits text into 8000-token windows with overlap via chonkie.""" from __future__ import annotations import asyncio from pathlib import Path import tiktoken from chonkie import TokenChunker as _ChonkieTokenChunker from jku_kb.chunkers.base import BaseChunker from jku_kb.models import Chunk, ChunkSt...
jku-encyclopedia
src/jku_kb/chunkers/text_chunker.py
Python
760f48868684045c8c51863ea5f62e548519d1ce06cb1bd6ae93894345808875
0
651
"""Video chunker — audio-aware segments (75s with audio, 110s video-only) via ffmpeg.""" from __future__ import annotations import asyncio from pathlib import Path import ffmpeg from jku_kb.chunkers.base import BaseChunker from jku_kb.models import Chunk, ChunkStatus, Modality, RawItem def _get_duration(path: Pat...
jku-encyclopedia
src/jku_kb/chunkers/video_chunker.py
Python
59ac0835fcd1bc67df5209dd1072e9ba98e22b713e6230ffabc14554d5007021
0
896
.year, local_path=str(chunk_path), start_time_seconds=start, end_time_seconds=end, duration_seconds=end - start, chunk_status=ChunkStatus.CHUNKED, ) chunks = await asyncio.gather( *[_extract_segment(idx, sta...
jku-encyclopedia
src/jku_kb/chunkers/video_chunker.py
Python
08b856673ba2bf3c12e27475dc6c06bec7d5409ee90799f736d7d67524324b73
1
95
"""Typer CLI entry point for the JKU Knowledge Base pipeline.""" from __future__ import annotations import typer from rich.console import Console app = typer.Typer(name="jku-kb", help="JKU Knowledge Base Pipeline CLI") console = Console() # Import command modules to register @app.command() decorators from jku_kb.cl...
jku-encyclopedia
src/jku_kb/cli/__init__.py
Python
ea8f37d5204fd34d5b26a73a4effe7ef08d5aea47af4f9cefd5a833ba88d7120
0
196
"""Admin commands: status, probe, export, stats, validate.""" from __future__ import annotations from typing import Any import typer from rich import box from rich.panel import Panel from rich.table import Table from jku_kb.cli import app, console from jku_kb.cli.helpers import _run from jku_kb.config import get_se...
jku-encyclopedia
src/jku_kb/cli/admin.py
Python
85f5ddd122eac62d990ebecd9ff32d1d5206ff20eecb3e830c3ac139be078c7a
0
896
item in items[:3]: table.add_row(item.title or item.item_id, item.url) console.print(table) _run(_probe()) @app.command() def export( output_format: str = typer.Argument(default="graphml", help="Export format: graphml"), output: str = typer.Option("./data/export.graphm...
jku-encyclopedia
src/jku_kb/cli/admin.py
Python
9d637f83a654cb10c1d7c36b5f7487d5622340da76ac45a5a88899edf1006672
1
896
/yellow] {stats_data['neo4j_error']}") if "qdrant_error" in stats_data: console.print(f"[yellow]Qdrant unavailable:[/yellow] {stats_data['qdrant_error']}") @app.command() def validate() -> None: """Check data integrity: orphan nodes, broken NEXT_CHUNK chains, missing edges.""" settings = get_setti...
jku-encyclopedia
src/jku_kb/cli/admin.py
Python
8b3e4accaf6a9c1f9573dabad26807abf54beb97415eede7a9a220e6a304ceed
2
707
"""Pipeline commands: run, discover, fetch, chunk, embed, link.""" from __future__ import annotations import time from typing import Any import typer from rich import box from rich.rule import Rule from rich.table import Table from jku_kb.cli import app, console from jku_kb.cli.dashboard import LiveDashboard, _phas...
jku-encyclopedia
src/jku_kb/cli/commands.py
Python
48c394ef1f7d8344b844a302018a16af247bf5ce60e79faa7e860a2526d0e51f
0
896
", "taxonomy", "similarity_edges", "next_chunk_edges"] t0 = time.monotonic() with LiveDashboard(console, link_ops, "link") as dashboard: link_results = await orchestrator.run_phase_link( progress_callback=dashboard.progress_callback, ) ...
jku-encyclopedia
src/jku_kb/cli/commands.py
Python
cee5964a014bf45dfb9ba263c1b96006fab19c9cb10925fb32dc95bcb2c4f572
1
896
", justify="right", style="red") total_fetched = 0 total_failed = 0 for src, data in sorted(result.items()): fetched = data.get("fetched", 0) if isinstance(data, dict) else 0 failed = data.get("failed", 0) if isinstance(data, dict) else 0 table.add_row(src, f"{fetched:,}", f"{failed...
jku-encyclopedia
src/jku_kb/cli/commands.py
Python
f6787fb111485a6a036fa4d309b33e7072e5cdd0d7038c8dc1bc4766fc6902b5
2
896
0, 1), ) table.add_column("Operation") table.add_column("Edges", justify="right") total = 0 for op, count in result.items(): table.add_row(op, f"{count:,}") total += count table.add_section() table.add_row("[bold]Total[/bold]", f"[bold]{total:,}[/bold]") console.print(...
jku-encyclopedia
src/jku_kb/cli/commands.py
Python
7ff2e82387a9d165963a763e4deabf8f9ba8a2f734503e3732cbf308308d5950
3
128
"""Rich Live dashboard and display utilities for the CLI.""" from __future__ import annotations import dataclasses import time from typing import Any from rich import box from rich.panel import Panel from rich.table import Table from rich.text import Text from jku_kb.cli import console from jku_kb.cli.helpers impor...
jku-encyclopedia
src/jku_kb/cli/dashboard.py
Python
22e86c41cc6a134547e5b99292d3754fb9d16aa5948104f77360185e35c87721
0
896
ok[/green]" elif state.status == "running": status_text = "[yellow]● running[/yellow]" else: status_text = "[dim]○ pending[/dim]" elapsed = ( time.monotonic() - state.start_time if state.start_time > 0 else 0.0 ) elapsed_str = f"{elapsed:.1f}s"...
jku-encyclopedia
src/jku_kb/cli/dashboard.py
Python
c481c12867ca90728c15543ba7425aed2e8055b368c0a648e1803735c8fe2609
1
896
" elif advance == -1: state.status = "ok" else: if state.start_time == 0.0: state.start_time = time.monotonic() # Fallback if no advance==0 signal state.items += advance state.status = "running" # Compute ETA or throughput ...
jku-encyclopedia
src/jku_kb/cli/dashboard.py
Python
5cce9b82529e9a1f75d4bafb106e3f19277ae9994e0c6443f3aef5f6c7e26159
2
604
"""Shared CLI helper functions.""" from __future__ import annotations import asyncio from pathlib import Path from typing import Any import orjson import typer from rich import box from rich.table import Table from jku_kb.cli import app, console from jku_kb.config import get_settings, warn_if_missing_keys from jku_...
jku-encyclopedia
src/jku_kb/cli/helpers.py
Python
0cbd814c7b3e42fa153cc0b5b5459743459698f93e51689f3afc24201aef6623
0
896
str, phase: str) -> dict[str, Any]: """Read manifest JSONL to extract item count and last timestamp.""" manifest = cache_dir / source_id / f"{phase}_done.jsonl" if not manifest.exists(): return {"count": 0, "last_ts": None} count = 0 last_ts: str | None = None with open(manifest, "rb") a...
jku-encyclopedia
src/jku_kb/cli/helpers.py
Python
deaede2fd750b8008e0865a915574698ea239007af944487bdb0cf8c55bd5ed9
1
519
"""Verify command and health status utilities.""" from __future__ import annotations import asyncio from pathlib import Path from typing import Any import orjson import typer from rich import box from rich.table import Table from jku_kb.cli import app, console from jku_kb.cli.helpers import _format_modality_counts,...
jku-encyclopedia
src/jku_kb/cli/verify.py
Python
056d3ea699684bb2085ba737f5b26c56085d202b856ec13365c150609b6f8abf
0
896
) table.add_column("Source", min_width=28) table.add_column("Status", min_width=8) table.add_column("Expected", justify="right", min_width=10) table.add_column("Actual", justify="right", min_width=10) table.add_column("Ratio", justify="right", min_width=8) if show_modality: table.add_col...
jku-encyclopedia
src/jku_kb/cli/verify.py
Python
a61435aa0f5df49e5baec14b0f861972d67905689e891033b60d466599d2f154
1
896
= await run_health_probes(entries, source_ids) probe_map = {r.source_id: r for r in probe_results} # Step 3: Concurrent discover with semaphore sem = asyncio.Semaphore(5) results: list[dict[str, Any]] = [] async def _verify_one(sid: str) -> dict[str, Any]: async wit...
jku-encyclopedia
src/jku_kb/cli/verify.py
Python
f6a5970531ecd26493d20399e7447529ce166a6de13d5f820bb6c33c825cde54
2
896
.echo(_orjson.dumps(output).decode()) # CI-friendly exit code: 0 if all pass/warn, 1 if any fail has_fail = any(r["status"] in ("fail", "error") for r in results) if has_fail: raise typer.Exit(1)
jku-encyclopedia
src/jku_kb/cli/verify.py
Python
ecb09d7e13eacf21e63d0c9ae5da2610eb7eee11984f6f7bcff1b45d984ef975
3
67
"""Embedding module providing Gemini API integration and batch embedding orchestration."""
jku-encyclopedia
src/jku_kb/embedders/__init__.py
Python
58ab066719b578080de68d9d77d74bbd76f686ea116dc9539acb9670ea7efce8
0
17
"""Batch embedding orchestrator with rate limiting and dual-store callback.""" from __future__ import annotations import asyncio from collections.abc import Callable, Coroutine from datetime import UTC, datetime from pathlib import Path from typing import Any import orjson from aiolimiter import AsyncLimiter from j...
jku-encyclopedia
src/jku_kb/embedders/batch.py
Python
05be979c334242205a67ed260a62ab935faa086bf430814c7cdba65399cffc5e
0
896
occur. if result.embed_status != EmbedStatus.EMBEDDED: return # Rerun skip: if chunk_id already appears in the source dead-letter file, skip it. source_dead_letters = await _get_source_dead_letters(chunk.source_id) if chunk.chunk_id in source_dead_letters: log.in...
jku-encyclopedia
src/jku_kb/embedders/batch.py
Python
082b3c1bac33e7e23a37442cedec4b5e4ec8745b334c450b383f7204d985ee63
1
896
= await self.embedder.embed_chunk(chunk) if on_result: await on_result(chunk, result) return result async with asyncio.TaskGroup() as tg: for chunk in chunks: task = tg.create_task(_embed_one(chunk)) tasks.append(ta...
jku-encyclopedia
src/jku_kb/embedders/batch.py
Python
858f930f55675bb51673e47e8d133b6e32bc834409d9e70ddfc0e2a08a7c9d7e
2
174
"""Gemini embedding client for multimodal content.""" from __future__ import annotations import asyncio import contextlib from datetime import UTC, datetime from pathlib import Path from typing import Any from google import genai from google.genai import types from tenacity import retry, retry_if_exception, stop_aft...
jku-encyclopedia
src/jku_kb/embedders/gemini.py
Python
4e6019b710608e3d8255a621e8bc8e5e290997c6771575bc1e363f3aacdb3abc
0
896
""Call embed_content via asyncio.to_thread with tenacity retry.""" assert self._client is not None return await asyncio.to_thread( self._client.models.embed_content, model=self.model, contents=contents, config=EMBED_CONFIG, ) async def embed_c...
jku-encyclopedia
src/jku_kb/embedders/gemini.py
Python
89d2a768ac6d3ed58727a84f82901444efdfd267aa7c633e80682b64630822fe
1
896
}, ) try: result = await self._call_embed_content(file_ref) assert result.embeddings is not None, "embed_content returned no embeddings" assert result.embeddings[0].values is not None, "embedding values is None" vector = list(result.embeddings[0].values) ...
jku-encyclopedia
src/jku_kb/embedders/gemini.py
Python
7f86895df3418798e267fd2d9d49f3db891d70853b8e9204d80a24897c62cd64
2
896
older than max_age_hours. Returns deleted count.""" assert self._client is not None deleted = 0 files_list = await asyncio.to_thread(self._client.files.list) for f in files_list: if f.create_time is None or f.name is None: continue age_hours = (dat...
jku-encyclopedia
src/jku_kb/embedders/gemini.py
Python
d5f63b4d5b81cd95b8a24d2277b030be9e1017f52d32f46caab308ac95698bc5
3
896
"image/jpeg", ".jpeg": "image/jpeg", ".png": "image/png", ".gif": "image/gif", ".webp": "image/webp", ".mp4": "video/mp4", ".mov": "video/quicktime", ".webm": "video/webm", ".mp3": "audio/mpeg", ".wav": "audio/wav", ".ogg": "audio/ogg", ...
jku-encyclopedia
src/jku_kb/embedders/gemini.py
Python
cfa485df168f25de246729a035453787d89a31480b197893cb740e3de65c9347
4
152
"""Graph module providing Neo4j edge creation, taxonomy assignment, and similarity linking."""
jku-encyclopedia
src/jku_kb/graph/__init__.py
Python
e02044ca57bdb0b48bc46f8ec1aa2d5ea1df729e0df5a1c8d3f1570524313a2a
0
20
"""NEXT_CHUNK sequential edge builder.""" from __future__ import annotations from collections import defaultdict from typing import Any from jku_kb.logging import get_logger log = get_logger("graph.next_chunk") async def build_next_chunk_edges(neo4j_store: Any) -> int: """Query Neo4j for multi-chunk items, cr...
jku-encyclopedia
src/jku_kb/graph/next_chunk.py
Python
c7f87a512f67543e101507a66208eb1e6996fdad95a8f3def7c6409d2ebaa378
0
402
"""Structural seed edges from research report.""" from __future__ import annotations import json from pathlib import Path from typing import Any from jku_kb.logging import get_logger log = get_logger("graph.seed_edges") def load_seed_edges(path: Path) -> list[dict[str, Any]]: """Load seed edge definitions fro...
jku-encyclopedia
src/jku_kb/graph/seed_edges.py
Python
f7a5a006efef435a7aca707d5a45d4f8269127f9fc89191acf359248c84fba12
0
384
"""Cosine similarity backlink computation.""" from __future__ import annotations import json from pathlib import Path from typing import cast from jku_kb.config import Settings from jku_kb.logging import get_logger from jku_kb.storage.neo4j import Neo4jStore from jku_kb.storage.qdrant import QdrantStore log = get_l...
jku-encyclopedia
src/jku_kb/graph/similarity.py
Python
3b954d736bf9e54ca1a2bfdd0aebd5ec9f8d18ad2912b6d03b1113816d0559cc
0
896
, ) points, next_offset = scroll_result if not points: break edge_batch: list[tuple[str, str, float, bool]] = [] seen: set[tuple[str, str]] = set() for point in points: if not point.vector or not point.payload: continue ...
jku-encyclopedia
src/jku_kb/graph/similarity.py
Python
dd3590eb5a3fc314a283d18f14eca3047fc3ed5c985be43ba0a34539b97db9dc
1
375
"""Topic taxonomy assignment.""" from __future__ import annotations import json from pathlib import Path from typing import Any from jku_kb.logging import get_logger from jku_kb.models import Chunk, Modality log = get_logger("graph.taxonomy") class TaxonomyAssigner: """Assigns topic tags to chunks based on ke...
jku-encyclopedia
src/jku_kb/graph/taxonomy.py
Python
08f4584298c661d0f2bdea14c3f6f4b90c765376fcca9965e94779ee77ad6afb
0
896
topics def _build_searchable_text(chunk: Chunk) -> str: """Build text from chunk metadata for keyword matching.""" parts = [chunk.title, chunk.text_content] if chunk.metadata: parts.append(str(chunk.metadata.get("description", ""))) parts.append(" ".join(chunk.metadata.get("categories", []...
jku-encyclopedia
src/jku_kb/graph/taxonomy.py
Python
369d9697c50f9a9d393d2ed08bb6bbfdfa2b4c29ca069d16648c4606d1d3a3df
1
102
"""Graph visualization export (Neo4j → GraphML for Gephi).""" from __future__ import annotations import xml.etree.ElementTree as ET from pathlib import Path from jku_kb.logging import get_logger from jku_kb.storage.neo4j import Neo4jStore log = get_logger("graph.visualization") async def export_graphml(neo4j: Neo...
jku-encyclopedia
src/jku_kb/graph/visualization.py
Python
7e9544f4ca323c8f064f727394898d8f71ea5d1d81a70b8c0b20984daecb6b20
0
838
"""Main pipeline orchestrator with phased execution.""" from __future__ import annotations from collections.abc import Callable from contextlib import asynccontextmanager from typing import Any import httpx from jku_kb.config import Settings from jku_kb.logging import get_logger from jku_kb.orchestrator.chunk import...
jku-encyclopedia
src/jku_kb/orchestrator/__init__.py
Python
cfed25afc527d039927634ba61706b99f9040ecdb837c6f0eeb150494bd94609
0
896
await run_phase_link(ctx, mode=mode) async def run_all( self, source_ids: list[str] | None = None, max_items_per_source: int | None = None, progress_callback: ProgressCallback = None, error_callback: ErrorCallback = None, phase_callback: Callable[[str], None] | None ...
jku-encyclopedia
src/jku_kb/orchestrator/__init__.py
Python
b539a0a284176c2c7ee057fb3c7063bbc396c9ae7e8ef998c680efa3dc11977d
1
869
"""Chunk phase — split fetched items into chunks (parallel within sources).""" from __future__ import annotations import asyncio from pathlib import Path from typing import Any import orjson from jku_kb.logging import get_logger from jku_kb.models import Chunk, FetchStatus, ManifestEntry, RawItem from jku_kb.orchest...
jku-encyclopedia
src/jku_kb/orchestrator/chunk.py
Python
6186273cc750ff7e79f1d11c3f98470a06fa35a42d813f789ed5cb75418b4cc5
0
896
to prevent OOM try: file_size = local_path.stat().st_size if file_size > MAX_FILE_SIZE_BYTES: log.warning( "file_too_large_skipped", item_id=entry.item_id, ...
jku-encyclopedia
src/jku_kb/orchestrator/chunk.py
Python
0c2fabb61afaf36b5d2ea20a630faedef229ba40a84247b8a526e12ccaf4d786
1
489
"""Discover phase — find items from all sources. Pipeline: health probe -> discover -> content validate. """ from __future__ import annotations import asyncio from jku_kb.logging import get_logger from jku_kb.orchestrator.helpers import PipelineContext from jku_kb.quality import ( get_quality_for_source, loa...
jku-encyclopedia
src/jku_kb/orchestrator/discover.py
Python
7fb07157d7b438f26355effbd1c0169ff8608f47b4b11a233f7844cdf8f8971f
0
659
"""Embed phase — generate embeddings and store in vector DB.""" from __future__ import annotations import asyncio from collections import Counter from typing import Any from jku_kb.embedders.batch import BatchEmbedder from jku_kb.embedders.gemini import GeminiEmbedder from jku_kb.logging import get_logger from jku_kb...
jku-encyclopedia
src/jku_kb/orchestrator/embed.py
Python
1c90a1becf9b8dc765d0b492869cd75c0ab6d3337d5679de1fe9b657fc790988
0
793
"""Fetch phase — download discovered items.""" from __future__ import annotations import asyncio from jku_kb.logging import get_logger from jku_kb.models import FetchStatus from jku_kb.orchestrator.helpers import PipelineContext from jku_kb.scrapers import get_scraper log = get_logger("orchestrator.fetch") async d...
jku-encyclopedia
src/jku_kb/orchestrator/fetch.py
Python
0d27a534896a24858dc894ac49848eb6585530e8846006aa00bb1d24b1b9eb8c
0
458
"""Shared helpers for the orchestrator pipeline package. Provides: - Type aliases (ProgressCallback, ErrorCallback) - PipelineContext frozen dataclass - Manifest utilities (_phase_manifest_path, _load_done_ids) - ManifestWriter buffered JSONL writer (PERF-01) - _guess_modality utility """ from __future__ import annota...
jku-encyclopedia
src/jku_kb/orchestrator/helpers.py
Python
3abe9cb6f8ccbb0cee1feb0cf3b64b37d409c092489b05b624180dfc3fbd1e5b
0
896
Returns an empty set if the file does not exist or all lines are corrupt. """ if not manifest_path.exists(): return set() ids: set[str] = set() with open(manifest_path, "rb") as f: for line in f: line = line.strip() if not line: continue ...
jku-encyclopedia
src/jku_kb/orchestrator/helpers.py
Python
494a1a365c0efb781bec7e2e484493d35dfe424e828ac604dcea08b0b7aff6c3
1
896
Modality.AUDIO if ext in (".jpg", ".jpeg", ".png", ".gif", ".webp"): return Modality.IMAGE if ext in (".py", ".js", ".ts", ".rs", ".go", ".java", ".c", ".cpp", ".h"): return Modality.CODE return Modality.TEXT
jku-encyclopedia
src/jku_kb/orchestrator/helpers.py
Python
5fbf27b947f56c6b6d7a0196a81a2699073709a637cbe69cd737739a940030e3
2
95
"""Link phase — create graph edges.""" from __future__ import annotations from datetime import UTC, datetime import orjson from jku_kb.graph.next_chunk import build_next_chunk_edges from jku_kb.graph.seed_edges import insert_seed_edges, load_seed_edges from jku_kb.graph.similarity import compute_similarity_backlinks...
jku-encyclopedia
src/jku_kb/orchestrator/link.py
Python
596752330c8253a7553aae95893399da18d34cfa37fdd1b5f85701c53ea8e260
0
516
"""Scraper module providing data source connectors for all JKU knowledge sources.""" from __future__ import annotations from typing import Any import httpx from jku_kb.config import Settings _REGISTRY: dict[str, type] = {} def register_scraper(source_id: str): """Class decorator that registers a scraper class...
jku-encyclopedia
src/jku_kb/scrapers/__init__.py
Python
1dbba13816dd101d9814c5e2de2fcf5706a67b69fa34da0d62000049c2ec0d2d
0
611
"""arXiv API scraper for JKU preprints.""" from __future__ import annotations import xml.etree.ElementTree as ET from typing import Any from jku_kb.config import Settings from jku_kb.models import FetchResult, FetchStatus, Modality, RawItem from jku_kb.scrapers import register_scraper from jku_kb.scrapers.base impor...
jku-encyclopedia
src/jku_kb/scrapers/arxiv.py
Python
adcc75c92b1ff229d5b003bc403e3fa641828c80454b7c51aa10daa1f11e2d5d
0
896
items async def _do_fetch(self, item: RawItem) -> FetchResult: pdf_url = item.metadata.get("pdf_url", "") if not pdf_url: return FetchResult( item_id=item.item_id, source_id=self.source_id, fetch_status=FetchStatus.SKIPPED, ...
jku-encyclopedia
src/jku_kb/scrapers/arxiv.py
Python
682190438483ec2bd4a9ffb8c172cee2b88c96ef00706ae8359541a3ce6f56c0
1
896
= entry.get("authors", []) first_author = authors[0] if authors else "" # Ensure PDF URL exists pdf_url = entry.get("pdf_url", "") if not pdf_url and arxiv_id: pdf_url = f"https://arxiv.org/pdf/{arxiv_id}.pdf" return RawItem( item_id=arxiv_id.replace("/", "_").replace(".", "_"), ...
jku-encyclopedia
src/jku_kb/scrapers/arxiv.py
Python
dbe95c80df3298ea46263f022cc71b5396362b07fb838f46a90a47c00f3ed760
2
220
"""JKU Knowledge Base — BaseScraper ABC. Provides rate limiting, retry, caching, manifest tracking, and progress reporting. """ from __future__ import annotations import asyncio import contextlib import hashlib from abc import ABC, abstractmethod from pathlib import Path from typing import Any import httpx import o...
jku-encyclopedia
src/jku_kb/scrapers/base.py
Python
2fd595ebfb7292340c707b0c4c0468f8f422d81461755bdfb28b7ab14278da68
0
896
self._shared_client = client # Shared client from PipelineContext (PERF-02) # Directories self.cache_dir = settings.cache_dir / source_id self.cache_dir.mkdir(parents=True, exist_ok=True) self.chunks_dir = self.cache_dir / "chunks" self.chunks_dir.mkdir(parents=True, exist_ok=T...
jku-encyclopedia
src/jku_kb/scrapers/base.py
Python
914574c36f4d5aee2449fdb753fe988e225d56cc986827ca72389ec5a9426777
1
896
= 429: retry_after = int(response.headers.get("Retry-After", "30")) self.log.warning("rate_limited", url=url, retry_after=retry_after) await asyncio.sleep(retry_after) continue if response.status_code >= 500: if attempt >= 4: ...
jku-encyclopedia
src/jku_kb/scrapers/base.py
Python
e75c45a789ded100219b682afe0fed212dc8f3c9984259c3083f2efa44d60562
2
896
= self._manifest[item.item_id] return FetchResult( item_id=item.item_id, source_id=self.source_id, local_path=entry.local_path, fetch_status=FetchStatus.FETCHED, ) try: return await self._do_fetch(item) e...
jku-encyclopedia
src/jku_kb/scrapers/base.py
Python
2a8551dd267226999c296e172ab7da7bd59b7fefed7a53cce0e1f22224025e85
3
896
in results if r.fetch_status == FetchStatus.FETCHED) self.log.info("fetch_complete", total=len(results), success=success) return results async def close(self) -> None: """Close the HTTP client. Only closes the scraper-owned client. The shared client (self._shared_client) is...
jku-encyclopedia
src/jku_kb/scrapers/base.py
Python
b54ed4362e4eba860e614880341cf86c1f10acd990e37a217ed1b17b8ca3c2e3
4
151
"""Europe PMC API scraper.""" from __future__ import annotations from typing import Any from jku_kb.config import Settings from jku_kb.models import FetchResult, FetchStatus, Modality, RawItem from jku_kb.scrapers import register_scraper from jku_kb.scrapers.base import BaseScraper API_BASE = "https://www.ebi.ac.uk...
jku-encyclopedia
src/jku_kb/scrapers/europe_pmc.py
Python
95c7cfe8cb6d69e22f235c61cf96d8ec48c4df65c2651bf4c53b3586f9fd6293
0
788