pravopis
is a Node.js module which implements a few string manipulation functions which are useful
when working with text in Serbian language as they handle Serbian language orthography rules correctly.
Goal of this project is to implement functions covering all Serbian language orthography rules. For now just the most basic ones are implemented.
You can get latest version of pravopis
by cloning this repository or by installing the module via Yarn:
yarn add pravopis
Or, if you are still stuck with NPM, via:
npm install --save pravopis
const pravopis = require('pravopis');
console.log(pravopis.toCyrillic('Pozdrav!')); // => Поздрав!
Use a module bundler like Webpack or Browserify which can bundle Node modules easily.
Transliterates string s
from Serbian Latin to Serbian Cyrillic alphabet honoring orthography rules for transliterating nj
/lj
/dž
to њ
/љ
/џ
.
Examples:
pravopis.toCyrillic('pravopis'); // правопис
pravopis.toCyrillic('injekcija, njiva'); // инјекција, њива
pravopis.toCyrillic('patlidžan, nadživeti'); // патлиџан, надживети
Transliterates string s
from Serbian Cyrillic to Serbian Latin alphabet.
Examples:
pravopis.toLatin('правопис'); // pravopis
pravopis.toLatin('инјекција, њива'); // injekcija, njiva
pravopis.toLatin('патлиџан, надживети'); // patlidžan, nadživeti
Returns vocative form of string name
(which is nominative form of a person's given name). Preserves casing and alphabet of a given string.
Examples:
pravopis.toVocative('Ђура'); // Ђуро
pravopis.toVocative('ПЕТАР'); // ПЕТРЕ
pravopis.toVocative('milojica'); // milojice
pravopis.toVocative('Stanoje'); // Stanoje
Compares strings a
and b
and returns true
if they are equal, ignoring difference in used alphabet.
Examples:
pravopis.equals('latinica', 'латиница'); // true
pravopis.equals('ćirilica', 'ћирилица'); // true
pravopis.equals('ćirilica', 'Ћирилица'); // false
Compares strings a
and b
and returns true
if they are equal, ignoring difference in case and used alphabet.
Examples:
pravopis.equalsIgnoreCase('latinica', 'латиница'); // true
pravopis.equalsIgnoreCase('ćirilica', 'ћирилица'); // true
pravopis.equalsIgnoreCase('ćirilica', 'Ћирилица'); // true
Returns true
if string s
has at least one Serbian Cyrillic letter.
Examples:
pravopis.hasCyrillic('ћирилица'); // true
pravopis.hasCyrillic('ćirilica'); // false
Returns true
if string s
has at least one Serbian Latin letter.
Examples:
pravopis.hasLatin('ћирилица'); // false
pravopis.hasLatin('ćirilica'); // true
Yes.
- transliteration rules borrowed from this vokabular.org discussion
- vocative dictionary and rules adapted from Vokativ project by Nemanja Avramović.
MIT