#!/usr/bin/env python3 """Parse the ollama library page text dump and list unique models.""" import re, json, sys raw = open('scripts/ollama_library_full.txt').read() first_line = raw.split('\n')[0] # Each line is prefixed "N| " repeated; find the first { and the last } start = first_line.find('{') end = first_line.rfind('}') + 1 first_line = first_line[start:end] j = json.loads(first_line) text = j['text'] print('text length:', len(text)) # Pattern: ## [name desc](https://ollama.com/library/normalized) matches = re.findall(r'## \[([a-z0-9.\-]+) [^\]]*\]\(https://ollama.com/library/([a-z0-9.\-]+)\)', text) seen = {} for desc, name in matches: seen.setdefault(name, desc) print('Total models in library page:', len(seen)) for n in sorted(seen): print(f'{n}\t{seen[n][:80]}')