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
Use abstract classes #1639
Use abstract classes #1639
Conversation
def __str__(self): | ||
raise NotImplementedError() | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pass
here is inconsistent with the rest of the @abstractmethod
. Is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah my mistake there's no docstring for this, that's why =)
nltk/metrics/association.py
Outdated
def _contingency(*marginals): | ||
"""Calculates values of a contingency table from marginal values.""" | ||
raise NotImplementedError("The contingency table is not available" | ||
"in the general ngram case") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these cases I think the error message is important. Is there a way to use @abstractmethod
and still raise the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, added it back!
nltk/metrics/association.py
Outdated
def _marginals(*contingency): | ||
"""Calculates values of contingency table marginals from its values.""" | ||
raise NotImplementedError("The contingency table is not available" | ||
"in the general ngram case") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
For these cases I think the error message is important. Is there a way to use @abstractmethod
and still raise the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, added it back!
@alvations thanks for the feedback - reflected |
Rebased and updated. |
@alvations @stevenbird - does this look better? |
@naoyak – yes, looking good! |
Ref: #1130
Cherry-picking some commits from #1562.