Published
Edited
Jan 3, 2022
1 fork
6 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
button = Inputs.button(
[
[
"Add namespace prefixes from kg to editor",
async (value) => {
viewof y.editor.addPrefixes(
Object.fromEntries(
await py`#depends on ${kg} ${micropipDependenciesPy}
dict(${kg}.rdf_graph().namespaces())
`
)
);
}
],
[
"Autoformat",
(value) => {
viewof y.editor.autoformat();
}
],
[
"Reset query",
(value) => {
viewof y.editor.setValue(default_query);
}
]
],
{ label: "Change Editor Contents" }
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
kg = py`from os.path import dirname
import os
import io

kg = ${kglab}.KnowledgeGraph()
with open("chosen.ttl", "wb") as f:
f.write(${await kgzip.file(preloadFilename).arrayBuffer()}.tobytes())

kg.load_rdf("chosen.ttl")
kg`
Insert cell
kglab = py` # ${packagesPy}
import micropip
#make sure pyvis is installed first for sure
micropip.install("https://thadk.net/pyodide_packages/pyodide_18_1/pyvis-0.1.9-py2.py3-none-any.whl")

import kglab
# ${otherKglabDependencies} ${micropipDependenciesPy} ${kglabDependency}
kglab
`
Insert cell
py`dir(${kglab})`
Insert cell
py`repr(${kglab})`
Insert cell
kgzip = FileAttachment("kglab-main.zip").zip()
Insert cell
Yasgui = require("@triply/yasgui@4.2.20/build/yasgui.min.js")
Insert cell
import { view } from "@tomlarkworthy/view"
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more