Giter Club home page Giter Club logo

nsam's Introduction

N-Sam: A Lightweight N3 Parser in Java

1. Introduction

N-Sam is a small parser, written in Java, for parsing N3 files. N-Sam has no problem with typical N3 documents that include RDF and OWL sentences, but some complex constructs like embedded formulas and built-ins are not recognized.

2. A Basic Usage

A basic usage of N-Sam parser is as follows:

            ...
            String url = "file:///usr/etc/sample.n3";
            NSam parser = new NSam();
            StatementHandler h = new StatementHandlerImpl();
            parser.setStatementHandler(h);
            parser.read(url);
            ...

Parsed N3 constructs are notified via StatementHandler interface. StatementHandler includes the following notification methods:

void statement(Stirng subject, String predicate, String object, String objectType);
void prefix(String prefix, String uri);
void startFormula();
void endFormula();
void formulaConnector(String connector);

Details on the methods are provided as javadoc comments in the code.

3. Validation

N3 successfully parsed the following N3 documents:

http://www.agfa.com/w3c/euler/owl-rules.n3
http://www.w3.org/2000/10/swap/test/lists-simple.n3
http://www.w3.org/2002/03owlt/sameGuyC.n3
http://www.w3.org/2002/03owlt/sameGuyP.n3
http://www.w3.org/2002/03owlt/sameGuyR.n3
http://www.w3.org/2002/03owlt/sameGuyQ.n3
http://www.w3.org/2002/03owlt/sameGuyQR.n3
http://www.w3.org/2002/03owlt/sameGuyT.n3
http://www.w3.org/2002/03owlt/sameStateC.n3
http://www.w3.org/2002/03owlt/dbC.n3
http://www.w3.org/2002/03owlt/dbP.n3
http://www.w3.org/2002/03owlt/sameStateP.n3
http://www.w3.org/2002/03owlt/sem-intersectionC.n3
http://www.w3.org/2002/03owlt/unionOfC.n3
http://www.w3.org/2002/03owlt/unionOfP.n3
http://www.agfa.com/w3c/euler/danb.n3
http://www.agfa.com/w3c/euler/ziv.n3
http://www.agfa.com/w3c/euler/animal.n3
http://www.agfa.com/w3c/euler/gedcom-facts.n3
http://www.w3.org/2000/10/swap/test/s1.n3
http://www.agfa.com/w3c/euler/owl-facts.n3

And N3 failed with the following documents:

http://www.w3.org/2002/03owlt/sameStateR.n3
http://www.w3.org/2002/03owlt/sem-intersectionR.n3
http://www.w3.org/2000/10/swap/test/resolves-rdf.n3
http://www.w3.org/2000/10/swap/test/contexts.n3
http://www.w3.org/2000/10/swap/test/includes/quantifiers.n3
http://dev.w3.org/cvsweb/~checkout~/2000/10/swap/test/ref/strquot.n3

written by zebehn(minsu.jang (at) me.com)

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.