Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.PHONY: sync install build publish clean help test lint check tox-run check-uv run demo update-dev-requirements check-dev-requirements
.DEFAULT_GOAL := help

.PHONY: sync install build publish clean help test lint check tox-run check-uv run demo demo-transliterate demo-syllabify update-dev-requirements check-dev-requirements add-dep
Comment thread
ssoto marked this conversation as resolved.
Outdated

check-uv:
@if ! command -v uv &> /dev/null; then \
Expand All @@ -15,16 +17,24 @@ help: ## Muestra esta ayuda

sync: check-uv ## Sincroniza dependencias y crea entorno virtual con uv
@echo "🔄 Sincronizando dependencias con uv..."
@uv sync --extra dev
@echo "📝 Actualizando dev-requirements.txt..."
@$(MAKE) update-dev-requirements --no-print-directory
@uv sync
@echo "✅ Entorno sincronizado"

sync-dev: check-uv ## Sincroniza dependencias de desarrollo
@echo "🔄 Sincronizando dependencias con uv..."
@uv sync --extra dev
@echo "✅ Entorno dev sincronizado"

install: check-uv sync ## Instala el módulo andaluh en modo desarrollo
@echo "⚙️ Instalando módulo andaluh en modo desarrollo..."
@uv pip install -e .
@echo "✅ Módulo andaluh instalado en modo desarrollo"

install-editable: check-uv sync ## Instala el módulo andaluh en modo desarrollo
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'install-editable' target depends on 'sync', which no longer installs development dependencies. You may want to depend on 'sync-dev' instead to ensure dev dependencies are available.

Suggested change
install-editable: check-uv sync ## Instala el módulo andaluh en modo desarrollo
install-editable: check-uv sync-dev ## Instala el módulo andaluh en modo desarrollo

Copilot uses AI. Check for mistakes.
@echo "⚙️ Instalando módulo andaluh en modo desarrollo..."
@uv pip install -e .
@echo "✅ Módulo andaluh instalado en modo desarrollo"
Comment on lines +33 to +36
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The 'install-editable' target duplicates the 'install' target. Consider consolidating these to avoid duplicated logic.

Suggested change
install-editable: check-uv sync ## Instala el módulo andaluh en modo desarrollo
@echo "⚙️ Instalando módulo andaluh en modo desarrollo..."
@uv pip install -e .
@echo "✅ Módulo andaluh instalado en modo desarrollo"
install-editable: install ## Alias para instalar el módulo andaluh en modo desarrollo

Copilot uses AI. Check for mistakes.

build: check-uv ## Construye el paquete
@echo "Construyendo paquete..."
@if [ -d "dist" ]; then \
Expand All @@ -47,7 +57,7 @@ clean: check-uv ## Limpia archivos generados
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@echo "✅ Limpieza completada"

test: check-uv sync ## Ejecuta los tests
test: check-uv sync-dev ## Ejecuta los tests
@echo "🧪 Ejecutando tests..."
@uv run pytest --cov=andaluh tests/
@echo "✅ Tests completados"
Expand All @@ -73,12 +83,26 @@ run: check-uv sync ## Ejecuta el CLI andaluh (uso: make run TEXT="tu texto aquí
uv run python bin/andaluh "$(TEXT)" $(ARGS); \
fi

demo: check-uv sync ## Ejecuta una demostración del CLI andaluh
@echo "🎯 Demostración de andaluh:"
demo-transliterate: check-uv sync ## Ejecuta una demostración del CLI andaluh
@echo "🎯 Demostración de andaluh (transliteración):"
@echo "Texto original: 'Hola, ¿cómo estás? ¡Qué tal el día!'"
@echo "Transliteración:"
@uv run python bin/andaluh "Hola, ¿cómo estás? ¡Qué tal el día!"

demo-syllabify: check-uv sync ## Ejecuta una demostración del CLI syllabify
@echo "🎯 Demostración de syllabify (silabificación):"
@echo "Palabra original: 'murçiélago'"
@echo "Silabificación:"
@uv run python bin/syllabify --word "murçiélago"
@echo ""
@echo "Palabra original: 'andalûh'"
@echo "Silabificación:"
@uv run python bin/syllabify --word "andalûh"
@echo ""
@echo "Palabra original: 'êppañôh'"
@echo "Silabificación:"
@uv run python bin/syllabify --word "êppañôh"

update-dev-requirements: check-uv ## Actualiza dev-requirements.txt desde pyproject.toml
@echo "📝 Actualizando dev-requirements.txt desde pyproject.toml..."
@uv export --extra dev --format requirements-txt --no-hashes > dev-requirements.txt.tmp
Expand All @@ -100,3 +124,21 @@ check-dev-requirements: check-uv ## Verifica si dev-requirements.txt está sincr
echo "✅ dev-requirements.txt está sincronizado"; \
rm -f dev-requirements.txt.expected; \
fi

