Skip to content
This repository has been archived by the owner on Mar 17, 2018. It is now read-only.
/ nxfilter Public archive

A command line tool for filtering RDF N-Triples or N-Quads

Notifications You must be signed in to change notification settings

j13z/nxfilter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nxfilter

A command line tool for filtering RDF N-Triples or N-Quads.

Usage

nxfilter lets you:

  • Use N-Triples / N-Quads in a Unix pipe to run small ad-hoc queries:

    curl -s http://dbpedia.org/data/Munich.ntriples | \
    nxfilter -p | sort | uniq -c | sort -n -r | head

    screenshot

  • Look at data files more conveniently in the terminal:

    curl -s 'http://dbpedia.org/data/Cut_(Unix).ntriples' | tail +10 | head -n 15 | \
    nxfilter -p -o --compact --no-protocol --limit 28

    screenshot

Like cut for N-x formats, plus some additional query features.

You can filter by:

  • Element position (-s, -p, -o, -g)
  • Type: --<element>:<type> (with types iri / bnode / literal)
  • Value: --<element>=<value>

Run nxfilter --help for detailed usage information.

Settings (colors and defaults) can be adjusted with a dotfile: ~/.nxfilterrc.

Examples

Get predicates and objects as TSV:

nxfilter -p -o --delimiter '\t' data.nt.gz

Get most frequent predicates (pipe):

cat data.nt | nxfilter -p | sort | uniq -c | sort -n -r | head

Output (predicate, object) tuples where the object is a literal:

nxfilter --predicate --object:literal data.nt.g

Installation

Requires Node.js (which is easy to install). With Node.js installed, get it via npm with

$ npm install -g nxfilter

which provides you with the nxfilter command on your shell, installed in user space.

Change Log

  • 1.0.6: Fixes nxfilter -h bug

About

A command line tool for filtering RDF N-Triples or N-Quads

Resources

Stars

Watchers

Forks

Packages

No packages published