Added index checking to hyponym_detector.py#282
Added index checking to hyponym_detector.py#282dumbshow wants to merge 1 commit intoallenai:mainfrom
Conversation
|
@DeNeutoy can you have a look a this? |
DeNeutoy
left a comment
There was a problem hiding this comment.
@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!
|
|
||
| start = token.i | ||
| while True: | ||
| if start==0: |
There was a problem hiding this comment.
Please add spaces between symbols, (our linter requires it), like if start == 0:
| end = token.i + 1 | ||
| while True: | ||
| previous = doc[end] | ||
| try: |
There was a problem hiding this comment.
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.
Sorry for the delay. Should have time to make these updates shortly.
There was a problem hiding this comment.
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.