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

@rdfjs/score

v0.1.2

Published

Scores RDF/JS terms inside a dataset

Downloads

54,906

Readme

@rdfjs/score

build status npm version

Scores RDF/JS terms inside a dataset

Install

npm install @rdfjs/score --save

Usage

Factory

This package provides a factory that can be used with @rdfjs/environment.

import DataFactory from '@rdfjs/environment/DataFactory.js'
import DatasetFactory from '@rdfjs/environment/DatasetFactory.js'
import Environment from '@rdfjs/environment'
import ScoreFactory from '@rdfjs/score/Factory.js'

const env = new Environment([DataFactory, DatasetFactory, ScoreFactory])

combine(list)

Combines the result of multiple score functions of the same term into a single result and calculates the average score.

import combine from '@rdfjs/score/combine.js'

const results = combine([score1, score2])(ptrs)

combine.prioritized(list)

Combines the result of multiple score functions of the same term into a single result. The new score is a combined value of the results of all score functions for the same term. Priorities are used where the first function has the highest priority and the last one the lowest.

import combine from '@rdfjs/score/combine.js'

const results = combine.prioritized([score1, score2])(ptrs)

concat(list)

Concatenates the results of multiple score functions.

import concat from '@rdfjs/score/concat.js'

const results = concat([score1, score2])(ptrs)

count({ graph, object, predicate, subject = true })

Scores all given terms based on their occurrence. The parts of the triple that should be taken into account must be given as boolean true. By default, only the subject is taken into account.

import count from '@rdfjs/score/count.js'

const results = count()(ptrs)

distinct(results)

Reduces the list of results to unique terms. The highest score for each term is used.

import distinct from '@rdfjs/score/distinct.js'

const results = distinct(results)

exists({ graph, object, predicate, subject })

Scores a quad with 1, if one of the given parts matches. At least one part must be given.

import exists from '@rdfjs/score/exists.js'

const results = exists({ subject: ns.ex.resource })(ptrs)

fallback(list)

Calls one score function after another until a score function returns a result that is not empty.

import fallback from '@rdfjs/score/fallback.js'

const results = fallback([score1, score2])(ptrs)

fixed(term)

Scores the term that matches the given term with 1.

import fixed from '@rdfjs/score/fixed.js'

const results = fixed(ns.ex.resource)(ptrs)

language(languages)

Score language literals based on the order of the given languages. The * wildcard can be used to match any language.

import language from '@rdfjs/score/language.js'

const results = language(['en', 'de', '*'])(ptrs)

pageRank ({ alpha, epsilon })

Scores the given terms with the PageRank algorithm. Edges are only processed subject to object direction.

import pageRank from '@rdfjs/score/pageRank.js'

const results = pageRank()(ptrs)

pathDepth()

Scores the given terms by the level of the path. Shorter path depths get scored better than deeper ones.

import pathDepth from '@rdfjs/score/pathDepth.js'

const results = pathDepth()(ptrs)

prioritized(list)

Runs all score functions of the given list and prioritizes the score based on the position of the score function in the array. Priorities are used where the first function has the highest priority and the last one the lowest.

import prioritized from '@rdfjs/score/prioritized.js'

const results = prioritized([score1, score2])(ptrs)

product(list)

Runs all score functions of the given list, combines the results with the same term, and scores it with the product of the individual results.

import product from '@rdfjs/score/product.js'

const results = product()(ptrs)

scale({ factor, score })

Calls the given score function and multiplies the score of the results with the given factor.

import scale from '@rdfjs/score/scale.js'

const results = scale()(ptrs)

sort(results)

Sorts the given results descending by score (best matches first).

import sort from '@rdfjs/score/sort.js'

const sortedResults = sort(results)

sortObjects({ dataset, objects, score, termCallback })

Scores and sorts the given objects, which must have a term attached. The dataset must be given as an argument. Optional a termCallback function can be given that extracts the term from the object. By default, the term is expected as a property named term.

import sortObjects from '@rdfjs/score/sortObjects.js'

const sortedObjects = sortObjects({
  dataset,
  objects,
  score,
  termCallback: object => object.ptr.term
})

sum(list)

Runs all score functions of the given list, combines the results with the same term, and scores it with the sum of the individual results.

import sum from '@rdfjs/score/sum.js'

const results = sum([score1, score2])(ptrs)

type(type)

Scores all terms that are subjects of a resource with the given type with 1.

import type from '@rdfjs/score/type.js'

const results = type(ns.schema.Person)(ptrs)