Files
nanobot-runtime/scripts/parse_library.py
2026-09-02 15:23:13 +02:00

25 lines
828 B
Python

#!/usr/bin/env python3
"""Parse the ollama library page text dump and list unique models."""
import re, json, sys
with open('scripts/ollama_library_full.txt', encoding='utf-8') as f:
raw = f.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]}')