tzot

Greek-only letters

Sep 10th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import re, subprocess
  2.  
  3. class GreekWords:
  4.     re_greek= re.compile('(?ui)[γδθλξπσςφψΐΰωώ]')
  5.  
  6.     def all_words(self):
  7.         with subprocess.Popen(
  8.             'exec aspell -d el dump master | aspell -l el expand',
  9.             shell=True, stdout=subprocess.PIPE, universal_newlines=True) as sub:
  10.             yield from sub.stdout
  11.         sub.wait()
  12.  
  13.     def most_greek(self):
  14.         return max(self.all_words(), key=lambda i: len(self.re_greek.findall(i)))
  15.  
  16.     def most_unique_greek(self):
  17.         return max(self.all_words(), key=lambda i: len(set(self.re_greek.findall(i))))
Advertisement
Add Comment
Please, Sign In to add comment