from spacy import displacy from spacy.tokens import Doc from spacy.util import get_lang_class from pathlib import Path words = ["The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "fox"] heads = [3, 3, 3, 4, 4, 4, 8, 8, 5] deps = ["det", "amod", "amod", "nsubj", "ROOT", "prep", "pobj", "det", "amod"] doc = Doc(get_lang_class("en")().vocab, words=words, heads=heads, deps=deps) html = displacy.render(doc) output_path = Path("depdendencymatchertest.html") output_path.open("w", encoding="utf-8").write(html)