Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

commonform-phrase-annotator

The module exports a single function that takes an array of strings and a function for generating annotations, returning an annotator function to apply to Common Forms.

const phrases = ['thereof', 'whereof']

The annotation function receives the form in which a string was found, its path within the overall form, and the string that matches. It must return a Common Form Annotations.

function implementation (form, path, string) {
  return {
    message: '"' + string + '" is archaic',
    path: path,
    source: 'example-annotator',
    url: null
  }
}

import phraseAnnotator from 'commonform-phrase-annotator'

const annotator = phraseAnnotator(phrases, implementation)

The library does the job of finding matches and calculating paths.

import assert from 'node:assert'

assert.deepStrictEqual(
  annotator({ content: ['all rights thereof and whereof'] }),
  [
    {
      message: '"thereof" is archaic',
      path: ['content', 0],
      source: 'example-annotator',
      url: null
    },
    {
      message: '"whereof" is archaic',
      path: ['content', 0],
      source: 'example-annotator',
      url: null
    }
  ]
)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages