Skip to content

Instantly share code, notes, and snippets.

@cypreess
Created September 20, 2013 05:39
Show Gist options
  • Save cypreess/6633689 to your computer and use it in GitHub Desktop.
Save cypreess/6633689 to your computer and use it in GitHub Desktop.
MegiTeam scrabble turnament
# coding=utf-8
from pydic import PyDic
sjp = PyDic('../../data/sjp/sjp.pydic')
weights = {u'a': 1, u'ą': 5, u'b': 3, u'c': 2, u'ć': 6, u'd': 2, u'e': 1, u'ę': 5, u'f': 5, u'g': 3, u'h': 3, u'i': 1,
u'j': 3, u'k': 2, u'l': 2, u'ł': 3, u'm': 2, u'n': 1, u'ń': 7, u'o': 1, u'ó': 5, u'p': 2, u'r': 1, u's': 1,
u'ś': 5, u't': 2, u'u': 3, u'w': 1, u'y': 2, u'z': 1, u'ź': 9, u'ż': 5, }
def rank(word):
try:
return reduce(lambda x, y: x + weights[y], word, 0)
except KeyError:
return 0
for word in sjp:
forms = sjp.id_forms(word)
if forms[0][0].lower() == forms[0][0].lower():
for form in forms:
print rank(form), form.encode('utf8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment