Giter VIP home page Giter VIP logo

Comments (3)

TessavWalstijn avatar TessavWalstijn commented on May 27, 2024 1

Thanks! For the look. It was the typo.

TIL about @zazuko/env and will look in to it

from clownface.

tpluscode avatar tpluscode commented on May 27, 2024 1

tl;dr; for @zazuko/env you'd need to add the parsers yourself as they are excluded to reduce dependencies if used in the browser.

@zazuko/env-node includes parsers/serializers and also an additional utility to access the filesystem (https://npm.im/@zazuko/rdf-utils-fs)

from clownface.

tpluscode avatar tpluscode commented on May 27, 2024

There is no short answer because the a shorthand for rdf:type is a feature of turtle serialisation. Clownface only deals with parsed graphs in memory. I suppose NO is the short answer and when accessing the graph with clownface, the rdf:type term has to be used.

The problem appears to be the casing. It should be Ns.rdf.type (lower case) to match the actual URL

I looked at you snippet after all, and I might suggest some simplifications. I change rdf-ext to @zazuko/env because the former has recently removed clownface and we also added some since features, such as common namespaces built-in and type declarations. That also includes type-checking for vocabularies, which would have alerted you about that above.

Here's how much can can abbreviate but using all library features (most of which is available in the libs you import above, only more tightly packed in @zazuko/env-node)

import rdf from '@zazuko/env-node'

const response = await rdf.fetch('http://zazuko.github.io/tbbt-ld/dist/tbbt.nt')
if (!response.ok) {
  // TODO: handle request error
}

const dataset = await response.dataset()

const data = rdf.clownface({ dataset })
const quads = data.has(rdf.ns.rdf.type, rdf.ns.schema.Person)

quads.forEach((quad) => {
    const source = {
        iri: quad.term.value,
        name: quad.out(rdf.ns.schema.givenName).value
    }

  console.log(source)
})

from clownface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.