Created
April 7, 2015 00:58
-
-
Save marsimaria/1929466e0701882a5151 to your computer and use it in GitHub Desktop.
Sunflower Module 1 - A module with multiple functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import goslate | |
def getText(text): | |
gs = goslate.Goslate() | |
with open('sunflower.txt', 'r') as f: | |
text = f.read() | |
l = [] | |
l_array = [] | |
for i in range(100): | |
if i==0: | |
trans1 = gs.translate(text, 'en') | |
l.append(trans1) | |
elif i%2==0: | |
transC = gs.translate(l[-1], 'zh-tw') | |
l.append(transC) | |
else: | |
transE = gs.translate(l[-1], 'en') | |
l.append(transE) | |
l_array.append(l[1]) | |
l_array.append(l[-1]) | |
return l_array | |
text_array = getText(text) | |
def wordsincommon(text_array): | |
t1 = text_array[0].split(',') | |
t2 = text_array[1].split(',') | |
output = [] | |
for word in t1: | |
if word in t2: | |
word = word.strip() | |
word = word.replace(' Af', 'Af') | |
output.append(word) | |
return output | |
def returnandreplace(a): | |
p = '\n'.join(a) | |
p.replace('.', '\n') | |
return p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment