Giter Site home page Giter Site logo

Comments (2)

StephanLupp avatar StephanLupp commented on June 13, 2024 1

Hello Marco,

You are a live-safer, this is exactly what I was looking for.
Thanks for the very quick response and good example how to connect this. I never considered that "RDFPropertyConstraint" is used for this.

I do hope that we can contribute further, we will continue to use the library and post questions that we find or oddities that we notice.

Best Regards
Stephan

from rdfsharp.

mdesalvo avatar mdesalvo commented on June 13, 2024

Hi Stephan,
here is an implementation of the example turtle file showing usage of constraints and targets:

var shapesGraph = new RDFShapesGraph();

var nodeShape = new RDFNodeShape(new RDFResource("ex:PersonShape"));
nodeShape.AddTarget(new RDFTargetClass(new RDFResource("ex:Person")));
nodeShape.AddConstraint(new RDFPropertyConstraint(new RDFResource("ex:PropertyShapeSSN")));
nodeShape.AddConstraint(new RDFPropertyConstraint(new RDFResource("ex:PropertyShapeWorksFor")));
nodeShape.AddConstraint(new RDFClosedConstraint(true).AddIgnoredProperty(RDFVocabulary.RDF.TYPE));

var propertyShapeSSN = new RDFPropertyShape(new RDFResource("ex:PropertyShapeSSN"), new RDFResource("ex:ssn"));
propertyShapeSSN.AddConstraint(new RDFMaxCountConstraint(1));
propertyShapeSSN.AddConstraint(new RDFDatatypeConstraint(RDFModelEnums.RDFDatatypes.XSD_STRING));
propertyShapeSSN.AddConstraint(new RDFPatternConstraint(new Regex("^\\d{3}-\\d{2}-\\d{4}$")));

var PropertyShapeWorksFor = new RDFPropertyShape(new RDFResource("ex:PropertyShapeWorksFor"), new RDFResource("ex:worksFor"));
PropertyShapeWorksFor.AddConstraint(new RDFClassConstraint(new RDFResource("ex:Company")));
PropertyShapeWorksFor.AddConstraint(new RDFNodeKindConstraint(RDFValidationEnums.RDFNodeKinds.IRI));

shapesGraph.AddShape(nodeShape);
shapesGraph.AddShape(propertyShapeSSN);
shapesGraph.AddShape(PropertyShapeWorksFor);

It is of course possible to contribute to the library: posting questions, signalling issues, requesting new capabilities, also submitting PRs for targeting bugs or delivering new features.

Let me know if this coding example clarifies your doubts about usage of the library.
Regards,
marco

from rdfsharp.

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.