Created
November 18, 2020 22:05
-
-
Save elsanussi-s-mneina/40fd6be59be26454e00c14d6886eae1f to your computer and use it in GitHub Desktop.
sed script for Arabic romanization (Buckwalter)
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
# Made by Elsanussi Mneina on November 18th, 2020 | |
# Anyone may use. | |
# It implements the Buckwalter transliteration system, where every Arabic Character corresponds to exactly one latin ASCII character. | |
# Useful web pages I used when making this code this code: | |
# How to escape single quotes: https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings | |
# To learn about the Buckwalter tranliteration system see: http://www.qamus.org/transliteration.htm | |
# https://www.tutorialspoint.com/sed/sed_basic_commands.htm | |
# If you need to read a file, replace the "echo" part of the command with a call to cat. | |
# Assuming you have text in Arabic characters in a file named input.txt in the current directory. | |
# Assuming you have text in Latin characters in a file named input2.txt in the current directory. | |
# The following are the two commands. | |
# Command to convert from Arabic to Latin characters | |
cat 'input.txt' | sed 'y/ءأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىيًٌٍَُِّْ/'"'"'>&<}AbptvjHxd*rzs$SDTZEg_fqklmnhwYyFNKaui~o/' | |
# Command to convert from Latin characters to Arabic characters | |
cat 'input2.txt' | sed 'y/'"'"'>&<}AbptvjHxd*rzs$SDTZEg_fqklmnhwYyFNKaui~o/ءأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىيًٌٍَُِّْ/' | |
# Your terminal may misbehave when given Latin characters. Just edit the command in a text editor, and press enter. The results should appear. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment