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

treedown-aligner

v0.0.24

Published

TreedownAligner is a react component library. Its components enable users to view and modify alignments between texts with the aid source language syntax via Treedown.

Downloads

4

Readme

TreedownAligner

TreedownAligner is a react component library. Its components enable users to view and modify alignments between texts with the aid source language syntax via Treedown.

View Demo.

TreedownAligner is a react component written in Typesript using Redux for state management. Included is a <Workbench /> component that wraps TreedownAligner for local development and testing.

Consuming Application Quickstart

  • Install: npm install treedown-aligner
  • Import: import TreedownAligner from 'treedown-aligner';
  • Render: () => { return <TreedownAligner /> } (see below for proper usage)

Note: expected peer dependencies

The following peer dependencies are required:

  • react
  • react-dom

The component currently supports react v18.x.

Local development Quickstart

  • Install dependencies: yarn
  • Run local server: yarn start (starts local CRA server with component wrapper in a UI workbench)
  • Build: yarn build

Basic Usage

After install, import the react component:

import TreedownEditor from 'treedown-aligner';

In your render function, include the component with some props:

<TreedownEditor
  theme="day"
  corpora={[<...>]}
  alignments={[<...>]}
  alignmentUpdated={(newAlignmentData) => {
    // persist alignment data here
  }}
/>

Properties and Options

theme

string: 'day' | 'night'

specifies which css theme is used.

localizationCode

string

NOT YET IMPLEMENTED

The consuming application can provide a localizationCode that component will conform internationalized UI elements to. The ISO 639-3 is expected. Supported languages are:

  • English (eng)
  • something else here...
  • something else here...

corpora

Corpus[]

Corpora is the plural form of corpus. A corpus is one body of text that the user will interact with when using this component. Up to 4 corpus entities can be supplied.

A Corpus looks like:

interface Corpus {
  id: string;
  name: string;
  fullName: string;
  language: string;

  words: Word[];
  fullText?: string;
  viewType?: CorpusViewType;
  syntax?: SyntaxRoot;
}
  • id: string unique identifier for the corpus
  • name: string short name, like NIV
  • fullName long name, like New International Version
  • language language code via ISO 639-3
  • words: Word[] object representing a word in the corpus. See Word below.
  • fullText?: string optional - full unsegmented text of the corpus
  • syntax?: SyntaxRoot optional - syntactic parsing of the corpus. See SyntaxRoot below.

Word

Word is an object representing a word in a corpus. In English, words are surrounded by whitespace, but in other languages not neccesarily.

A Word looks like:

export interface Word {
  id: string;
  corpusId: string;

  text: string;
  position: number;
}
  • id: string unique indetifier. used to correlate with Alignment data
  • corpusId: string unique identifier of the corpus the words belongs to
  • text: string content of the word
  • position: number sequential position of the word in the corpus

SyntaxRoot

In some use cases, one of the supplied corpora can have syntax data. In this case, "Syntax data" is a tree-like structure denoting words, word groups, and their relationships to other. The component current supports a json representation of Lowfat Syntax XML.

Note: The component could recieve lowfat xml in string form and then internally convert to json structure. This may be preferable.

alignments

Alignment[]

An Alignment is a set of data the describes the relationship between two corpora. The component enables users to view and modify alignment data. It also uses alignment data to generate syntactic views in treedown notation.

interface Alignment {
  source: string;
  target: string;
  polarity: AlignmentPolarity;
  links: Link[];
}
  • source: string id of the source corpus
  • target: string id of the target corpus
  • polarity: AlignmentPolarity describes the directionality of the alignment see AlignmentPolarity below.
  • links: Link[] relationship entities between the two corpora. see Links

AlignmentPolarity

An AlignmentPolarity describes the "sides" of an alignment and their attributes. Each alignment dataset much be specified with either a PrimaryAlignmentPolarity or a SecondaryAlignmentPolarity.

interface PrimaryAlignmentPolarity {
  type: 'primary';
  syntaxSide: 'sources' | 'targets';
  nonSyntaxSide: 'sources' | 'targets';
}
  • type: 'primary'
  • syntaxSide: 'sources' | 'targets'
  • nonSyntaxSide: 'sources' | 'targets'
interface SecondaryAlignmentPolarity {
  type: 'secondary';
  mappedSide: 'sources' | 'targets';
  nonMappedSide: 'sources' | 'targets';
}
  • type: 'secondary'
  • mappedSide: 'sources' | 'targets'
  • nonMappedSide: 'sources' | 'targets'

Links

Link[]

A Link is a single instance of alignment data. It describes the relationship between the words of two corpora. The strings on either side of the link are IDs of words that were cpecified in the provided Corpus[]. There can be one or many words on either side of a Link.

export interface Link {
  _id?: string;
  sources: string[];
  targets: string[];
}
  • [wip] _id?: string unqiue indentifier for the link. probably should just generate internally
  • sources: string[] array of Word IDs on the source side of the link
  • targets: string[] array of Word IDs on the target side of the link

alignmentUpdated

This is function provided by the consuming application that is called when a user saves alignment data. At the time of invocation, the current alignment state is passed to the function which can be used to display, send, or persist the user's alignment data.