Skip to content

Commit

Permalink
trying to make pylint a little happier and shave off some function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislit committed May 15, 2015
1 parent 0e76d07 commit 495749e
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 91 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Abydos
:target: https://codeclimate.com/github/chrislit/abydos
:alt: Code Climate

.. image:: https://img.shields.io/badge/Pylint-9.98/10-green.svg
.. image:: https://img.shields.io/badge/Pylint-9.99/10-green.svg
:alt: Pylint Score

.. image:: https://img.shields.io/badge/PEP8-0-brightgreen.svg
Expand Down
177 changes: 87 additions & 90 deletions abydos/stemmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ def lovins(word):
# lowercase, normalize, and compose
word = unicodedata.normalize('NFC', _unicode(word.lower()))

def cond_a(word, suffix_len):
"""Lovins' condition A
"""
return True

def cond_b(word, suffix_len):
"""Lovins' condition B
"""
Expand Down Expand Up @@ -215,100 +210,102 @@ def cond_cc(word, suffix_len):
"""
return word[-suffix_len-1] == 'l'

suffix = {'alistically': cond_b, 'arizability': cond_a,
'izationally': cond_b, 'antialness': cond_a,
'arisations': cond_a, 'arizations': cond_a, 'entialness': cond_a,
'allically': cond_c, 'antaneous': cond_a, 'antiality': cond_a,
'arisation': cond_a, 'arization': cond_a, 'ationally': cond_b,
'ativeness': cond_a, 'eableness': cond_e, 'entations': cond_a,
'entiality': cond_a, 'entialize': cond_a, 'entiation': cond_a,
'ionalness': cond_a, 'istically': cond_a, 'itousness': cond_a,
'izability': cond_a, 'izational': cond_a, 'ableness': cond_a,
'arizable': cond_a, 'entation': cond_a, 'entially': cond_a,
'eousness': cond_a, 'ibleness': cond_a, 'icalness': cond_a,
'ionalism': cond_a, 'ionality': cond_a, 'ionalize': cond_a,
'iousness': cond_a, 'izations': cond_a, 'lessness': cond_a,
'ability': cond_a, 'aically': cond_a, 'alistic': cond_b,
'alities': cond_a, 'ariness': cond_e, 'aristic': cond_a,
'arizing': cond_a, 'ateness': cond_a, 'atingly': cond_a,
'ational': cond_b, 'atively': cond_a, 'ativism': cond_a,
'elihood': cond_e, 'encible': cond_a, 'entally': cond_a,
'entials': cond_a, 'entiate': cond_a, 'entness': cond_a,
'fulness': cond_a, 'ibility': cond_a, 'icalism': cond_a,
'icalist': cond_a, 'icality': cond_a, 'icalize': cond_a,
'ication': cond_g, 'icianry': cond_a, 'ination': cond_a,
'ingness': cond_a, 'ionally': cond_a, 'isation': cond_a,
'ishness': cond_a, 'istical': cond_a, 'iteness': cond_a,
'iveness': cond_a, 'ivistic': cond_a, 'ivities': cond_a,
'ization': cond_f, 'izement': cond_a, 'oidally': cond_a,
'ousness': cond_a, 'aceous': cond_a, 'acious': cond_b,
'action': cond_g, 'alness': cond_a, 'ancial': cond_a,
'ancies': cond_a, 'ancing': cond_b, 'ariser': cond_a,
'arized': cond_a, 'arizer': cond_a, 'atable': cond_a,
'ations': cond_b, 'atives': cond_a, 'eature': cond_z,
'efully': cond_a, 'encies': cond_a, 'encing': cond_a,
'ential': cond_a, 'enting': cond_c, 'entist': cond_a,
'eously': cond_a, 'ialist': cond_a, 'iality': cond_a,
'ialize': cond_a, 'ically': cond_a, 'icance': cond_a,
'icians': cond_a, 'icists': cond_a, 'ifully': cond_a,
'ionals': cond_a, 'ionate': cond_d, 'ioning': cond_a,
'ionist': cond_a, 'iously': cond_a, 'istics': cond_a,
'izable': cond_e, 'lessly': cond_a, 'nesses': cond_a,
'oidism': cond_a, 'acies': cond_a, 'acity': cond_a,
'aging': cond_b, 'aical': cond_a, 'alist': cond_a,
'alism': cond_b, 'ality': cond_a, 'alize': cond_a,
suffix = {'alistically': cond_b, 'arizability': None,
'izationally': cond_b, 'antialness': None,
'arisations': None, 'arizations': None, 'entialness': None,
'allically': cond_c, 'antaneous': None, 'antiality': None,
'arisation': None, 'arization': None, 'ationally': cond_b,
'ativeness': None, 'eableness': cond_e, 'entations': None,
'entiality': None, 'entialize': None, 'entiation': None,
'ionalness': None, 'istically': None, 'itousness': None,
'izability': None, 'izational': None, 'ableness': None,
'arizable': None, 'entation': None, 'entially': None,
'eousness': None, 'ibleness': None, 'icalness': None,
'ionalism': None, 'ionality': None, 'ionalize': None,
'iousness': None, 'izations': None, 'lessness': None,
'ability': None, 'aically': None, 'alistic': cond_b,
'alities': None, 'ariness': cond_e, 'aristic': None,
'arizing': None, 'ateness': None, 'atingly': None,
'ational': cond_b, 'atively': None, 'ativism': None,
'elihood': cond_e, 'encible': None, 'entally': None,
'entials': None, 'entiate': None, 'entness': None,
'fulness': None, 'ibility': None, 'icalism': None,
'icalist': None, 'icality': None, 'icalize': None,
'ication': cond_g, 'icianry': None, 'ination': None,
'ingness': None, 'ionally': None, 'isation': None,
'ishness': None, 'istical': None, 'iteness': None,
'iveness': None, 'ivistic': None, 'ivities': None,
'ization': cond_f, 'izement': None, 'oidally': None,
'ousness': None, 'aceous': None, 'acious': cond_b,
'action': cond_g, 'alness': None, 'ancial': None,
'ancies': None, 'ancing': cond_b, 'ariser': None,
'arized': None, 'arizer': None, 'atable': None,
'ations': cond_b, 'atives': None, 'eature': cond_z,
'efully': None, 'encies': None, 'encing': None,
'ential': None, 'enting': cond_c, 'entist': None,
'eously': None, 'ialist': None, 'iality': None,
'ialize': None, 'ically': None, 'icance': None,
'icians': None, 'icists': None, 'ifully': None,
'ionals': None, 'ionate': cond_d, 'ioning': None,
'ionist': None, 'iously': None, 'istics': None,
'izable': cond_e, 'lessly': None, 'nesses': None,
'oidism': None, 'acies': None, 'acity': None,
'aging': cond_b, 'aical': None, 'alist': None,
'alism': cond_b, 'ality': None, 'alize': None,
'allic': cond_bb, 'anced': cond_b, 'ances': cond_b,
'antic': cond_c, 'arial': cond_a, 'aries': cond_a,
'arily': cond_a, 'arity': cond_b, 'arize': cond_a,
'aroid': cond_a, 'ately': cond_a, 'ating': cond_i,
'ation': cond_b, 'ative': cond_a, 'ators': cond_a,
'atory': cond_a, 'ature': cond_e, 'early': cond_y,
'ehood': cond_a, 'eless': cond_a, 'elity': cond_a,
'ement': cond_a, 'enced': cond_a, 'ences': cond_a,
'eness': cond_e, 'ening': cond_e, 'ental': cond_a,
'ented': cond_c, 'ently': cond_a, 'fully': cond_a,
'ially': cond_a, 'icant': cond_a, 'ician': cond_a,
'icide': cond_a, 'icism': cond_a, 'icist': cond_a,
'icity': cond_a, 'idine': cond_i, 'iedly': cond_a,
'ihood': cond_a, 'inate': cond_a, 'iness': cond_a,
'antic': cond_c, 'arial': None, 'aries': None,
'arily': None, 'arity': cond_b, 'arize': None,
'aroid': None, 'ately': None, 'ating': cond_i,
'ation': cond_b, 'ative': None, 'ators': None,
'atory': None, 'ature': cond_e, 'early': cond_y,
'ehood': None, 'eless': None, 'elity': None,
'ement': None, 'enced': None, 'ences': None,
'eness': cond_e, 'ening': cond_e, 'ental': None,
'ented': cond_c, 'ently': None, 'fully': None,
'ially': None, 'icant': None, 'ician': None,
'icide': None, 'icism': None, 'icist': None,
'icity': None, 'idine': cond_i, 'iedly': None,
'ihood': None, 'inate': None, 'iness': None,
'ingly': cond_b, 'inism': cond_j, 'inity': cond_cc,
'ional': cond_a, 'ioned': cond_a, 'ished': cond_a,
'istic': cond_a, 'ities': cond_a, 'itous': cond_a,
'ively': cond_a, 'ivity': cond_a, 'izers': cond_f,
'izing': cond_f, 'oidal': cond_a, 'oides': cond_a,
'otide': cond_a, 'ously': cond_a, 'able': cond_a, 'ably': cond_a,
'ional': None, 'ioned': None, 'ished': None,
'istic': None, 'ities': None, 'itous': None,
'ively': None, 'ivity': None, 'izers': cond_f,
'izing': cond_f, 'oidal': None, 'oides': None,
'otide': None, 'ously': None, 'able': None, 'ably': None,
'ages': cond_b, 'ally': cond_b, 'ance': cond_b, 'ancy': cond_b,
'ants': cond_b, 'aric': cond_a, 'arly': cond_k, 'ated': cond_i,
'ates': cond_a, 'atic': cond_b, 'ator': cond_a, 'ealy': cond_y,
'edly': cond_e, 'eful': cond_a, 'eity': cond_a, 'ence': cond_a,
'ency': cond_a, 'ened': cond_e, 'enly': cond_e, 'eous': cond_a,
'hood': cond_a, 'ials': cond_a, 'ians': cond_a, 'ible': cond_a,
'ibly': cond_a, 'ical': cond_a, 'ides': cond_l, 'iers': cond_a,
'iful': cond_a, 'ines': cond_m, 'ings': cond_n, 'ions': cond_b,
'ious': cond_a, 'isms': cond_b, 'ists': cond_a, 'itic': cond_h,
'ized': cond_f, 'izer': cond_f, 'less': cond_a, 'lily': cond_a,
'ness': cond_a, 'ogen': cond_a, 'ward': cond_a, 'wise': cond_a,
'ying': cond_b, 'yish': cond_a, 'acy': cond_a, 'age': cond_b,
'aic': cond_a, 'als': cond_bb, 'ant': cond_b, 'ars': cond_o,
'ary': cond_f, 'ata': cond_a, 'ate': cond_a, 'eal': cond_y,
'ants': cond_b, 'aric': None, 'arly': cond_k, 'ated': cond_i,
'ates': None, 'atic': cond_b, 'ator': None, 'ealy': cond_y,
'edly': cond_e, 'eful': None, 'eity': None, 'ence': None,
'ency': None, 'ened': cond_e, 'enly': cond_e, 'eous': None,
'hood': None, 'ials': None, 'ians': None, 'ible': None,
'ibly': None, 'ical': None, 'ides': cond_l, 'iers': None,
'iful': None, 'ines': cond_m, 'ings': cond_n, 'ions': cond_b,
'ious': None, 'isms': cond_b, 'ists': None, 'itic': cond_h,
'ized': cond_f, 'izer': cond_f, 'less': None, 'lily': None,
'ness': None, 'ogen': None, 'ward': None, 'wise': None,
'ying': cond_b, 'yish': None, 'acy': None, 'age': cond_b,
'aic': None, 'als': cond_bb, 'ant': cond_b, 'ars': cond_o,
'ary': cond_f, 'ata': None, 'ate': None, 'eal': cond_y,
'ear': cond_y, 'ely': cond_e, 'ene': cond_e, 'ent': cond_c,
'ery': cond_e, 'ese': cond_a, 'ful': cond_a, 'ial': cond_a,
'ian': cond_a, 'ics': cond_a, 'ide': cond_l, 'ied': cond_a,
'ier': cond_a, 'ies': cond_p, 'ily': cond_a, 'ine': cond_m,
'ery': cond_e, 'ese': None, 'ful': None, 'ial': None,
'ian': None, 'ics': None, 'ide': cond_l, 'ied': None,
'ier': None, 'ies': cond_p, 'ily': None, 'ine': cond_m,
'ing': cond_n, 'ion': cond_q, 'ish': cond_c, 'ism': cond_b,
'ist': cond_a, 'ite': cond_aa, 'ity': cond_a, 'ium': cond_a,
'ive': cond_a, 'ize': cond_f, 'oid': cond_a, 'one': cond_r,
'ous': cond_a, 'ae': cond_a, 'al': cond_bb, 'ar': cond_x,
'ist': None, 'ite': cond_aa, 'ity': None, 'ium': None,
'ive': None, 'ize': cond_f, 'oid': None, 'one': cond_r,
'ous': None, 'ae': None, 'al': cond_bb, 'ar': cond_x,
'as': cond_b, 'ed': cond_e, 'en': cond_f, 'es': cond_e,
'ia': cond_a, 'ic': cond_a, 'is': cond_a, 'ly': cond_b,
'ia': None, 'ic': None, 'is': None, 'ly': cond_b,
'on': cond_s, 'or': cond_t, 'um': cond_u, 'us': cond_v,
'yl': cond_r, '\'s': cond_a, 's\'': cond_a, 'a': cond_a,
'e': cond_a, 'i': cond_a, 'o': cond_a, 's': cond_w, 'y': cond_b}
'yl': cond_r, '\'s': None, 's\'': None, 'a': None,
'e': None, 'i': None, 'o': None, 's': cond_w, 'y': cond_b}

for suffix_len in _range(11, 0, -1):
if ((word[-suffix_len:] in suffix and
len(word)-suffix_len >= 2 and
suffix[word[-suffix_len:]](word, suffix_len))):
ending = word[-suffix_len:]
if (ending in suffix and
len(word)-suffix_len >= 2 and
(suffix[ending] is None or
suffix[ending](word, suffix_len))):
word = word[:-suffix_len]
break

Expand Down

0 comments on commit 495749e

Please sign in to comment.