Skip to main content
Home

A simple NLP library to invert the first/second-person pronouns in English language strings

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.0.2)

Reflectr

A small, simple, speedy NLP library to invert the first/second-person pronouns in English language strings.

  • Preserves case, spacing, punctuation.
  • Typescript types.
  • Modern, strict, ES2022 code.
  • Only 1 dependency (also by me).

Reflectr is intended to cope in most regular English language cases. This is a naive library which makes limited, sensible decisions. More complex cases may require advanced NLP techniques.

Usage

npm install reflectr
import { invert } from "reflectr"; // or "jsr:@phughesmcr/reflectr" if using Deno
invert("I want to go to the moon"); // "You want to go to the moon"

For long strings, I recommend splitting by sentence first and then inverting each.

License

MIT

Examples

Example 1

import { invert } from 'reflectr';
const inverted = invert('I want to go to the moon');
console.log(inverted); // 'You want to go to the moon'

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@phughesmcr/reflectr

Import symbol

import * as reflectr from "@phughesmcr/reflectr";
or

Import directly with a jsr specifier

import * as reflectr from "jsr:@phughesmcr/reflectr";

Add Package

pnpm i jsr:@phughesmcr/reflectr
or (using pnpm 10.8 or older)
pnpm dlx jsr add @phughesmcr/reflectr

Import symbol

import * as reflectr from "@phughesmcr/reflectr";

Add Package

yarn add jsr:@phughesmcr/reflectr
or (using Yarn 4.8 or older)
yarn dlx jsr add @phughesmcr/reflectr

Import symbol

import * as reflectr from "@phughesmcr/reflectr";

Add Package

vlt install jsr:@phughesmcr/reflectr

Import symbol

import * as reflectr from "@phughesmcr/reflectr";

Add Package

npx jsr add @phughesmcr/reflectr

Import symbol

import * as reflectr from "@phughesmcr/reflectr";

Add Package

bunx jsr add @phughesmcr/reflectr

Import symbol

import * as reflectr from "@phughesmcr/reflectr";