Skip to content

Commit 5a99c8c

Browse files
committed
Fixes for pylint
1 parent c078c63 commit 5a99c8c

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

wordsegment/__init__.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,26 @@ def score(self, word, previous=None):
8686
# Probability of the given word.
8787

8888
return unigrams[word] / total
89-
else:
90-
# Penalize words not found in the unigrams according
91-
# to their length, a crucial heuristic.
9289

93-
return 10.0 / (total * 10 ** len(word))
94-
else:
95-
bigram = '{0} {1}'.format(previous, word)
90+
# Penalize words not found in the unigrams according
91+
# to their length, a crucial heuristic.
9692

97-
if bigram in bigrams and previous in unigrams:
93+
return 10.0 / (total * 10 ** len(word))
9894

99-
# Conditional probability of the word given the previous
100-
# word. The technical name is *stupid backoff* and it's
101-
# not a probability distribution but it works well in
102-
# practice.
95+
bigram = '{0} {1}'.format(previous, word)
10396

104-
return bigrams[bigram] / total / self.score(previous)
105-
else:
106-
# Fall back to using the unigram probability.
97+
if bigram in bigrams and previous in unigrams:
10798

108-
return self.score(word)
99+
# Conditional probability of the word given the previous
100+
# word. The technical name is *stupid backoff* and it's
101+
# not a probability distribution but it works well in
102+
# practice.
103+
104+
return bigrams[bigram] / total / self.score(previous)
105+
106+
# Fall back to using the unigram probability.
107+
108+
return self.score(word)
109109

110110

111111
def isegment(self, text):
@@ -174,10 +174,10 @@ def clean(cls, text):
174174
return ''.join(letters)
175175

176176

177-
_segmenter = Segmenter()
178-
load = _segmenter.load
179-
isegment = _segmenter.isegment
180-
segment = _segmenter.segment
177+
_segmenter = Segmenter() # pylint: disable=invalid-name
178+
load = _segmenter.load # pylint: disable=invalid-name
179+
isegment = _segmenter.isegment # pylint: disable=invalid-name
180+
segment = _segmenter.segment # pylint: disable=invalid-name
181181
UNIGRAMS = _segmenter.unigrams
182182
BIGRAMS = _segmenter.bigrams
183183

wordsegment/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"WordSegment CLI"
2+
13
import sys
24
from . import main
35

0 commit comments

Comments
 (0)