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 🙏

© 2025 – Pkg Stats / Ryan Hefner

trjs

v2.0.0

Published

A Library That Uses Turkish Grammar and Composes Turkish Sentences

Downloads

9

Readme

Turkish Grammar Library (trjs)

A comprehensive TypeScript library for Turkish grammar and sentence composition. This library provides tools for verb conjugation, noun declension, and Turkish vowel harmony rules.

Features

  • Verb Conjugation: Complete conjugation system for Turkish verbs across all tenses, persons, and moods
  • Noun Declension: Case marking, genitive forms, and pluralization
  • Vowel Harmony: Automatic application of Turkish vowel harmony rules
  • TypeScript Support: Full type definitions and IntelliSense support
  • Comprehensive Testing: Extensive test suite with 92+ test cases

Installation

npm install trjs

Quick Start

import { Verb, Noun, Pronoun, Tense, Type, Polarity, Case } from "trjs";

// Verb conjugation
const verb = new Verb("gitmek"); // 'to go'
verb.setTense(
  Tense.Present,
  Pronoun.Ben,
  Type.Indicative,
  Polarity.Affirmative
);
console.log(verb.toString()); // "giderim" (I go)

// Noun declension
const noun = new Noun("araba"); // 'car'
noun.case(Case.Dative);
console.log(noun.toString()); // "arabaya" (to the car)

Verb Conjugation

Supported Tenses

  • Present (Tense.Present): Current actions
  • Past (Tense.Past): Completed actions
  • Continuous (Tense.Continuous): Ongoing actions
  • Remote Past (Tense.RPast): Distant past actions
  • Future (Tense.Future): Future actions

Supported Persons

  • Ben (Pronoun.Ben): I
  • Sen (Pronoun.Sen): You (singular)
  • O (Pronoun.O): He/She/It
  • Biz (Pronoun.Biz): We
  • Siz (Pronoun.Siz): You (plural/formal)
  • Onlar (Pronoun.Onlar): They

Supported Moods

  • Indicative (Type.Indicative): Statements
  • Imperative (Type.Imperative): Commands
  • Interrogative (Type.Interrogative): Questions
  • Conditional (Type.Conditional): Conditions

Supported Polarities

  • Affirmative (Polarity.Affirmative): Positive statements
  • Negative (Polarity.Negative): Negative statements

Example: Complete Verb Conjugation

import { Verb, Pronoun, Tense, Type, Polarity } from "trjs";

const verb = new Verb("gelmek"); // 'to come'

// Present tense
verb.setTense(
  Tense.Present,
  Pronoun.Ben,
  Type.Indicative,
  Polarity.Affirmative
);
console.log(verb.toString()); // "gelirim" (I come)

// Past tense
verb.setTense(Tense.Past, Pronoun.Sen, Type.Indicative, Polarity.Negative);
console.log(verb.toString()); // "gelmedin" (you didn't come)

// Future tense
verb.setTense(Tense.Future, Pronoun.O, Type.Indicative, Polarity.Affirmative);
console.log(verb.toString()); // "gelecek" (he/she/it will come)

// Continuous tense
verb.setTense(
  Tense.Continuous,
  Pronoun.Biz,
  Type.Indicative,
  Polarity.Negative
);
console.log(verb.toString()); // "gelmiyoruz" (we are not coming)

Noun Declension

Supported Cases

  • Accusative (Case.Accusative): Direct object (no suffix)
  • Dative (Case.Dative): Indirect object (to/for)
  • Ablative (Case.Ablative): Source (from)
  • Locative (Case.Locative): Location (in/at/on)

Genitive Forms

Genitive forms indicate possession and are marked with pronouns:

import { Noun, Pronoun } from "trjs";

const noun = new Noun("araba"); // 'car'

noun.genitive(Pronoun.Ben);
console.log(noun.toString()); // "arabam" (my car)

noun.genitive(Pronoun.Sen);
console.log(noun.toString()); // "araban" (your car)

noun.genitive(Pronoun.O);
console.log(noun.toString()); // "arabası" (his/her/its car)

Pluralization

const noun = new Noun("ev"); // 'house'

noun.plural();
console.log(noun.toString()); // "evler" (houses)

