Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def euro_english(s):
- out = [' ']
- s = ' ' + s + ' '
- i = 0
- while i < len(s):
- for art in 'a an the'.split():
- if s[i: i+len(art)].lower() == art and not out[-1].isalpha() and not s[i+len(art)].isalpha():
- i += len(art)
- to_upper = s[i].isupper()
- char = s[i].lower()
- if s[i] == 'e' and not s[i+1].isalpha() and out[-1].isalpha():
- char = None
- elif s[i: i+2].lower() in 'ce ci'.split():
- char = 's'
- elif s[i].lower() == 'c':
- char = 'k'
- elif s[i: i+2].lower() in 'ee oo'.split():
- char = 'i' if s[i+1] == 'e' else 'u'
- if char:
- out.append(char.upper() if to_upper else char)
- i += 1 + (s[i: i+2].lower() in 'ee oo'.split())
- while len(out) > 1 and out[-1] == out[-2].lower() and (out[-1].isalpha() or out[-1] == ' '):
- del out[-1]
- if out and out[-1] == ' ':
- del out[-1]
- if out and out[0] == ' ':
- del out[0]
- return ''.join(out)
- s = input()
- print(euro_english(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement