Skip to content

Commit fe49d98

Browse files
SamriddhiJaintmylk
authored andcommitted
pep8/pycodestyle fixes for hanging indents in Summarization module (#1202)
* Initial fixes with autopep8 * updated for E713 * Updated to hanging indents * added line braek before operator
1 parent 411d708 commit fe49d98

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

gensim/summarization/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
# bring model classes directly into package namespace, to save some typing
33
from .summarizer import summarize, summarize_corpus
4-
from .keywords import keywords
4+
from .keywords import keywords

gensim/summarization/bm25.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def initialize(self):
4040
self.df[word] += 1
4141

4242
for word, freq in iteritems(self.df):
43-
self.idf[word] = math.log(self.corpus_size-freq+0.5) - math.log(freq+0.5)
43+
self.idf[word] = math.log(self.corpus_size - freq + 0.5) - math.log(freq + 0.5)
4444

4545
def get_score(self, document, index, average_idf):
4646
score = 0
4747
for word in document:
4848
if word not in self.f[index]:
4949
continue
5050
idf = self.idf[word] if self.idf[word] >= 0 else EPSILON * average_idf
51-
score += (idf*self.f[index][word]*(PARAM_K1+1)
52-
/ (self.f[index][word] + PARAM_K1*(1 - PARAM_B+PARAM_B*self.corpus_size / self.avgdl)))
51+
score += (idf * self.f[index][word] * (PARAM_K1 + 1)
52+
/ (self.f[index][word] + PARAM_K1 * (1 - PARAM_B + PARAM_B * self.corpus_size / self.avgdl)))
5353
return score
5454

5555
def get_scores(self, document, average_idf):

gensim/summarization/keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _get_combined_keywords(_keywords, split_text):
164164
result.append(word) # appends last word if keyword and doesn't iterate
165165
for j in xrange(i + 1, len_text):
166166
other_word = _strip_word(split_text[j])
167-
if other_word in _keywords and other_word == split_text[j] and not other_word in combined_word:
167+
if other_word in _keywords and other_word == split_text[j] and other_word not in combined_word:
168168
combined_word.append(other_word)
169169
else:
170170
for keyword in combined_word:

gensim/summarization/summarizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ def summarize(text, ratio=0.2, word_count=None, split=False):
198198
logger.warning("Input text is empty.")
199199
return
200200

201-
# If only one sentence is present, the function raises an error (Avoids ZeroDivisionError).
201+
# If only one sentence is present, the function raises an error (Avoids ZeroDivisionError).
202202
if len(sentences) == 1:
203203
raise ValueError("input must have more than one sentence")
204-
204+
205205
# Warns if the text is too short.
206206
if len(sentences) < INPUT_MIN_LENGTH:
207207
logger.warning("Input text is expected to have at least " + str(INPUT_MIN_LENGTH) + " sentences.")

0 commit comments

Comments
 (0)