-
Notifications
You must be signed in to change notification settings - Fork 229
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
Added index checking to hyponym_detector.py #282
base: main
Are you sure you want to change the base?
Conversation
@DeNeutoy can you have a look a this? |
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.
@dumbshow, thanks for catching this! Two small things, and then also could you add a test for this in this file?
https://github.com/allenai/scispacy/blob/master/tests/test_hyponym_detector.py#L8
Thanks!
@@ -62,6 +62,8 @@ def expand_to_noun_compound(self, token: Token, doc: Doc): | |||
|
|||
start = token.i | |||
while True: | |||
if start==0: |
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.
Please add spaces between symbols, (our linter requires it), like if start == 0:
@@ -70,7 +72,10 @@ def expand_to_noun_compound(self, token: Token, doc: Doc): | |||
|
|||
end = token.i + 1 | |||
while True: | |||
previous = doc[end] | |||
try: |
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.
Instead of using try/except
here, could you get the length of the doc before this while loop (len(doc)
) and check against it each time? It's more explicit and doesn't silently catch other index errors that may be thrown e.g within spacy.
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.
Sorry for the delay. Should have time to make these updates shortly.
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.
No problem, contributions are always welcome regardless of timeframe :)
Hi, I was getting errors with noun phrases that occurred at the beginning and end of SpaCy docs in hyponym_detector.py. (Not sure if I have filed this request correctly....I am new to git....) Thank you.