| Conditions | 132 | 
| Total Lines | 249 | 
| Code Lines | 201 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 197 | 
| CRAP Score | 132 | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
Complex classes like abydos.stemmer._snowball.porter() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | # -*- coding: utf-8 -*-  | 
            ||
| 116 | term[-3] not in self._vowels  | 
            ||
| 117 | and term[-2] in self._vowels  | 
            ||
| 118 | and term[-1] in self._codanonvowels  | 
            ||
| 119 | ):  | 
            ||
| 120 | 1 | return True  | 
            |
| 121 | 1 | return False  | 
            |
| 122 | |||
| 123 | 1 | def _sb_short_word(self, term, r1_prefixes=None):  | 
            |
| 124 | """Return True iff term is a short word.  | 
            ||
| 125 | |||
| 126 | (...according to the Porter2 specification.)  | 
            ||
| 127 | |||
| 128 | Parameters  | 
            ||
| 129 | ----------  | 
            ||
| 130 | term : str  | 
            ||
| 131 | The term to examine  | 
            ||
| 132 | r1_prefixes : set  | 
            ||
| 133 | Prefixes to consider  | 
            ||
| 134 | |||
| 135 | Returns  | 
            ||
| 136 | -------  | 
            ||
| 137 | bool  | 
            ||
| 138 | True iff term is a short word  | 
            ||
| 139 | |||
| 140 | """  | 
            ||
| 141 | 1 | if self._sb_r1(term, r1_prefixes) == len(  | 
            |
| 142 | term  | 
            ||
| 143 | ) and self._sb_ends_in_short_syllable(term):  | 
            ||
| 144 | 1 | return True  | 
            |
| 145 | 1 | return False  | 
            |
| 146 | |||
| 147 | 1 | def _sb_has_vowel(self, term):  | 
            |
| 148 | """Return Porter helper function _sb_has_vowel value.  | 
            ||
| 149 | |||
| 150 | Parameters  | 
            ||
| 151 | ----------  | 
            ||
| 152 | term : str  | 
            ||
| 153 | The term to examine  | 
            ||
| 154 | |||
| 155 | Returns  | 
            ||
| 156 | -------  | 
            ||
| 157 | bool  | 
            ||
| 158 | True iff a vowel exists in the term (as defined in the Porter  | 
            ||
| 159 | stemmer definition)  | 
            ||
| 160 | |||
| 161 | """  | 
            ||
| 162 | 1 | for letter in term:  | 
            |
| 163 | 1 | if letter in self._vowels:  | 
            |
| 164 | 1 | return True  | 
            |
| 165 | 1 | return False  | 
            |
| 166 | |||
| 167 | |||
| 168 | if __name__ == '__main__':  | 
            ||
| 169 | import doctest  | 
            ||
| 170 | |||
| 171 | doctest.testmod()  | 
            ||
| 172 |