A comprehensive TypeScript library for Turkish grammar and sentence composition. This library provides tools for verb conjugation, noun declension, and Turkish vowel harmony rules.
- 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
npm install trjsimport { 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)- 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
- 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
- Indicative (
Type.Indicative): Statements - Imperative (
Type.Imperative): Commands - Interrogative (
Type.Interrogative): Questions - Conditional (
Type.Conditional): Conditions
- Affirmative (
Polarity.Affirmative): Positive statements - Negative (
Polarity.Negative): Negative statements
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)- 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 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)const noun = new Noun('ev'); // 'house'
noun.plural();
console.log(noun.toString()); // "evler" (houses)
noun.singular();
console.log(noun.toString()); // "ev" (house)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)The library automatically applies Turkish vowel harmony rules:
- Front vowels (i, ü, e, ö) → e
- Back vowels (ı, u, a, o) → a
- 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)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')); // trueThe 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")new Verb(infinitive: string)setTense(tense: Tense, pronoun: Pronoun, mood: Type, polarity: Polarity): voidsetConjugation(tense: Tense, pronoun: Pronoun, mood: Type, polarity: Polarity): voidtoString(): stringtoRoot(): string
new Noun(root: string)case(caseType: Case): voidgenitive(pronoun: Pronoun): voidplural(): voidsingular(): voidtoString(): stringtoRoot(): string
new Word(root: string)toString(): stringtoRoot(): stringsuffix(suffix: string): voiddesuffix(suffix: string): voidisVowel(char: string): booleanisConsonant(char: string): booleanisFortis(char: string): booleanisLenis(char: string): booleanlastVowel(word?: string): stringlastConsonant(word?: string): stringfirstVowel(word?: string): stringfirstConsonant(word?: string): stringallVowels(word?: string): string[]allConsonants(word?: string): string[]vowelLength(word?: string): numberconsonantLength(word?: string): numberbacknessHarmony(word?: string): stringflatnessHarmony(word?: string): string
Run the test suite:
npm testThe 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
See the examples/ directory for more detailed usage examples.
Contributions are welcome! Please ensure all tests pass before submitting a pull request.
MIT License - see LICENSE file for details.
- 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