From 579ad4fee74392e2356f5475b196bfc49f14e1c9 Mon Sep 17 00:00:00 2001 From: Yusuf Khasbulatov Date: Tue, 17 Sep 2024 01:05:39 +0200 Subject: [PATCH] update docs --- LICENSE | 21 +++++++++ Readme.md | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ jsr.json | 10 +++- 3 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 LICENSE create mode 100644 Readme.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..88e2ca1 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..8b701c1 --- /dev/null +++ b/Readme.md @@ -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). diff --git a/jsr.json b/jsr.json index 5673fe6..2190011 100644 --- a/jsr.json +++ b/jsr.json @@ -1,5 +1,11 @@ { "name": "@ce/transliteration", "version": "0.2.9", - "exports": "./translit.ts" -} \ No newline at end of file + "exports": "./translit.ts", + "publish": { + "exclude": [ + ".github", + "__tests__" + ] + } +}