noun.singular();
console.log(noun.toString()); // "ev" (house)

Example: Complex Noun Declension

import { Noun, Pronoun, Case } from "trjs";

const noun = new Noun("araba"); // 'car'

// Multiple operations
noun.plural(); // Make plural
noun.genitive(Pronoun.Biz); // Add genitive (our)
noun.case(Case.Dative); // Add dative case (to)

console.log(noun.toString()); // "arabalarımıza" (to our cars)

Vowel Harmony

The library automatically applies Turkish vowel harmony rules:

Backness Harmony

  • Front vowels (i, ü, e, ö) → e
  • Back vowels (ı, u, a, o) → a

Flatness Harmony

  • i, e → i
  • ü, ö → ü
  • ı, a → ı
  • u, o → u
import { Word } from "trjs";

const word = new Word("git"); // 'go'

console.log(word.backnessHarmony()); // "e" (front vowel)
console.log(word.flatnessHarmony()); // "i" (front vowel)

Advanced Features

Word Analysis

import { Word } from "trjs";

const word = new Word("gelir"); // 'comes/income'

// Vowel and consonant analysis
console.log(word.allVowels()); // ["e", "i"]
console.log(word.allConsonants()); // ["g", "l", "r"]
console.log(word.vowelLength()); // 2
console.log(word.consonantLength()); // 3

// Character classification
console.log(word.isVowel("e")); // true
console.log(word.isConsonant("g")); // true
console.log(word.isFortis("p")); // true
console.log(word.isLenis("b")); // true

Irregular Verbs

The library handles irregular Turkish verbs correctly:

// These verbs have special present tense forms
const gelmek = new Verb("gelmek"); // 'to come'
gelmek.setTense(
  Tense.Present,
  Pronoun.Ben,
  Type.Indicative,
  Polarity.Affirmative
);
console.log(gelmek.toString()); // "gelirim" (not "gelerim")

const korkmak = new Verb("korkmak"); // 'to fear'
korkmak.setTense(
  Tense.Present,
  Pronoun.Ben,
  Type.Indicative,
  Polarity.Affirmative
);
console.log(korkmak.toString()); // "korkarım" (not "korkarım")

API Reference

Verb Class

Constructor

new Verb(infinitive: string)

Methods

  • setTense(tense: Tense, pronoun: Pronoun, mood: Type, polarity: Polarity): void
  • setConjugation(tense: Tense, pronoun: Pronoun, mood: Type, polarity: Polarity): void
  • toString(): string
  • toRoot(): string

Noun Class

Constructor

new Noun(root: string)

Methods

  • case(caseType: Case): void
  • genitive(pronoun: Pronoun): void
  • plural(): void
  • singular(): void
  • toString(): string
  • toRoot(): string

Word Class

Constructor

new Word(root: string)

Methods

  • toString(): string
  • toRoot(): string
  • suffix(suffix: string): void
  • desuffix(suffix: string): void
  • isVowel(char: string): boolean
  • isConsonant(char: string): boolean
  • isFortis(char: string): boolean
  • isLenis(char: string): boolean
  • lastVowel(word?: string): string
  • lastConsonant(word?: string): string
  • firstVowel(word?: string): string
  • firstConsonant(word?: string): string
  • allVowels(word?: string): string[]
  • allConsonants(word?: string): string[]
  • vowelLength(word?: string): number
  • consonantLength(word?: string): number
  • backnessHarmony(word?: string): string
  • flatnessHarmony(word?: string): string

Testing

Run the test suite:

npm test

The library includes comprehensive tests covering:

  • All verb conjugations across tenses, persons, and polarities
  • All noun declensions and cases
  • Vowel harmony rules
  • Edge cases and error handling
  • Irregular verb handling

Examples

See the examples/ directory for more detailed usage examples.

Contributing

Contributions are welcome! Please ensure all tests pass before submitting a pull request.

License

MIT License - see LICENSE file for details.

Changelog

Version 2.0.0

  • Complete rewrite with TypeScript support
  • Fixed all verb conjugation issues
  • Added comprehensive test suite
  • Improved vowel harmony implementation
  • Added irregular verb support
  • Enhanced documentation and examples