Skip to content

Instantly share code, notes, and snippets.

@Khazbs
Created July 9, 2025 15:53
Show Gist options
  • Save Khazbs/25834895153a4f1148db25b6766fd92b to your computer and use it in GitHub Desktop.
Save Khazbs/25834895153a4f1148db25b6766fd92b to your computer and use it in GitHub Desktop.
Transliterate Hebrew letters to Greek letters
import sys
import argparse
def main():
hebr = 'אבגדהוזחטיכךלמםנןסעפףצץקרשת'
grek = 'αβγδευζηθικκλμμννξοππϻϻϙρστ'
hebr_grek = str.maketrans(hebr, grek)
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', nargs='*', type=argparse.FileType('r'), default=sys.stdin, help='read from files instead of stdin')
parser.add_argument('-o', '--output', type=argparse.FileType('w'), default=sys.stdout, help='write to file instead of stdout')
args = parser.parse_args()
for file in args.input:
for line in file:
normalized = ''.join(c for c in line if c.isascii() or c in hebr)
args.output.write(normalized.translate(hebr_grek))
if args.input is not sys.stdin:
file.close()
if args.output is not sys.stdout:
args.output.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment