Skip to main content

A flask-based microservice to translate english text to pig latin. Wikipedia Link.

Pig Latin is a language game in which words in English are altered. The objective is to conceal the words from others not familiar with the rules.

Pig Latin is simply a form of jargon with rules. The Rules are described later

Demo

You can try your own examples at a web form here.

Example Usage

The fastest way to get started is to request this service from the demo api

Curl

curl --request POST \
  --url https://piglatin.jaichaudhary.com/api/translate \
  --form 'text=How do you say ... in Pig Latin?'

Python

import requests
url = "https://piglatin.jaichaudhary.com/api/translate"
payload = {"text": "How do you say ... in Pig Latin?"}
response = requests.request("POST", url, data=payload)
print response.text

You should see a response like

{
  "text": "Owhay oday ouyay aysay ... inyay Igpay Atinlay?"
}

Installation

If you would like to run the service locally, there are multiple ways

Dockerfile

docker pull ja1chaudhary/pig-latin-translation-service
docker run --name pig-latin-service -p 5000:5000 -d ja1chaudhary/pig-latin-translation-service

Python Package

To install the python package, simply

pip install piglatintranslation
python -m piglatintranslation

Source

git clone https://github.com/Jai-Chaudhary/pig-latin-translation-microservice
cd pig-latin-translation-microservice
python setup.py install
python run.py

Rules

If word begins with consonant sound, all letters before the initial vowel are placed at the end of the word sequence. Then, “ay” is added.

  • pig => igpay

  • banana => ananabay

  • trash => ashtray

  • happy => appyhay

  • duck => uckday

  • glove => oveglay

If word begins with vowel sounds or a silent letter, one just adds “yay” to the end.

  • eat => eatyay

  • omelet => omeletyay

  • are => areyay

Silent Letters

In order to infer silent letters cmu pronunication corpus of 134K words was used(http://www.nltk.org/_modules/nltk/corpus/reader/cmudict.html). The words with silent first letter were filtered into silent_words.json. Among them the most common prefixes were chosen as approximation of silent words. These include ( “pf”, “ph”, “ps”, “pn”, “pt”, “wr”, “ts”, “gn”, “kn”, “jo”, “he”)

Documentation

API documentation is available at http://pig-latin-translation-microservice.readthedocs.io

Testing

To run test cases, simply do

python tests.py

Metadata

Release files for PigLatinTranslation 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PigLatinTranslation 0.2.0
File Size Uploaded
PigLatinTranslation-0.2.0.tar.gz 5.8 kB Details

Release files / PigLatinTranslation-0.2.0.tar.gz

Download URL PigLatinTranslation-0.2.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e407a68c122c30c4393550d1564dd2e85bde48988cbcc2e0b12381a9c2bd5a85
BLAKE2b-256 checksum
How to use checksums
6ff84d84d3851527704545d60e74acd4f4f899bfd89defe1c6c119ceeced1e5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

0.1dev

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page