Skip to content

Add verification when summarize_corpus returns null. Fix #1531.#1570

Merged
menshikh-iv merged 5 commits into
piskvorky:developfrom
summanlp:issue531
Sep 18, 2017
Merged

Add verification when summarize_corpus returns null. Fix #1531.#1570
menshikh-iv merged 5 commits into
piskvorky:developfrom
summanlp:issue531

Conversation

@fbarrios
Copy link
Copy Markdown
Contributor

@fbarrios fbarrios commented Sep 5, 2017

No description provided.

Comment thread gensim/summarization/summarizer.py Outdated
# If couldn't get important docs, the algorithm ends.
if not most_important_docs:
logger.warning("Couldn't get relevant sentences.")
return
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising an exception better? I'm not sure whether this is an error state, or just a warning.

Many people don't have logging enabled, and the docstring implies the result of this function is a string (not None).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is an error. Perhaps it makes even more sense to actually return the entire text as the summary wasn't possible, but this will break compatibility with the old behavior.

Regarding the docstring, the method returns a string or a list if the split parameter was set to true, so perhaps the best thing to do is:

if not most_important_docs:
    logger.warning("Couldn't get relevant sentences.")
    return [] if split else ""

Copy link
Copy Markdown
Owner

@piskvorky piskvorky Sep 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like a good solution 👍
Except we probably want to work with unicode in general ("" => u"", if the rest of the code uses proper unicode too).

CC @menshikh-iv

fbarrios and others added 2 commits September 9, 2017 11:11
- Returns empty list on border case of summarize_corpus.
- Returns empty string or empty list on border case of summarize.
- Fixed test accordingly.
- Removed some test code repetition.
@menshikh-iv menshikh-iv changed the title Add verification when summarize_corpus returns null (Fixes #1531) Add verification when summarize_corpus returns null. Fix #1531. Sep 14, 2017
@menshikh-iv
Copy link
Copy Markdown
Contributor

Thank you @fbarrios

@menshikh-iv menshikh-iv merged commit 02ba343 into piskvorky:develop Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants