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

inhabit-taxonomy-filter

v1.2.4

Published

taxonomy filter for inhabit

Downloads

23

Readme

TaxonomyFilter

Special filter for inhabit factives. Allows make factives brand safe and attached to specific categories

Install

npm install inhabit-taxonomy-filter --save
import { TaxonomyFilter } from 'inhabit-taxonomy-filter';

class InhabitModule() {
  ...
  public async getContent() {
    const taxfilter = new TaxonomyFilter(this);
    if (await taxfilter.apply()) {
      return <success filter result>
    }
  }
}

Settings

Settings provided through the module configuration and can be exposed on upper level. if you want to override default settings you should add "taxonomyFilter" section into your module configuration, either on the inhabit configuration level or through the code :

From code

this.inhabitModule.configuration.taxonomyFilter = {
        method:"excludeAndInclude",
        taxonomies:"default",
        excludeTaxonomies:"default",
        excludeThreshold:0.3,
        includeTaxonomies:"default",
        includeThreshold:0.7
}

From inhabit configuration

{
 "modules": [
            {
              "id": "mymodule",
              "deliveryMethod": "random",
              "taxonomyFilter":{
                "method":"excludeAndInclude",
                "excludeTaxonomies":"default",
                "excludeThreshold":0.3,
                "includeTaxonomies":"default",
                "includeThreshold":0.7
              }
            }
          ]
}

Add the forms to allow the client to edit on the adminsite:

Form data

[
  {
    "key": "taxonomyFilter",
    "items": [
      {
        "key":"taxonomyFilter.method",
        "type": "select",
        "titleMap": {
          "exclude": "Exclude",
          "include": "Include",
          "excludeAndInclude": "ExcludeAndInclude"
        }
      },
      {
        "key":"taxonomyFilter.excludeTaxonomies",
        "items": [
            "taxonomyFilter.excludeTaxonomies[]"
            ]
      },
      "taxonomyFilter.excludeThreshold",
      {
        "key":"taxonomyFilter.includeTaxonomies",
        "items": [
            "taxonomyFilter.includeTaxonomies[]"
            ]
      },
      "taxonomyFilter.includeThreshold"
    ]
  }
]

schema

{
  "type": "object",
  "title": "Taxonomy",
  "properties": {
    "taxonomyFilter": {
      "type": "object",
      "properties": {
        "method": {
          "title": "Taxonomy Method",
          "type": "select",
		  "enum": [
			"exclude",
			"include",
			"excludeAndInclude"
		  ]
        },
        "excludeTaxonomies": {
          "title": "array of excluded taxonomies",
          "type": "array",
		  "items": {
			"type": "string",
			"default": "politics"
		  }
        },
        "excludeThreshold": {
          "title": "excludeThreshold",
          "type": "number",
		  "default": 3
        },
        "includeTaxonomies": {
          "title": "array of included Taxonomies",
          "type": "array",
		  "items": {
			"type": "string",
			"default": "sports"
		  }
        },
        "includeThreshold": {
          "title": "includeThreshold",
          "type": "number",
		  "default": 3
        }
      }
    }
  }
}

Settings Description

{
  "method":"excludeAndInclude",
  "excludeTaxonomies":"default",
  "excludeThreshold":0.3,
  "includeTaxonomies":"default",
  "includeThreshold":0.7
}

method

"exclude" - if you want to show factive only if it is not in the list of categories provided to filter. In other words if you want to exclude your factive and not show it if article is from the list of provided categories
"include" - opposite from exclude, at this case you are showing factive only if article is from provided list of categories

taxonomies

"default" - if you want to use default exclusion list that is ["society", "law, govt and politics"]
"["category 1","category 2"]" - array of categories, if you want to use your own list

threshold

"0.3" - number that represent contextuality threshold. everything that higher will be included/excluded depending on your preferences