项目作者: raleksandar

项目描述 :
Set of helper string manipulation functions for handling Serbian language orthography rules correctly
高级语言: JavaScript
项目地址: git://github.com/raleksandar/pravopis.git
创建时间: 2017-05-09T19:32:46Z
项目社区:https://github.com/raleksandar/pravopis

开源协议:MIT License

下载


pravopis

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.

Installation

You can get latest version of pravopis by cloning this repository or by installing the module via Yarn:

  1. yarn add pravopis

Or, if you are still stuck with NPM, via:

  1. npm install --save pravopis

Usage

  1. const pravopis = require('pravopis');
  2. console.log(pravopis.toCyrillic('Pozdrav!')); // => Поздрав!

Usage in browser:

Use a module bundler like Webpack or Browserify which can bundle Node modules easily.

API

pravopis.toCyrillic(s)

Transliterates string s from Serbian Latin to Serbian Cyrillic alphabet honoring orthography rules for transliterating nj/lj/ to њ/љ/џ.

Examples:

  1. pravopis.toCyrillic('pravopis'); // правопис
  2. pravopis.toCyrillic('injekcija, njiva'); // инјекција, њива
  3. pravopis.toCyrillic('patlidžan, nadživeti'); // патлиџан, надживети

pravopis.toLatin(s)

Transliterates string s from Serbian Cyrillic to Serbian Latin alphabet.

Examples:

  1. pravopis.toLatin('правопис'); // pravopis
  2. pravopis.toLatin('инјекција, њива'); // injekcija, njiva
  3. pravopis.toLatin('патлиџан, надживети'); // patlidžan, nadživeti

pravopis.toVocative(name)

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:

  1. pravopis.toVocative('Ђура'); // Ђуро
  2. pravopis.toVocative('ПЕТАР'); // ПЕТРЕ
  3. pravopis.toVocative('milojica'); // milojice
  4. pravopis.toVocative('Stanoje'); // Stanoje

pravopis.equals(a, b)

Compares strings a and b and returns true if they are equal, ignoring difference in used alphabet.

Examples:

  1. pravopis.equals('latinica', 'латиница'); // true
  2. pravopis.equals('ćirilica', 'ћирилица'); // true
  3. pravopis.equals('ćirilica', 'Ћирилица'); // false

pravopis.equalsIgnoreCase(a, b)

Compares strings a and b and returns true if they are equal, ignoring difference in case and used alphabet.

Examples:

  1. pravopis.equalsIgnoreCase('latinica', 'латиница'); // true
  2. pravopis.equalsIgnoreCase('ćirilica', 'ћирилица'); // true
  3. pravopis.equalsIgnoreCase('ćirilica', 'Ћирилица'); // true

pravopis.hasCyrillic(s)

Returns true if string s has at least one Serbian Cyrillic letter.

Examples:

  1. pravopis.hasCyrillic('ћирилица'); // true
  2. pravopis.hasCyrillic('ćirilica'); // false

pravopis.hasLatin(s)

Returns true if string s has at least one Serbian Latin letter.

Examples:

  1. pravopis.hasLatin('ћирилица'); // false
  2. pravopis.hasLatin('ćirilica'); // true

Is it any good?

Yes.

Credits

Licence

MIT