-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f54a6a1
commit 579ad4f
Showing
3 changed files
with
165 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 khashashin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# @ce/transliteration | ||
|
||
![Build and Publish](https://github.com/chechen-language/ce-translit/actions/workflows/publish.yml/badge.svg) | ||
|
||
A JavaScript library for transliterating Chechen text written in Cyrillic script to Latin script using a predefined mapping. | ||
|
||
## Table of Contents | ||
- [Introduction](#introduction) | ||
- [Features](#features) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Special Handling](#special-handling) | ||
- [Examples](#examples) | ||
- [Configuration](#configuration) | ||
- [Development](#development) | ||
- [License](#license) | ||
|
||
## Introduction | ||
|
||
`@ce/transliteration` is a library that provides an easy way to transliterate Chechen text from Cyrillic to Latin script based on a predefined mapping. The transliteration is designed to accurately represent Chechen phonetics in Latin script. | ||
|
||
### Demo | ||
|
||
Check out the [live demo](https://chechen-language.github.io/repositories/chechen-transliterator/?text=дӏахьäдира) to see the transliteration in action. | ||
|
||
## Features | ||
- Transliterates Chechen text from Cyrillic to Latin script. | ||
- Special handling for specific characters, including contextual rules. | ||
- Configurable transliteration mapping. | ||
- Provides a comprehensive set of tools for Chechen language processing. | ||
|
||
## Installation | ||
|
||
To install `@ce/transliteration`, use npm or yarn: | ||
|
||
```bash | ||
npx jsr add @ce/transliteration | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
yarn dlx jsr add @ce/transliteration | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
deno add @ce/transliteration | ||
``` | ||
|
||
## Usage | ||
|
||
Here's how to use the transliteration library in your JavaScript or TypeScript project: | ||
|
||
```javascript | ||
import { apply, translitMap } from "@ce/transliteration"; | ||
|
||
const result = apply('дӏахьäдира'); | ||
console.log(result); // Output: 'djaẋädira' | ||
|
||
console.log(translitMap); | ||
``` | ||
|
||
## Special Handling | ||
|
||
The library includes some specific handling for the character 'н': | ||
|
||
1. **End of Word**: If 'н' appears at the end of a word, it is generally transliterated as 'ŋ'. | ||
2. **Blacklist**: If the word is in a predefined blacklist, 'н' is transliterated as 'n'. | ||
3. **Uncertain List**: If the word is in the "unsureList", 'н' is transliterated as 'ŋ[REPLACE]' to indicate that manual review is needed. | ||
|
||
## Examples | ||
|
||
### Example 1 | ||
|
||
Transliterate a Chechen text: | ||
|
||
```javascript | ||
import { apply } from "@ce/transliteration"; | ||
|
||
const text = 'дӏахьäдира'; | ||
const transliteratedText = apply(text); | ||
console.log(transliteratedText); // Output: 'djaẋädira' | ||
``` | ||
|
||
### Example 2 | ||
|
||
Transliterate a Chechen text with special handling: | ||
|
||
```javascript | ||
import { apply } from "@ce/transliteration"; | ||
|
||
const text = 'шун'; | ||
const transliteratedText = apply(text); | ||
console.log(transliteratedText); // Output: 'şuŋ[REPLACE]' | ||
``` | ||
|
||
## Configuration | ||
|
||
The transliteration rules are defined in a mapping object (`translitMap`). You can view or modify the transliteration mapping according to your needs. For more information, check the `translit.ts` file in the repository. | ||
|
||
## Development | ||
|
||
### Project Structure | ||
|
||
```bash | ||
. | ||
├── .github | ||
│ └── workflows | ||
│ └── publish.yml | ||
├── __tests__ | ||
│ └── translit.test.ts | ||
├── .gitignore | ||
├── jest.config.js | ||
├── jsr.json | ||
└── translit.ts | ||
``` | ||
|
||
- **`.github/workflows/publish.yml`**: CI/CD configuration for building and publishing the package. | ||
- **`__tests__/translit.test.ts`**: Test cases for the transliteration logic. | ||
- **`translit.ts`**: Core library file containing the transliteration logic and mapping. | ||
- **`jest.config.js`**: Jest configuration for running tests. | ||
- **`jsr.json`**: Contains metadata for the JavaScript Registry. | ||
|
||
### Running Tests | ||
|
||
This project uses [Jest](https://jestjs.io/) for testing. To run the test suite with coverage reports, use the following command: | ||
|
||
```bash | ||
jest --coverage | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
{ | ||
"name": "@ce/transliteration", | ||
"version": "0.2.9", | ||
"exports": "./translit.ts" | ||
} | ||
"exports": "./translit.ts", | ||
"publish": { | ||
"exclude": [ | ||
".github", | ||
"__tests__" | ||
] | ||
} | ||
} |