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

affixi

v1.1.0

Published

Affixi is a helper library for Turkish suffixes for nouns and proper nouns written in typescript.

Downloads

155

Readme

Affixi

A helper library for Turkish noun suffixes written in typescript.

Table

Functions

Classes

Objects

Enums

Interfaces

Usage

install

npm install affixi

There is no default export in the library, so you can import whatever you need and only the things you need. This makes the library tree-shakable.

import { makePlural, makePossesive, Pronoun } from 'affixi';

makePlural('O'); // Onlar
makePossesive('Akıl', Pronoun.PluralFirst); // Aklımız
makeCase(makePossesive('Ongözlü Köprü', Pronoun.SingularThird), Case.Locative, true); // Ongözlü Köprüsü'nde

Reference

Functions

getPluralSuffix

getPluralSuffix(base: string) => string

Returns the appropriate plural suffix for a given noun. Suffixes are affected by vowel harmony rules.

e.g:

  • Araç > lar
  • Bebek > ler

makePlural

makePlural(base: string) => string

Returns the word base concatenated with the appropriate plural suffix for a given noun.

e.g:

  • Araç > Araçlar
  • Bebek > Bebekler

getEqualitySuffix

getEqualitySuffix(base: string) => string

Returns the appropriate equality suffix for a given noun. These types of suffixes are affected by both vowel harmony, consonant softening, consonant assimilation and buch of other rules.

e.g:

  • Çocuk > ça
  • Sen > ce

makeEqual

makeEqual(base: string) => string

Returns the word base concatenated with the appropriate equality suffix for a given noun.

e.g:

  • Çocuk > Çocukça
  • Sen > Sence

getPossesiveSuffix

getPossesiveSuffix(base: string, pronoun: Pronoun) => string

Returns the appropriate possesive suffix for a given noun and pronoun. These types of suffixes are affected by vowel harmony and given pronoun.

e.g:

  • getPossesiveSuffix("Çocuk", Pronoun.SingularFirst) // um
  • getPossesiveSuffix("Çocuk", Pronoun.SingularSecond) // un
  • getPossesiveSuffix("Sen", Pronoun.SingularSecond) // in

makePossesive

makePossesive(base: string, pronoun: Pronoun, isProperNoun: boolean = false) => string

Returns the word base concatenated with the appropriate possesive suffix for a given noun and pronoun.

Proper nouns are seperated with an apostrophe character.

e.g:

  • makePossesive("Çocuk", Pronoun.SingularFirst) // Çocuğum
  • makePossesive("Çocuk", Pronoun.SingularSecond) // Çocuğun
  • makePossesive("Sen", Pronoun.SingularSecond) // Senin
  • makePossesive("Ayşe", Pronoun.SingularFirst, true) // Ayşe'm

getCaseSuffix

getCaseSuffix(base: string, _case: Case) => string

Returns the appropriate case suffix for a given base word and a case

  • makeCase('Ev', Case.Ablative) // den
  • makeCase('Şehir', Case.Dative) // e
  • makeCase('Sinema', Case.Dative) // ya

makeCase

makeCase(base: string, _case: Case, isProperNoun: boolean = false) => string

Returns the word base concatenated with the appropriate case suffix for a given base word and a case Proper nouns are seperated with an apostrophe character.

  • makeCase('Ev', Case.Ablative) // Evden
  • makeCase('Balıkesir', Case.Ablative, true) // Balıkesir'den
  • makeCase('Şehir', Case.Dative) // Şehre
  • makeCase('Sinema', Case.Dative) // Sinemaya

getCompoundSuffix

getCompoundSuffix(base: string, compound: Compound) => string

Returns the appropriate compound suffix for a given base word and a compound

  • getCompoundSuffix('Köprü', Compound.Compounder) // nün
  • getCompoundSuffix('Öğretmen', Compound.Compounder) // in
  • getCompoundSuffix('Köprü', Compound.Compoundee) // sü
  • getCompoundSuffix('Akıl', Compound.Compoundee) // ı

makeCompound

makeCompound(base: string, compound: Compound, isProperNoun: boolean = false) => string

Returns the word base concatenated with the appropriate compound suffix for a given base word and a compound Proper nouns are seperated with an apostrophe character.

  • makeCompound('Köprü', Compound.Compounder) // Köprünün
  • makeCompound('Öğretmen', Compound.Compounder) // Öğretmenin
  • makeCompound('Köprü', Compound.Compoundee) // Köprüsü
  • makeCompound('Akıl', Compound.Compoundee) // Aklı