add-dep: check-uv ## Añade dependencias a pyproject.toml (uso: make add-dep DEPS="paquete1 paquete2" o make add-dep DEPS="paquete1 paquete2" DEV=true)
@if [ -z "$(DEPS)" ]; then \
echo "❌ Debes especificar al menos una dependencia"; \
echo "📖 Uso: make add-dep DEPS=\"paquete1 paquete2\""; \
echo "📖 Para dependencias de desarrollo: make add-dep DEPS=\"paquete1 paquete2\" DEV=true"; \
exit 1; \
fi
@if [ "$(DEV)" = "true" ]; then \
echo "📦 Añadiendo dependencias de desarrollo: $(DEPS)"; \
uv add --dev $(DEPS); \
else \
echo "📦 Añadiendo dependencias: $(DEPS)"; \
uv add $(DEPS); \
fi
@echo "📝 Actualizando dev-requirements.txt..."
@$(MAKE) update-dev-requirements --no-print-directory
@echo "✅ Dependencias añadidas y dev-requirements.txt actualizado"
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This package introduces transliteration functions to convert *español* (spanish

### Command line tool

Use from the command line with the **andaluh** tool:
Use EPA transliterator from the command line with the **andaluh** tool:

```bash
$ andaluh -h
Expand All @@ -56,6 +56,38 @@ $ andaluh -e z -j "El veloz murciélago hindú comía feliz cardillo y kiwi. La
Er belôh murziélago indú comía felîh cardiyo y kiwi. La zigueña tocaba er zâzzofón detrâh der palenque de paja.
```

You also can transliterate files using the `-i` option:

```bash
$ andaluh -i input.txt > output.txt
```

### EPA Syllabifier

The package includes a **syllabify** tool for syllabifying words using EPA rules:

```bash
$ syllabify -h
usage: syllabify [-h] [--word WORD] [--file FILE]

Syllabify a word

optional arguments:
-h, --help show this help message and exit
--word WORD, -w WORD The EPA word to syllabify
--file FILE, -f FILE The file to syllabify

# Syllabify a single word
$ syllabify --word "murciélago"
mur-cié-la-go

$ syllabify -w "andaluz"
an-da-luz

# Syllabify an entire file
$ syllabify --file input.txt
```

### Development usage

If you're working with the source code, you can use the convenient make commands:
Expand Down
51 changes: 51 additions & 0 deletions bin/syllabify
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim: ts=4

import argparse
import logging
import os
import sys
from epa_syllabifier import syllabify

logging.basicConfig(level=logging.INFO)

def syllabify_file(file_path):
output = ""
with open(file_path, "r", encoding="utf-8") as f:
for line in f:
# check if line is empty
if not line.strip():
output += "\n\n"
continue
for word in line.split():
stripped_word = word.strip()
if stripped_word:
try:
output += '-'.join(syllabify(stripped_word)) + " "
except Exception as e:
logging.error(f"Error syllabifying {stripped_word}: {e}")
output += stripped_word + " "
continue
return output

def main():
parser = argparse.ArgumentParser(description="Syllabify a word")
parser.add_argument("--word", "-w", type=str, help="The EPA word to syllabify")
parser.add_argument("--file", "-f", type=str, help="The file to syllabify")
args = parser.parse_args()
if args.word:
print('-'.join(syllabify(args.word)))
elif args.file:
if not os.path.exists(args.file):
logging.error(f"File {args.file} does not exist")
sys.exit(1)
result = syllabify_file(args.file)
print("=" * 80)
print(result)
else:
parser.print_help()
sys.exit(1)

if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ coverage==7.9.1
# pytest-cov
distlib==0.3.9
# via virtualenv
epa-syllabifier==0.3.0
# via andaluh
exceptiongroup==1.3.0 ; python_full_version < '3.11'
# via pytest
filelock==3.18.0
Expand Down
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"epa-syllabifier~=0.3.0",
]

[project.urls]
Homepage = "https://andaluh.es"
Expand All @@ -43,7 +46,10 @@ dev = [

[tool.setuptools]
packages = ["andaluh"]
script-files = ["bin/andaluh"]
script-files = [
"bin/andaluh",
"bin/syllabify"
]

[tool.setuptools.package-dir]
"" = "."
Expand Down Expand Up @@ -108,4 +114,4 @@ version_files = [
"pyproject.toml:version"
]
tag_format = "v$version"
update_changelog_on_bump = true
update_changelog_on_bump = true