add yoda translator

add the script to the projects list

add requirements
This commit is contained in:
sonniki 2019-10-06 11:36:46 +02:00
parent 18fee78cb5
commit d23bbfdcf0
4 changed files with 37 additions and 0 deletions

View File

@ -61,6 +61,7 @@ So far, the following projects have been integrated to this repo:
|[CLI Calculator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/cli_calculator)|[Willian GL](https://github.com/williangl) | |[CLI Calculator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/cli_calculator)|[Willian GL](https://github.com/williangl) |
|[Find PhoneNumber in String](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Find-PhoneNumber-in-String)|[Austin Zuniga](https://github.com/AustinZuniga)| |[Find PhoneNumber in String](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Find-PhoneNumber-in-String)|[Austin Zuniga](https://github.com/AustinZuniga)|
|[IMDB TV Series Info Extractor](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/imdb_episode_ratings)|[Yash Raj Sarrof](https://github.com/yashYRS) | |[IMDB TV Series Info Extractor](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/imdb_episode_ratings)|[Yash Raj Sarrof](https://github.com/yashYRS) |
|[Yoda-speak Translator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/speak_like_yoda)|[sonniki](https://github.com/sonniki) |
## How to use : ## How to use :

10
speak_like_yoda/README.md Normal file
View File

@ -0,0 +1,10 @@
# Speak-Like-Yoda
## Description
A python script that translates an input English sentence into Yoda-speak.
## Usage
Run ```python speak_like_yoda.py```. Type in your sentence to get it translated into Yoda-speak.
## Requirements
The script only uses Python's standard modules ```random``` and ```string```, so no additional installation is needed.

View File

@ -0,0 +1,2 @@
random
string

View File

@ -0,0 +1,24 @@
import random
import string
def speak_like_yoda(sentence):
"""
Translate the input sentence into Yoda-speak.
:param sentence: input string
:return: translation to Yoda-speak
"""
sentence = sentence.lower()
for p in string.punctuation.replace("'", ''):
sentence = sentence.replace(p, '')
words = sentence.split()
random.shuffle(words)
new_sent = ' '.join(words)
print()
print('Your Yodenglish sentence:')
print(new_sent.capitalize())
if __name__ == '__main__':
print('Your English sentence:')
sentence = str(input())
speak_like_yoda(sentence)