Universal Rule-based Machine Translation Toolkit (URBaMT)
Project description
URBaMT: Universal Rule-Based Machine Translation toolkit
A tool for translating text from source grammar to target grammar (context-free) with corresponding dictionary.
Why not translate it yourself when Google Translate cannot satisfy you❓
Installation
pip install urbamt
Usage
from urbamt import Translator
# Source sentence to be translated
src_sentences = ["I love good dogs", "I hate bad dogs"]
# Source grammar in nltk parsing style
src_grammar = """
S -> NP VP
NP -> PRP
VP -> VB NP
NP -> JJ NN
PRP -> 'I'
VB -> 'love' | 'hate'
JJ -> 'good' | 'bad'
NN -> 'dogs'
"""
# Some edit within source grammar to target grammar
src_to_target_grammar = {
"NP -> JJ NN": "NP -> NN JJ" # in Vietnamese NN goes before JJ
}
# Word-by-word dictionary from source language to target language
en_to_vi_dict = {
"I":"tôi",
"love":"yêu",
"hate":"ghét",
"dogs":"những chú_chó",
"good":"ngoan",
"bad":"hư"
}
translator = Translator(src_grammar = src_grammar,
src_to_tgt_grammar = src_to_target_grammar,
src_to_tgt_dictionary = en_to_vi_dict)
trans_sentences = translator.translate(src_sentences)
# This should returns ['tôi yêu những chú_chó ngoan', 'tôi ghét những chú_chó hư']
License
This repository is using the Apache 2.0 license that is listed in the repo. Please take a look at LICENSE
as you wish.
BibTeX
If you wish to cite the framework feel free to use this (but only if you loved it 😊):
@misc{phat2020urbamt,
author = {Patrick Phat},
title = {URBaMT: Universal Rule-Based Machine Translation toolkit},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/urbamt/urbamt}},
}
Contributors:
- Patrick Phat Nguyen
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
urbamt-0.0.1b1.tar.gz
(4.4 kB
view details)
File details
Details for the file urbamt-0.0.1b1.tar.gz
.
File metadata
- Download URL: urbamt-0.0.1b1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e2acbf977d9e77fc5340b737913dcdaa5b8966a9c34cb8b7c3073c2261e65211
|
|
MD5 |
110b3cb83479d6d6ca96291dfd838cdb
|
|
BLAKE2b-256 |
c7c2371c312cd44af08d2dc248d829ccfa9ec94fb7bb46c19426e187ef20c77b
|