Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroDivisionError Rouge-L summary level #128

Open
dorianve opened this issue Aug 1, 2019 · 2 comments
Open

ZeroDivisionError Rouge-L summary level #128

dorianve opened this issue Aug 1, 2019 · 2 comments
Labels

Comments

@dorianve
Copy link

dorianve commented Aug 1, 2019

Hello,

I have had some ZeroDivisionErrors trying to get the Rouge-L summary level score for one of my data.

The problem was in the function _union_lcs of rouge.py where the "union longest common subsequence count" was divided by the "combined LCS length".

I added the case when combined_lcs_length was equal to 0 to return 0, and it's working fine now.
(I mean, I added that case locally, I cannot change it in this repository)

Does it sound right ?

def _union_lcs(evaluated_sentences, reference_sentence):
    if len(evaluated_sentences) <= 0:
        raise (ValueError("Collections must contain at least 1 sentence."))

    lcs_union = set()
    reference_words = _split_into_words(reference_sentence)
    combined_lcs_length = 0
    for eval_s in evaluated_sentences:
        evaluated_words = _split_into_words(eval_s)
        lcs = set(_recon_lcs(reference_words, evaluated_words))
        combined_lcs_length += len(lcs)
        lcs_union = lcs_union.union(lcs)

    union_lcs_count = len(lcs_union)
    
    # Here the modification:
    if combined_lcs_length == 0:
        return 0
    union_lcs_value = union_lcs_count / combined_lcs_length
    return union_lcs_value
@dorianve
Copy link
Author

dorianve commented Aug 2, 2019

The same goes for def _f_lcs(...) where denom could be 0. So I also added :

# ...
if denom == 0:
    return 0
# ...

@miso-belica
Copy link
Owner

Hi @dorianve, can you attach some simple test to reproduce this? Or maybe create a PR with the test and a fix? You can't update the repository, but you are welcome to send me a PR :)

@miso-belica miso-belica added the bug label Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants