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

Added index checking to hyponym_detector.py #282

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dumbshow
Copy link

@dumbshow dumbshow commented Oct 25, 2020

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.

@dakinggg
Copy link
Collaborator

@DeNeutoy can you have a look a this?

Copy link
Contributor

@DeNeutoy DeNeutoy left a 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:
Copy link
Contributor

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:
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants