Logo Lanfrica

aissam-out/DarijaTranslatorAssistant

Domaine:

natural language processing

Type de record:

software
Créateur:
ais
Hôte:
A library for assisting in translating darija to english. It provides a list of potential translations for a given darija word. It also supports translation of full sentences using LLMs (e.g., OpenAI). # DarijaAssistant Library **DarijaAssistant** is a Python library designed to assist in translating Moroccan Darija (a dialect of Arabic) into English. It integrates two main functionalities: 1. **Assisted Translation**: The `DarijaAssistant` class provides additional support for translating words and sentences using a custom word-distance algorithm, offering assistance to improve translation accuracy, especially for difficult or ambiguous phrases. 2. **LLM Client**: A client that allows interaction with any language model (LLM) hosted at any URL. For enhanced usability, the library also provides built-in support for OpenAI’s GPT models, allowing users to easily integrate them by simply providing the OpenAI API key and the model name, making it work out of the box. This library allows users to perform both raw and assisted translations, improving the contextual understanding of Moroccan Darija sentences through caching, normalization, and additional linguistic analysis. ## Installation To install the library, run: ```bash pip install DarijaTranslatorAssistant ``` ## Usage ### 1. Initializing the Translation model You can choose between a model hosted at any URL or OpenAI. Here's how to initialize the client: ```python from DarijaTranslatorAssistant.llm_client import LLMClient # Example using OpenAI GPT model llm_client = LLMClient(use_openai=True, openai_api_key="your_openai_api_key", openai_model="gpt-4o") # Example using an LLM hosted at a specific URL llm_client = LLMClient(llm_url="your-llm-url.com", use_openai=False) ``` ### 2. Simple Translation You can perform a direct translation using the LLM client. ```python sentence = "law3lm asahbi" # only uses OpenAI's gpt-4o translation_without_assistance = llm_client.translate(sentence) print(translation_without_assistance) # [output]: The world, my friend. ``` ### 3. Assisted Translation For more context-aware translation, use the *DarijaAssistant* class. This will assist the translation …