Skip to content

Division by zero bug. #270

Description

@niuzaisheng

OpenAttack/metric/algorithms/modification.py 的 calc_score(self, tokenA : List[str], tokenB : List[str]) 函数中,当 tokenA 或者 tokenB 任意一个列表为空时,会触发ZeroDivisionError。

https://github.com/thunlp/OpenAttack/blob/4df712e0a5aebc03daa9b1ef353da4b7ea0a1b23/OpenAttack/metric/algorithms/modification.py#LL23C1-L43C29

calc_score([1,1], [1,2]) -> 0.5
calc_score([], [1,2]) -> ZeroDivisionError
calc_score([1,2], []) -> ZeroDivisionError
calc_score([], []) -> ZeroDivisionError

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions