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

jv-conjugator

v2.2.4

Published

A powerful Japanese verb conjugator library which can provide conjugations for a wide range of verb forms and form combinations.

Downloads

175

Readme

jv-conjugator

For all your Japanese verb conjugation needs

https://www.npmjs.com/package/jv-conjugator

About

jv-conjugator is a powerful Japanese verb conjugator library which can provide conjugations for a wide range of verb forms and form combinations including polite forms, negative forms, auxiliary verb forms, additional て-form suffixes and colloquial short versions. The library is written purely in TypeScript and fully tested using Jest. It is designed to be consumed by TypeScript projects as it takes enums as function arguments.

Installation

npm i jv-conjugator

Usage

Two callable functions are provided, getVerbConjugation for a single conjugation, and getVerbConjugations for multiple conjugations of the same VerbInfo object.

Arguments

VerbInfo

An object of type VerbInfo.

verb: An object with string properties kana and kanji. Either one or both may be provided, but if neither are provided an error will be returned.
type: VerbType enum. Typically VerbType.Ichidan or VerbType.Godan, but if the verb is irregular find the corresponding verb in VerbType to ensure irregular conjugations are correct.

FormInfo

An object of type FormInfo.

  • formName: FormName enum of primary verb conjugations. Required.
  • auxFormName: AuxiliaryFormName enum of auxiliary verb conjugations. Optional.
  • additional: AdditionalFormName enum of additional て-form suffix verbs. Optional.
  • polite: Boolean which will give the polite form of the requested conjugation if it exists, and return Error if not. Optional, default false.
  • negative: Boolean which will give the negative form of the requested conjugation if it exists, and return Error if not. Optional, default false.
  • shortVer: Boolean which will give the colloquial short version of the requested conjugation if it exists, or ignore if not. Optional, default false.

If calling getVerbConjugations, provide a list[] of FormInfo instead.

For more information about FormInfo definitions, see Conjugation Details below.

Return Values

  • getVerbConjugation: Returns one Result object or Error if conjugation failed.
  • getVerbConjugations: Returns either Error if VerbInfo processing fails, or a list[] of Result objects and/or Error objects (if conjugation fails for a particular FormInfo).

The Result object contains string properties kana and kanji which are the corresponding conjugation results. Each property will only be defined if they were defined in the VerbInfo argument.

Example usage

import {AdditionalFormName, AuxiliaryFormName, FormInfo, FormName, Result, VerbInfo, VerbType, getVerbConjugation, getVerbConjugations} from "jv-conjugator"

const verbInfo: VerbInfo = {verb: {kana: "たべる", kanji: "食べる"}, type: VerbType.Ichidan};

const formInfo: FormInfo = {formName: FormName.Past, auxFormName: AuxiliaryFormName.Passive, polite: true, negative: true};
const res: Result | Error = getVerbConjugation(verbInfo, formInfo);
if (res instanceof Error) return;
console.log(res.kana + ", " + res.kanji);

const formInfoList: FormInfo[] = [
    {formName: FormName.Past, auxFormName: AuxiliaryFormName.Passive, polite: true, negative: true},
    {formName: FormName.Present, additionalFormName: AdditionalFormName.TeAgeru}
];
const resList: (Result | Error)[] | Error = getVerbConjugations(verbInfo, formInfoList);
if (resList instanceof Error) return;
resList.forEach(result => {
  if(result instanceof Error) return;
  console.log(result.kana + ", " + result.kanji);
});

Conjugation Details

Notes

  • Any field marked N/A will return an Error, except in the case of a missing shortVer which will return the standard version.
  • Additional endings such as ください or なら are left for the consumer to add, as they are not affected by conjugation themself.
  • It is possible to create form combinations which are gramatically correct but make little semantic sense, which is left for the consumer to decide.
  • It is possible to request any combination of FormInfo parameters, although the result may not exist.

FormName

| FormName | Plain | Negative Plain| Polite | Negative Polite | | ---------------| --------| --------------|---------------------------------|-----------------| | Stem |し    |N/A       |N/A                 |N/A       | | Present |する   |しない     |します               |しません     | | Past |した   |しなかった   |しました              |しませんでした  | | Te |して   |しなくて    |しまして              |しませんで    | | Naide |しないで |N/A       |しませんで             |N/A       | | Tai |したい  |したくない   |したいです             |したくないです  | | Zu |せず   |N/A |N/A                |N/A       | | Volitional |しよう  |しなかろう   |しましょう             |N/A       | | Imperative |しろ   |するな     |しなさい              |N/A       | | BaConditional |すれば  |しなければ  |しますれば、しませば (shortVer) |N/A       | | TaraConditional|したら  |しなかったら  |しましたら             |しませんでしたら |

AuxiliaryFormName

Note: For demonstration purposes AuxiliaryFormName is combined with FormName 'Present' here.
Note: Whether an auxiliary verb has a valid shortVer is highly dependant on the type of verb.
Note: する will return できる for the Potential form.

| AuxiliaryFormName | Standard | ShortVer | | -------------------| ------------| ------------| | Potential |食べられる   |食べれる   | | Passive |食べられる  |       |  | Causative |食べさせる  |食べさす   | | CausativePassive |飲ませられる |飲まされる  | | Tagaru |食べたがる  |       |

AdditionalFormName

Note: For demonstration purposes AdditionalFormName is combined with FormName 'Present' here.

| AdditionalFormName | Standard | ShortVer | | -------------------| ----------| ---------| | Continuous |している  |してる  | | TeAru |してある  |      |  | TeOku |しておく  |しとく  | | TeIku |していく  |      | | TeKuru |してくる  |      | | TeAgeru |してあげる |      | | TeKureru |してくれる |  | | TeMorau |してもらう |      | | TeShimau |してしまう |しちゃう |

Combining All

As stated, it is possible to combine forms in any combination. For example, using one of every option for 食べる:
{formName: FormName.Past, additionalFormName: AuxiliaryForm.Continuous, auxFormName: AuxiliaryFormName.Potential, polite: true, negative: true, shortVer: true}
=食べれてませんでした (despite making little real sense)