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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@semiont/ontology

v0.5.11

Published

Entity types and annotation-body extraction utilities for the Semiont annotation system

Readme

@semiont/ontology

Tests codecov npm version npm downloads License

Entity types and annotation-body extraction utilities for the Semiont annotation system.

Overview

This package owns:

  • Entity types: Semantic categories for tagging resources and annotations (Person, Organization, Location, etc.) — DEFAULT_ENTITY_TYPES plus the extraction helper getEntityTypes.
  • Tag extraction helpers: Pure body-readers (getTagCategory, getTagSchemaId) that pull schema provenance off an annotation's body. They don't depend on the schema registry.

Tag schemas are not stored in this package. Schemas are runtime-registered per knowledge base via frame.addTagSchema(...) from the SDK; the TagSchema and TagCategory types are exported from @semiont/core. The schema data lives with the KB that owns it (typically a src/tag-schemas.ts module in the KB repo).

Installation

npm install @semiont/ontology

Usage

Entity Types

Default entity types used throughout the system:

import { DEFAULT_ENTITY_TYPES } from '@semiont/ontology';

console.log(DEFAULT_ENTITY_TYPES);
// ['Person', 'Organization', 'Location', 'Event', 'Concept',
//  'Product', 'Technology', 'Date', 'Author']

Tag Schemas

Tag schemas are runtime-registered per KB (see docs/protocol/skills/semiont-tag/SKILL.md and .plans/TAG-SCHEMAS-GAP.md). The TagSchema and TagCategory types live in @semiont/core; schema data lives with the KB that owns it. Use frame.addTagSchema(schema) to register and browse.tagSchemas() to enumerate registered schemas.

import { SemiontClient, type TagSchema } from '@semiont/sdk';

const semiont = await SemiontClient.signInHttp({ /* ... */ });

// Register a schema (idempotent — same content re-registered is silent)
const SCHEMA: TagSchema = { id: 'my-schema', name: '...', /* ... */ };
await semiont.frame.addTagSchema(SCHEMA);

// Enumerate registered schemas
const all = await semiont.browse.tagSchemas();

Entity Extraction

Extract entity types from annotation bodies:

import { getEntityTypes } from '@semiont/ontology';
import type { Annotation } from '@semiont/core';

const annotation: Annotation = {
  motivation: 'linking',
  body: [
    { type: 'TextualBody', purpose: 'tagging', value: 'Person' },
    { type: 'TextualBody', purpose: 'tagging', value: 'Organization' },
    { type: 'SpecificResource', source: 'resource://abc123' }
  ],
  target: 'resource://xyz789'
};

const entityTypes = getEntityTypes(annotation);
// Returns: ['Person', 'Organization']

From src/entity-extraction.ts: Extracts values from TextualBody items where purpose === 'tagging'.

Tag Extraction

Extract tag categories and schema IDs from tag annotations:

import { getTagCategory, getTagSchemaId } from '@semiont/ontology';

const tagAnnotation = {
  motivation: 'tagging',
  body: [
    { type: 'TextualBody', purpose: 'tagging', value: 'Issue' },
    { type: 'TextualBody', purpose: 'classifying', value: 'legal-irac' }
  ],
  target: { source: 'resource://doc123', selector: { /* ... */ } }
};

const category = getTagCategory(tagAnnotation);
// Returns: 'Issue'

const schemaId = getTagSchemaId(tagAnnotation);
// Returns: 'legal-irac'

From src/tag-extraction.ts: Tag annotations use dual-body structure with purpose: 'tagging' for category and purpose: 'classifying' for schema ID.

Tag Collections

Type definitions for graph database tag collection operations:

import type { TagCollection, TagCollectionOperations } from '@semiont/ontology';

// TagCollection interface for stored collections
interface TagCollection {
  id: string;
  collectionType: 'entity-types';
  tags: string[];
  created: Date;
  updatedAt: Date;
}

// TagCollectionOperations interface for graph database implementations
interface TagCollectionOperations {
  getEntityTypes(): Promise<string[]>;
  addEntityType(tag: string): Promise<void>;
  addEntityTypes(tags: string[]): Promise<void>;
  hasEntityTypesCollection(): Promise<boolean>;
  initializeCollections(): Promise<void>;
}

From src/tag-collections.ts: Interfaces for managing entity type collections in graph databases.

Dependencies

  • @semiont/core: For the Annotation type

Package Structure

packages/ontology/
├── src/
│   ├── index.ts                # Public API exports
│   ├── entity-types.ts         # DEFAULT_ENTITY_TYPES
│   ├── tag-collections.ts      # TagCollection interfaces
│   ├── entity-extraction.ts    # getEntityTypes utility
│   └── tag-extraction.ts       # getTagCategory, getTagSchemaId
├── package.json
├── tsconfig.json
├── tsup.config.ts
└── README.md

Notes

  • Bootstrap service: The entity types bootstrap logic lives in packages/make-meaning/src/bootstrap/entity-types.ts — it needs EventBus/EventStore, which don't belong in this package.
  • Annotation type guards: Type guards like isHighlight(), isReference(), etc. live in @semiont/core (src/web-annotation-utils.ts).

License

Apache-2.0