npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sparql-faceter

v1.11.0

Published

Faceted search using AngularJS and SPARQL

Downloads

1

Readme

SPARQL Faceter

A paper describing SPARQL Faceter can be found here, although as of version 1.0.0 the implementation is quite different. Most importantly, rather than there being one SPARQL query to get the state of all the facets, each facet makes its own query.

Installation

Install via Bower:

bower install sparql-faceter

or

npm install sparql-faceter

Include seco.facetedSearch in your module dependencies:

angular.module('myApp', ['seco.facetedSearch'])

Include the script in your HTML:

<script src="bower_components/sparql-faceter/dist/semantic-faceted-search.js></script>

And additionally the dependencies defined in bower.json before the above script.

You can also include the stylesheet in the header:

<link rel="stylesheet" href="bower_components/angular-semantic-faceted-search/dist/semantic-faceted-search.css">

Then you're good to go!

Configuration and Usage

See the documentation.

Setup in the controller:

var vm = this;

// Define facets
vm.facets = {
    // Text facet
    name: {
        name: 'Name',
        facetId: 'name',
        predicate: '<http://www.w3.org/2004/02/skos/core#prefLabel>',
        enabled: true
    },
    // Date facet
    deathDate: {
        name: 'Time of Death',
        facetId: 'death',
        startPredicate: '<http://ldf.fi/schema/narc-menehtyneet1939-45/kuolinaika>',
        endPredicate: '<http://ldf.fi/schema/narc-menehtyneet1939-45/kuolinaika>',
        min: '1939-10-01',
        max: '1989-12-31',
        enabled: true
    },
    // Basic facet
    profession: {
        name: 'Ammatti',
        facetId: 'occupation',
        predicate: '<http://ldf.fi/schema/narc-menehtyneet1939-45/ammatti>',
        enabled: true
    },
    // Basic facet with property path
    source: {
        name: 'Source',
        facetId: 'source',
        predicate: '^<http://www.cidoc-crm.org/cidoc-crm/P70i_is_documented_in>/<http://purl.org/dc/elements/1.1/source>',
        enabled: true
    },
    // Basic facet with labels in another service.
    birthMunicipality: {
        name: 'Birth Municipality',
        services: ['<http://ldf.fi/pnr/sparql>'],
        facetId: 'birthplace',
        predicate: '<http://ldf.fi/schema/narc-menehtyneet1939-45/synnyinkunta>',
        enabled: false
    },
    // Hierarchical facet
    rank: {
        name: 'Rank',
        facetId: 'rank',
        predicate: '<http://ldf.fi/schema/narc-menehtyneet1939-45/sotilasarvo>',
        hierarchy: '<http://purl.org/dc/terms/isPartOf>',
        enabled: true,
        depth: 3
    }
};

// Define common options
vm.options = {
    scope: $scope,
    endpointUrl: 'http://ldf.fi/warsa/sparql',
    rdfClass: '<http://ldf.fi/schema/narc-menehtyneet1939-45/DeathRecord>',
    constraint: '?id skos:prefLabel ?name .',
    preferredLang : 'fi'
};

// Define a function that handles updates.
// 'dataService' is some service that fetches results based on the facet selections.
function updateResults(event, facetState) {
    dataService.getResults(facetState.constraints).then(function(results) {
        vm.results = results;
    }
}

// Listen for the update event
$scope.$on('sf-facet-constraints', updateResults);

// Listen for initial state
var initListener = $scope.$on('sf-initial-constraints', function(event, state) {
    updateResults(event, state);
    // Only listen once for the init event
    initListener();
});

// Initialize the facet handler:
vm.handler = new FacetHandler(vm.options);

Then, in the template:

<seco-text-facet
  data-options="vm.facets.name">
</seco-text-facet>
<seco-timespan-facet
  data-options="vm.facets.deathDate">
</seco-timespan-facet>
<seco-basic-facet
  data-options="vm.facets.source">
</seco-basic-facet>
<seco-basic-facet
  data-options="vm.facets.profession">
</seco-basic-facet>
<seco-basic-facet
  data-options="vm.facets.birthMunicipality">
</seco-basic-facet>
<seco-basic-facet
  data-options="vm.facets.principalAbode">
</seco-basic-facet>
<seco-hierarchy-facet
  data-options="vm.facets.rank">
</seco-hierarchy-facet>

Examples

Simplistic demo using DBpedia (the code in the repository contains helpful comments)

The WarSampo casualties demo uses SPARQL Faceter.

You can also see the tool in action in the WarSampo photograph perspective.