Advertisement
yenqwerty

Untitled

Apr 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import re
  2.  
  3. def interpretator(s):
  4.     space_s=space(s)
  5.     dash_s=dash(space_s)
  6.     quote_s=quote(dash_s)
  7.     tabs_s=tabs(quote_s)
  8.     newline_s=newline(tabs_s)
  9.     comma_s = comma(newline_s)
  10.     dot_s = dot(comma_s)
  11.     right_bracket_s = right_bracket(dot_s)
  12.     return left_bracket(right_bracket_s)
  13.  
  14. def left_bracket(s):
  15.     # "( "
  16.     return re.sub(r'\(\s', '(', s)
  17.  
  18. def right_bracket(s):
  19.     # " )"
  20.     return re.sub(r'\s\)', ')', s)
  21.  
  22. def comma(s):
  23.     # " ,"
  24.     return re.sub(r'\s[,]', ',', s)
  25.  
  26. def dot(s):
  27.     # " ."
  28.     return re.sub(r'\s[.]', '.', s)
  29.  
  30. def space(s):
  31.     #
  32.     return re.sub(r'\s+', ' ', s)
  33.  
  34. def dash(s):
  35.     # −  to -
  36.     return re.sub(r'\−','-',s)
  37.  
  38. def quote(s):
  39.     #  “” to «»
  40.     return re.sub(r'\“','«',re.sub(r'\”','»',s))
  41.  
  42. def tabs(s):
  43.     return s
  44.  
  45. def newline(s):
  46.     return s
  47.  
  48. # main
  49. text_in = open('input.txt').read()
  50. print(interpretator(text_in))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement