Skip to content

Commit

Permalink
test(stripAccents): use stripAccents in stripAccents test (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhajneet committed May 31, 2020
1 parent 32a151b commit 0231214
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 197 deletions.
196 changes: 99 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!-- Do not modify README.md, instead modify README.hbs -->

# gurmukhi-utils

> General utilities for working with Gurmukhi text data.
[![CircleCI](https://img.shields.io/circleci/project/github/ShabadOS/gurmukhi-utils.svg?style=for-the-badge)](https://circleci.com/gh/ShabadOS/gurmukhi-utils)
[![Coveralls github](https://img.shields.io/coveralls/github/ShabadOS/gurmukhi-utils.svg?style=for-the-badge)](https://coveralls.io/github/ShabadOS/gurmukhi-utils)
[![npm](https://img.shields.io/npm/v/gurmukhi-utils.svg?style=for-the-badge)](https://www.npmjs.com/package/gurmukhi-utils)
[![license](https://img.shields.io/github/license/ShabadOS/gurmukhi-utils.svg?style=for-the-badge)](./License)
[![Try on RunKit](https://img.shields.io/badge/Try%20on%20RunKit-Playground-brightgreen.svg?style=for-the-badge)](https://npm.runkit.com/gurmukhi-utils)


Want to speak with us? <p>[![Slack](https://slack.shabados.com/badge.svg)](https://slack.shabados.com)</p>

<!-- Do not modify README.md, instead modify README.hbs -->

# gurmukhi-utils

> General utilities for working with Gurmukhi text data.
[![CircleCI](https://img.shields.io/circleci/project/github/ShabadOS/gurmukhi-utils.svg?style=for-the-badge)](https://circleci.com/gh/ShabadOS/gurmukhi-utils)
[![Coveralls github](https://img.shields.io/coveralls/github/ShabadOS/gurmukhi-utils.svg?style=for-the-badge)](https://coveralls.io/github/ShabadOS/gurmukhi-utils)
[![npm](https://img.shields.io/npm/v/gurmukhi-utils.svg?style=for-the-badge)](https://www.npmjs.com/package/gurmukhi-utils)
[![license](https://img.shields.io/github/license/ShabadOS/gurmukhi-utils.svg?style=for-the-badge)](./License)
[![Try on RunKit](https://img.shields.io/badge/Try%20on%20RunKit-Playground-brightgreen.svg?style=for-the-badge)](https://npm.runkit.com/gurmukhi-utils)


Want to speak with us? <p>[![Slack](https://slack.shabados.com/badge.svg)](https://slack.shabados.com)</p>

## Contents

<!-- toc -->
Expand All @@ -32,37 +32,46 @@ Want to speak with us? <p>[![Slack](https://slack.shabados.com/badge.svg)](https

<!-- tocstop -->

## Usage

The library can be imported into Node as below:
```javascript
const { toUnicode, toAscii, firstLetters, transliterate, toShahmukhi } = require('gurmukhi-utils')

toUnicode('Koj') // => ਖੋਜ
toAscii('ਖੋਜ') // => Koj
firstLetters('hir hir hir gunI') // => hhhg
firstLetters('ਹਰਿ ਹਰਿ ਹਰਿ ਗੁਨੀ') // => ਹਹਹਗ
transliterate('hukmI hukmu clwey rwhu ]') // => hukamee hukam chalaae raahu ||
toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥
toShahmukhi('ਹਰਿ ਹਰਿ ਹਰਿ ਗੁਨੀ') // => هر هر هر گُنی
stripAccents('ਜ਼ਫ਼ੈਸ਼ਸ') // => ਜਫੈਸਸ
stripVishraams('sbid mrY. so mir rhY; iPir.') // => sbid mrY so mir rhY iPir
```

Additionally, the package is available for web use via [unpkg CDN](https://unpkg.com/gurmukhi-utils).
```
<script src="https://unpkg.com/gurmukhi-utils"></script>
```

Want to play around? [![Try gurmukhi-utils on RunKit](https://badge.runkitcdn.com/gurmukhi-utils.svg)](https://npm.runkit.com/gurmukhi-utils)


## API

### firstLetters(line, [stripNukta], [withVishraams]) ⇒ <code>String</code>
Generates the first letters for a given ASCII or unicode Gurmukhi string.
By default, the function will transform letters with bindi to their simple equivalent,
for example, zaza to jaja (ਜ਼ => ਜ).
## Usage

The library can be imported into Node as below:
```javascript
const {
toUnicode,
toAscii,
firstLetters,
toEnglish,
toHindi,
toShahmukhi,
stripAccents,
stripVishraams,
isGurmukhi,
} = require( 'gurmukhi-utils' )

toUnicode('Koj') // => ਖੋਜ
toAscii('ਖੋਜ') // => Koj
firstLetters('hir hir hir gunI') // => hhhg
firstLetters('ਹਰਿ ਹਰਿ ਹਰਿ ਗੁਨੀ') // => ਹਹਹਗ
toEnglish('hukmI hukmu clwey rwhu ]') // => hukamee hukam chalaae raahu ||
toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥
toShahmukhi('ਹਰਿ ਹਰਿ ਹਰਿ ਗੁਨੀ') // => هر هر هر گُنی
stripAccents('ਜ਼ਫ਼ੈਸ਼ਸ') // => ਜਫੈਸਸ
stripVishraams('sbid mrY. so mir rhY; iPir.') // => sbid mrY so mir rhY iPir
isGurmukhi('ਗੁਰਮੁਖੀ') // t=> true
```

Additionally, the package is available for web use via [unpkg CDN](https://unpkg.com/gurmukhi-utils).
```
<script src="https://unpkg.com/gurmukhi-utils"></script>
```

Want to play around? [![Try gurmukhi-utils on RunKit](https://badge.runkitcdn.com/gurmukhi-utils.svg)](https://npm.runkit.com/gurmukhi-utils)


## API

### firstLetters(line, [stripNukta], [withVishraams]) ⇒ <code>String</code>
Generates the first letters for a given ASCII or unicode Gurmukhi string.By default, the function will transform letters with bindi to their simple equivalent,for example, zaza to jaja (ਜ਼ => ਜ).

**Returns**: <code>String</code> - The first letters of each word in the provided Gurmukhi line.

Expand Down Expand Up @@ -97,7 +106,7 @@ firstLetters('iZir&qym sMdUk* drIXw AmIk* ]', false) // => Zsda
```js
firstLetters('sbid mrY. so mir rhY; iPir. mrY n, dUjI vwr ]', true, true) // => sm.smr;P.mn,dv
```
### isGurmukhi(text, [exhaustive]) ⇒ <code>boolean</code>
### isGurmukhi(text, [exhaustive]) ⇒ <code>boolean</code>
Checks if first char in string is part of the Gurmukhi Unicode block.

**Returns**: <code>boolean</code> - True if Unicode Gurmukhi, false if other.
Expand All @@ -111,9 +120,8 @@ Checks if first char in string is part of the Gurmukhi Unicode block.
```js
isGurmukhi('ਗੁਰਮੁਖੀ') // => trueisGurmukhi('gurmuKI') // => false
```
### stripAccents(text) ⇒ <code>String</code>
Removes accents from ASCII/Unicode Gumrukhi letters with their base letter.
Useful for generalising search queries.
### stripAccents(text) ⇒ <code>String</code>
Removes accents from ASCII/Unicode Gumrukhi letters with their base letter.Useful for generalising search queries.

**Returns**: <code>String</code> - A simplified version of the provided Gurmukhi string.

Expand All @@ -123,10 +131,9 @@ Useful for generalising search queries.

**Example**
```js
stripAccents('ਜ਼ਫ਼ੈਸ਼ਸਓ') // => ਜਫੈਸਸੳ
stripAccents('Z^Svb') // => gKsvb
stripAccents('ਜ਼ਫ਼ੈਸ਼ਸਓ') // => ਜਫੈਸਸੳstripAccents('Z^Svb') // => gKsvb
```
### stripVishraams(text, options) ⇒ <code>String</code>
### stripVishraams(text, options) ⇒ <code>String</code>
Removes the specified vishraams from a string.

**Returns**: <code>String</code> - A vishraam-less Gurmukhi string.
Expand All @@ -153,7 +160,7 @@ stripVishraams('Anhd sbd vjwey,', { medium: true }) // => Anhd sbd vjwey
```js
stripVishraams('sbid mrY. so mir rhY; iPir.', { light: true }) // => sbid mrY so mir rhY; iPir
```
### toAscii(text) ⇒ <code>String</code>
### toAscii(text) ⇒ <code>String</code>
Converts Gurmukhi unicode text to ASCII, used GurmukhiAkhar font.

**Returns**: <code>String</code> - An ASCII representation of the provided unicode Gurmukhi string.
Expand All @@ -164,12 +171,10 @@ Converts Gurmukhi unicode text to ASCII, used GurmukhiAkhar font.

**Example**
```js
toAscii('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => hmw swieil luqi& hk prvrS ]
toAscii('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => su bYiT iekMqR ]578]
toAscii('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => hmw swieil luqi& hk prvrS ]toAscii('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => su bYiT iekMqR ]578]
```
### toEnglish(line) ⇒ <code>String</code>
Transliterates a line from Unicode Gurmukhi to english.
Currently supports the `,`, `;`, `.` vishraam characters.
### toEnglish(line) ⇒ <code>String</code>
Transliterates a line from Unicode Gurmukhi to english.Currently supports the `,`, `;`, `.` vishraam characters.

**Returns**: <code>String</code> - The English transliteration of the provided Gurmukhi line.

Expand All @@ -185,7 +190,7 @@ toEnglish('ਹੁਕਮੀ ਹੁਕਮੁ ਚਲਾਏ ਰਾਹੁ ॥') // =>
```js
toEnglish('ਭਾਂਡਾ ਭਾਉ ਅੰਮ੍ਰਿਤੁ ਤਿਤੁ ਢਾਲਿ ॥') // => bhaa(n)ddaa bhaou anmrit tit dtaal ||
```
### toHindi(text) ⇒ <code>String</code>
### toHindi(text) ⇒ <code>String</code>
Transliterates Unicode Gurmukhi text to Hindi (Devanagari script).

**Returns**: <code>String</code> - A Hindi transliteration of the provided Unicode Gurmukhi string.
Expand All @@ -196,10 +201,9 @@ Transliterates Unicode Gurmukhi text to Hindi (Devanagari script).

**Example**
```js
toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥
toHindi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => सु बैठ इकंत्र ॥५७८॥
toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥toHindi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => सु बैठ इकंत्र ॥५७८॥
```
### toShahmukhi(text) ⇒ <code>String</code>
### toShahmukhi(text) ⇒ <code>String</code>
Transliterates Unicode Gurmukhi text to the Shahmukhi script.

**Returns**: <code>String</code> - A Shahmukhi transliteration of the provided Unicode Gurmukhi string.
Expand All @@ -210,10 +214,9 @@ Transliterates Unicode Gurmukhi text to the Shahmukhi script.

**Example**
```js
toShahmukhi('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => هما ساِال لُتف هک پرورش ۔۔
toShahmukhi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => سُ بَےٹھ ِاکںتر ۔۔۵۷۸۔۔
toShahmukhi('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => هما ساِال لُتف هک پرورش ۔۔toShahmukhi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => سُ بَےٹھ ِاکںتر ۔۔۵۷۸۔۔
```
### toUnicode(text) ⇒ <code>String</code>
### toUnicode(text) ⇒ <code>String</code>
Converts ASCII text used in the GurmukhiAkhar font to Unicode.

**Returns**: <code>String</code> - A unicode representation of the provided ASCII Gurmukhi string.
Expand All @@ -224,36 +227,35 @@ Converts ASCII text used in the GurmukhiAkhar font to Unicode.

**Example**
```js
toUnicode('kul jn mDy imil´o swrg pwn ry ]') // => ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥
toUnicode('su bYiT iekMqR ]578]') // => ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥
toUnicode('kul jn mDy imil´o swrg pwn ry ]') // => ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥toUnicode('su bYiT iekMqR ]578]') // => ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥
```

## Contributing

We're happy to accept suggestions and pull requests!

To get started, clone this repo and run `npm install` inside this directory.

This repository follows the **Airbnb's Javascript Style Guide**, with a few minor modifications. Notably, spaces should be included inside parentheses and brackets (weird, right!). An ESLint file is provided,
and your code will automatically be checked on-commit for style.
It is recommended to install an ESLint plugin for your editor (VS Code's `ESLint` plugin works out of the box), so you can receive
linter suggestions as you type.

When writing commit messages, please follow the **[seven rules](https://chris.beams.io/posts/git-commit/#seven-rules)**.
Markdown and HTML JSDoc documentation is generated automatically, on commit,
however if you'd like to preview any changes to documentation, `npm run build-docs` will
update `README.md` and the files in `docs/`. `README.md` should *not* be edited, instead
apply modifications to `README.hbs`.

The general workflow for contributing:

- Fork/create a new branch.
- Write or update existing tests with expected results
- Implement functions/changes
- Add JSDoc function documentation and examples.
- Run tests with `npm test` and ensure they all pass. Testing is done with the `mocha` testing framework.
- Create a pull request with the changes.

*Note to contributors with push access to master:* Any commits or merge commits containing the strings
`#Major`, `#Minor`, `#Patch` (case-sensitive) will trigger an automatic npm release with the

## Contributing

We're happy to accept suggestions and pull requests!

To get started, clone this repo and run `npm install` inside this directory.

This repository follows the **Airbnb's Javascript Style Guide**, with a few minor modifications. Notably, spaces should be included inside parentheses and brackets (weird, right!). An ESLint file is provided,
and your code will automatically be checked on-commit for style.
It is recommended to install an ESLint plugin for your editor (VS Code's `ESLint` plugin works out of the box), so you can receive
linter suggestions as you type.

When writing commit messages, please follow the **[seven rules](https://chris.beams.io/posts/git-commit/#seven-rules)**.
Markdown and HTML JSDoc documentation is generated automatically, on commit,
however if you'd like to preview any changes to documentation, `npm run build-docs` will
update `README.md` and the files in `docs/`. `README.md` should *not* be edited, instead
apply modifications to `README.hbs`.

The general workflow for contributing:

- Fork/create a new branch.
- Write or update existing tests with expected results
- Implement functions/changes
- Add JSDoc function documentation and examples.
- Run tests with `npm test` and ensure they all pass. Testing is done with the `mocha` testing framework.
- Create a pull request with the changes.

*Note to contributors with push access to master:* Any commits or merge commits containing the strings
`#Major`, `#Minor`, `#Patch` (case-sensitive) will trigger an automatic npm release with the
respective semver bump.
Expand Down
Loading

0 comments on commit 0231214

Please sign in to comment.