getVoicedConsonant

getVoicedConsonant(base: string) => string | undefined

Some words that end with an unvoiced consonants (p,ç,t,k) may be converted into their voiced counterparts (b,c,d,ğ). If extist, this function returns the voiced consonant. If not returns undefined.

  • Ağaç > c
  • Sebep > b
  • Akıllı > undefined

alterToVoicedConsonant

alterToVoicedConsonant(base: string) => string

This function returns the mutated version of a word with its voiced consonant. If base does not have a voiced counterpart, the base itself is returned.

  • Ağaç > Ağac
  • Sebep > Sebeb
  • Akıllı > Akıllı
  • Renk > Reng

alterToVowelDrop

alterToVowelDrop(base: string) => string

Some two syllable words that has acute vowels in their last syllable drop that vowel after they are conjugated with a suffix. This function returns the words mutated version with the dropped vowel.

Note: Because certain words are subjected to this phenomenon, these words are kept in an exceptions array. Contributions to this limited list is appreciated.

  • Akıl > Akl
  • Bağır > Bağr
  • Şehir > Şehr

Util

Some utility functions that may help word generation.

getComponents
util.getComponents(base: string) => WordComponent

This method returns the last letter and the last vowel in the last syllable of a given word. It returns a WordComponent interface.

export interface WordComponent {
  letter: string;
  vowel: string;
}
  • Araba > { letter: "a", vowel: "a" }
  • Oyuncak > { letter: "k", vowel: "a" }
  • Sebep > { letter: "p", vowel: "e" }
getSyllableCount
util.getSyllableCount(base: string) => number

This method returns the syllable count of a base word. Almost always the syllabale count of a word is equal to the vowel count of a word in Turkish because the stress is delimited by vowels.

  • Muvaffak > 3
  • Elma > 2
  • Süpermarket > 4

Classes

AffixiWord

AffixiWord is a construct that makes it easier to handle nouns in a complex manner. It holds a state that can be undone and handles aspects like compoundness in itslef. It has a toString method that returns the resulting word and can be used with String(word). All its methods apart from toString return the instance itself so they are chainable.

Properties
  base: string; // Given base word
  word: string; // Current state of the word
  isCompound: boolean;
  isProperNoun: boolean;
  history: AffixiWordState[] = [];

See: AffixiWordState

Methods
AffixiWord.makeCompound

Concatenates the word with the appropriate compound suffix for a given compound type.

makeCompound(type: Compound): AffixiWord
AffixiWord.makeCase

Concatenates the word with the appropriate case suffix for a given case.

makeCase(_case: Case): AffixiWord
AffixiWord.makeComplete

Concatenates the word with the completion suffix.

makeComplete(): AffixiWord
AffixiWord.makePossesive

Concatenates the word with the possesive suffix for a given pronoun.

  makePossesive(pronoun: Pronoun): AffixiWord
AffixiWord.makeEqual

Transforms the word into equal form.

makeEqual(): AffixiWord
AffixiWord.makePlural

Transforms the word into plural form.

makePlural(): AffixiWord
AffixiWord.undo

Undoes the last operation

undo(): AffixiWord

Objects

sounds

Turkish sounds categorized by different metrics.

interface sounds {
  unvoicedStoppingConsonants: string[];
  unvoicedContinuousConsonants: string[];
  voicedStoppingConsonants: string[];
  concatentorConsonants: string[];
  unvoicedConsonants: string[];
  roundedVowels: string[];
  unRoundedVowels: string[];
  backVowels: string[];
  frontVowels: string[];
  acuteVowels: string[];
  wideVowels: string[];
  vowels: string[];
}

Enums

Pronoun

enum Pronoun {
  SingularFirst, // I
  SingularSecond, // You (singular)
  SingularThird, // He/She/It
  PluralFirst, // We
  PluralSecond, // You (plural)
  PluralThird, // They
}

I think this one is pretty self-explanatory.

Case

enum Case {
  Absolute,
  Accusative, // -i
  Ablative, // -den
  Locative, // -de
  Instrumental, // -le
  Dative, // -e
}

Turkish noun case names.

Compound

enum Compound {
  Compounder, // tamlayan
  Compoundee, // tamlanan
}

Turkish compound types

Interfaces

AffixiWordState

export interface AffixiWordState {
  word: string;
  isCompound: boolean;
  isProperNoun: boolean;
}