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

Computing the next sibling id of a passage may result in an IndexOutOfBound error #152

Open
MrGecko opened this issue Jan 15, 2018 · 5 comments
Labels

Comments

@MrGecko
Copy link

MrGecko commented Jan 15, 2018

Computing the next sibling id of a passage may result in an IndexOutOfBound error

Given a document made of 3 passages:
Querying /passage/1-3 -> is ok, no next sibling
Querying /passage/1-2 -> is broken due to the next sibling calculation.

The current code will try to get document_references[end + range_length]
with document_references = [1, 2, 3], end=1 and range_length=2

#MyCapytain/resources/texts/local/capitains/cts.py
#line [635]
    _next = "{}-{}".format(document_references[end+1], document_references[end + range_length])

May be fixed by:

#MyCapytain/resources/texts/local/capitains/cts.py
#line [635]        
if end + range_length >= len(document_references):
    _next = "{}-{}".format(document_references[end+1], document_references[-1])
else:
    _next = "{}-{}".format(document_references[end+1], document_references[end + range_length])
@PonteIneptique
Copy link
Member

PonteIneptique commented Jan 15, 2018

Hey,
Thanks for opening an issue !
Could you provide the documents and the code responsible for the failure ?

@MrGecko
Copy link
Author

MrGecko commented Jan 15, 2018

Sure. I've updated the description.

@PonteIneptique
Copy link
Member

Great fix proposal ! Can you also include a test for this specific case ? :) I know, I ask for a lot :D

@PonteIneptique
Copy link
Member

Hey @MrGecko , I am gonna publish a bugfix today for #153 (2.0.7), do you think you can get the fix on a PR on your own for this one ?

@MrGecko
Copy link
Author

MrGecko commented Jan 25, 2018

Sure, I'll make a PR as soon as possible.

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

No branches or pull requests

2 participants