Skip to content

Commit

Permalink
больше красоты
Browse files Browse the repository at this point in the history
  • Loading branch information
muzhig committed Sep 16, 2012
1 parent 558f17a commit 5267b42
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions main.py
@@ -1,15 +1,13 @@
#coding=utf-8
import re
vowels = set(u'аеёиоуыэюя')
pattern_str = u"(c*[ьъ]?vc+[ьъ](?=v))|(c*[ьъ]?v(?=v|cv))|(c*[ьъ]?vc[ъь]?(?=cv|ccv))|(c*[ьъ]?v[cьъ]*(?=$))"

sign_chars = set(u'ъь')
pattern = re.compile(u"(c*[ьъ]?vc+[ьъ](?=v))|(c*[ьъ]?v(?=v|cv))|(c*[ьъ]?vc[ъь]?(?=cv|ccv))|(c*[ьъ]?v[cьъ]*(?=$))")

word = raw_input('слово:').decode('utf-8')

mask = ''.join(['v' if c in vowels else c if c in sign_chars else 'c' for c in word.lower()])
print mask
def get_syllables(word):
mask = ''.join(['v' if c in vowels else c if c in sign_chars else 'c' for c in word.lower()])
return [word[m.start():m.end()] for m in pattern.finditer(mask)]

syllables = [word[m.start():m.end()] for m in re.finditer(pattern_str,mask)]
print '-'.join(syllables)
word = raw_input('слово:').decode('utf-8')
print '-'.join(get_syllables(word))

0 comments on commit 5267b42

Please sign in to comment.