Coder Social home page Coder Social logo

nightmachinery / rtl_reshaper_rs Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 49 KB

A CLI tool to reshape and reorder bi-directional, Arabic/Persian text for display in apps that do not support them natively

License: MIT License

Rust 100.00%
rtl right-to-left persian arabic persian-language persian-script arabic-language aranic-reshaper persian-reshaper unicode

rtl_reshaper_rs's Introduction

rtl_reshaper_rs

rtl_reshaper_rs is a CLI tool that uses rust libraries arabic_reshaper and unic-bidi to reshape and reorder bi-directional, Arabic/Persian text for display in apps that do not support them natively.

Installation

cargo install --git https://github.com/NightMachinary/rtl_reshaper_rs --force

Or (not recommended):

cargo install rtl_reshaper_rs

Usage

echo 'من غذا خوردم.' $'\n' 'خانه خالی و hollow است ... :)' | rtl_reshaper_rs
echo $'\n'
 .ﻡﺩﺭﻮﺧ ﺍﺬﻏ ﻦﻣ
): ... ﺖﺳﺍ hollow ﻭ ﯽﻟﺎﺧ ﻪﻧﺎﺧ

readme.org_imgs/20210316_211212_rq0bk5.png

Alternatives

Python version (less buggy but much slower)

Benchmarks

cd ~/code/data/sharif_course_list || return $?
hyperfine --warmup=6 'ls -l | rtl_reshaper_rs' 'ls -l | rtl_reshaper.py'
Benchmark #1: ls -l | rtl_reshaper_rs
  Time (mean ± σ):      24.2 ms ±  12.9 ms    [User: 14.8 ms, System: 8.3 ms]
  Range (min … max):    13.9 ms …  91.3 ms    91 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Benchmark #2: ls -l | rtl_reshaper.py
  Time (mean ± σ):      1.310 s ±  0.137 s    [User: 751.1 ms, System: 317.7 ms]
  Range (min … max):    1.051 s …  1.489 s    10 runs

Summary
  'ls -l | rtl_reshaper_rs' ran
   54.07 ± 29.28 times faster than 'ls -l | rtl_reshaper.py'

Known issues

Upstream

Newlines are ordered weirdly:

echo A$'\n'B | rtl_reshaper_rs | cat -n
1	A
2	B
echo ب$'\n'ن | rtl_reshaper_rs | cat -n
1
2	ﺏ
3	ﻥ
echo ب$'\n'ن | rtl_reshaper.py | cat -n
1	ﺏ
2	ﻥ

Punctuation marks are ordered wrongly:

echo "بد :)" | rtl_reshaper_rs
): ﺪﺑ
echo "بد :)" | rtl_reshaper.py
(: ﺪﺑ

License

MIT

rtl_reshaper_rs's People

Contributors

nightmachinery avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.