Skip to content

Commit

Permalink
Yiddish transliteration via submodules.
Browse files Browse the repository at this point in the history
  • Loading branch information
scossu committed Feb 28, 2024
1 parent 50d4513 commit 1a2dc25
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push-test-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Push test image to Docker Hub.
on:
push:
branch:
- "main"
- "test"

env:
DOCKER_USER: lcnetdev
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "ext/arabic_rom"]
path = ext/arabic_rom
url = https://github.com/fadhleryani/Arabic_ALA-LC_Romanization.git
[submodule "ext/yiddish"]
path = ext/yiddish
url = https://github.com/ibleaman/yiddish.git
branch = loc
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ RUN apt install -y build-essential tzdata gfortran libopenblas-dev libboost-all-
ENV TZ=America/New_York
ENV _workroot "/usr/local/scriptshifter/src"

WORKDIR ${_workroot}
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Remove development packages.
RUN apt remove -y build-essential
RUN apt autoremove -y

RUN addgroup --system www
RUN adduser --system www
RUN gpasswd -a www www
Expand All @@ -22,6 +14,15 @@ COPY entrypoint.sh uwsgi.ini wsgi.py ./
COPY ext ./ext/
COPY scriptshifter ./scriptshifter/

WORKDIR ${_workroot}
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Remove development packages.
RUN apt remove -y build-essential git
RUN apt autoremove -y
RUN rm -rf ext/yiddish

RUN chmod +x ./entrypoint.sh
RUN chown -R www:www ${_workroot} .

Expand Down
1 change: 1 addition & 0 deletions ext/yiddish
Submodule yiddish added at 9bf22c
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ python-dotenv>=1.0,<2
pyyaml>=6.0,<7
repackage>=0.7.3
uwsgi>=2.0,<2.1
./ext/yiddish
51 changes: 51 additions & 0 deletions scriptshifter/hooks/yiddish_/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# @package ext

__doc__ = """
Yiddish transliteration module.
Courtesy of Isaac Bleaman and Asher Lewis.
https://github.com/ibleaman/yiddish.git
Note the underscore in the module name to disambiguate with the `yiddish`
external package name.
"""


from yiddish import detransliterate, transliterate

from scriptshifter.exceptions import BREAK
from scriptshifter.tools import capitalize


def s2r_post_config(ctx):
"""
Script to Roman.
"""

rom = transliterate(
ctx.src, loc=True,
loshn_koydesh=ctx.options.get("loshn_koydesh"))

if ctx.options["capitalize"] == "all":
rom = capitalize(rom)
elif ctx.options["capitalize"] == "first":
rom = rom[0].upper() + rom[1:]

ctx.dest = rom

return BREAK


def r2s_post_config(ctx):
"""
Roman to script.
NOTE: This doesn't support the `loc` option.
"""

ctx.dest = detransliterate(
ctx.src,
loshn_koydesh=ctx.options.get("loshn_koydesh"))

return BREAK
2 changes: 2 additions & 0 deletions scriptshifter/tables/data/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,7 @@ uzbek_cyrillic:
name: Uzbek (Cyrillic)
yakut_cyrillic:
name: Yakut (Cyrillic)
yiddish:
name: Yiddish
yuit_cyrillic:
name: Yuit (Cyrillic)
21 changes: 21 additions & 0 deletions scriptshifter/tables/data/yiddish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
general:
name: Yiddish

options:
- id: loshn_koydesh
label: Loshn Koydesh
description: [TODO]
type: boolean
default: false

script_to_roman:
hooks:
post_config:
-
- yiddish_.s2r_post_config

roman_to_script:
hooks:
post_config:
-
- yiddish_.r2s_post_config

0 comments on commit 1a2dc25

Please sign in to comment.