Skip to content

Commit

Permalink
bugfix! figures were not plottin properly because of weird interactin…
Browse files Browse the repository at this point in the history
…o between getattr() and spans
  • Loading branch information
kyleclo committed Mar 13, 2024
1 parent 6a0a4a2 commit d98db4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions papermage/magelib/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ def id(self, id: int) -> None:
def __getattr__(self, name: str) -> List["Entity"]:
"""This Overloading is convenient syntax since the `entity.layer` operation is intuitive for folks."""
try:
return self.intersect_by_span(name=name)
matched_entities_by_span = self.intersect_by_span(name=name)
matched_entities_by_box = self.intersect_by_box(name=name)
deduped_matched_entities = []
for entity in matched_entities_by_span + matched_entities_by_box:
if entity not in deduped_matched_entities:
deduped_matched_entities.append(entity)
return deduped_matched_entities
except ValueError:
# maybe users just want some attribute of the Entity object
return self.__getattribute__(name)
Expand Down Expand Up @@ -153,7 +159,8 @@ def symbols_from_boxes(self) -> List[str]:
if self.layer.doc.symbols is None:
raise ValueError("This Entity's Document is missing symbols")

matched_tokens = self.intersect_by_box(name=TokensFieldName)
# TODO: maybe just an import error for TokensFieldName?
matched_tokens = self.intersect_by_box(name="tokens")
return [self.layer.doc.symbols[span.start : span.end] for t in matched_tokens for span in t.spans]

@property
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = 'papermage'
version = '0.16.0'
version = '0.17.0'
description = 'Papermage. Casting magic over scientific PDFs.'
license = {text = 'Apache-2.0'}
readme = 'README.md'
Expand Down

0 comments on commit d98db4b

Please sign in to comment.