farsit 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -4
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/amiryxe/farsit/main/assets/logo-dark.svg">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/amiryxe/farsit/main/assets/logo.svg" alt="farsit" width="300">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/farsit"><img src="https://img.shields.io/npm/v/farsit?color=0f766e" alt="npm version"></a>
|
|
10
|
+
<a href="https://bundlephobia.com/package/farsit"><img src="https://img.shields.io/bundlephobia/minzip/farsit?color=0f766e&label=gzip" alt="gzip size"></a>
|
|
11
|
+
<a href="https://github.com/amiryxe/farsit/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/farsit?color=0f766e" alt="license"></a>
|
|
12
|
+
<img src="https://img.shields.io/badge/dependencies-0-0f766e" alt="zero dependencies">
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center"><a href="https://amiryxe.github.io/farsit/"><b>Live demo →</b></a></p>
|
|
2
16
|
|
|
3
17
|
**Accurate Persian → Finglish transliteration. No AI, no dictionary, zero deps. Slugs included.**
|
|
4
18
|
|
|
@@ -28,9 +42,16 @@ explain('استقامت'); // per-letter trace of every decis
|
|
|
28
42
|
## Install
|
|
29
43
|
|
|
30
44
|
```sh
|
|
31
|
-
npm install farsit
|
|
45
|
+
npm install farsit # or: pnpm add farsit · yarn add farsit
|
|
32
46
|
```
|
|
33
47
|
|
|
48
|
+
```ts
|
|
49
|
+
import { transliterate, slugify, explain } from 'farsit'; // ESM
|
|
50
|
+
const { transliterate, slugify, explain } = require('farsit'); // CommonJS
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Types are included and work with `moduleResolution` `bundler`, `node16` and `nodenext`. No Node-specific APIs, so it runs in browsers, Node, and edge/worker runtimes, fully offline.
|
|
54
|
+
|
|
34
55
|
## API
|
|
35
56
|
|
|
36
57
|
### `transliterate(text, options?) → string`
|
|
@@ -42,7 +63,21 @@ npm install farsit
|
|
|
42
63
|
| `beam` | `8` | Viterbi beam width. |
|
|
43
64
|
|
|
44
65
|
### `slugify(text, options?) → string`
|
|
45
|
-
Takes all the options above, plus
|
|
66
|
+
Takes all the options above, plus:
|
|
67
|
+
|
|
68
|
+
| option | default | |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `separator` | `'-'` | Word separator. |
|
|
71
|
+
| `lowercase` | `true` | Lowercase Latin letters. |
|
|
72
|
+
| `maxLength` | none | Maximum length; cuts at a word boundary. |
|
|
73
|
+
| `keepDigits` | `true` | Keep digits (Persian and Arabic digits become ASCII). |
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
slugify('سفر به اصفهان ۱۴۰۳', { separator: '_' }); // "safar_be_esfahan_1403"
|
|
77
|
+
slugify('سفر به اصفهان ۱۴۰۳', { keepDigits: false }); // "safar-be-esfahan"
|
|
78
|
+
slugify('آموزش برنامهنویسی با تایپاسکریپت', { maxLength: 25 }); // "amuzesh-barnamenevisi-ba"
|
|
79
|
+
slugify('نور خورشید', { longU: 'oo' }); // "noor-khorshid"
|
|
80
|
+
```
|
|
46
81
|
|
|
47
82
|
### `explain(text, options?) → Explanation`
|
|
48
83
|
Returns the normalised input, the output, and for each token its segments, the wazn match, tanvin and ezafe flags, and the per-letter labels with the constraints that produced them.
|
|
@@ -78,7 +113,7 @@ See [bench/RESULTS.md](bench/RESULTS.md) for the full numbers, the ablations and
|
|
|
78
113
|
|
|
79
114
|
## Development
|
|
80
115
|
|
|
81
|
-
`npm test` · `npm run build` · `npm run size` (150 KB gzip budget) · `npm run eval` · `npm run bench` · `npm run train` · `npm run demo` (http://localhost:5180) · `npx tsx tools/regress.ts` (diffs every output against `bench/baseline.json`)
|
|
116
|
+
`npm test` · `npm run build` · `npm run size` (150 KB gzip budget) · `npm run eval` · `npm run bench` · `npm run train` · `npm run demo` (http://localhost:5180) · `npm run demo:build` (GitHub Pages build, base `/farsit/`) · `npx tsx tools/regress.ts` (diffs every output against `bench/baseline.json`)
|
|
82
117
|
|
|
83
118
|
## License
|
|
84
119
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "farsit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Accurate Persian → Finglish (Latin) transliteration. No AI, no dictionary, zero deps. Slugs included.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"persian",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"types": "./dist/index.d.cts",
|
|
45
45
|
"default": "./dist/index.cjs"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
48
49
|
},
|
|
49
50
|
"files": [
|
|
50
51
|
"dist",
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@types/node": "^26.6.6",
|
|
68
69
|
"@typescript/typescript6": "^6.0.2",
|
|
70
|
+
"next-persian-fonts": "^1.5.0",
|
|
69
71
|
"tsup": "^9.0.0",
|
|
70
72
|
"tsx": "^4.23.15",
|
|
71
73
|
"typescript": "^7.0.2",
|