Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Begins an implementation of
Layer
to wrap theList[Entities]
and allow for more intuitive slicing (e.g.doc.sentences[:3].text
instead of[sent.text for sent in doc.sentences]
. This addresses #24 .The new data structure is implemented in
papermage/magelib/layer.py
and inherits from python'sUserList
. The changes into integrateLayer
were mainly made in theDocument
data structure.One design decision to consider is what to do with chained access: e.g.
doc.pages.paragraphs.sentences.tokens
. Currently, each access creates a new layer, so doing the above would create a four-dimensionallist
. Two consequences of this decision:doc.pages.paragraphs.sentences.tokens[0][0][0][0]
, which is a bit ugly.doc.pages.paragraphs.pages
does not return the originalLayer
of pages., which is a bit uninutitiveThe main question is: "Should chained accessing return the union of all of the entities in a single layer or should it return the entities in the shape of the chained accessing?"
As another example, if the doc is
Which should
doc.paragraphs.sentences.text
return?