You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to resolve the issue 'Document' object has no attribute 'words'?
for sentence in doc.abstracts[0].sentences:
words = []
# skip the first two words, which header
for word in sentence.words:
words.append(word.text)
print(" ".join(words)[:80] + "...")
AttributeError Traceback (most recent call last)
Cell In[9], line 4
2 words = []
3 # skip the first two words, which header
----> 4 for word in sentence.words:
5 words.append(word.text)
6 print(" ".join(words)[:80] + "...")
File ~/papermage/papermage/magelib/entity.py:105, in Entity.getattr(self, name) 103 try: 104 if len(self.spans) > 0:
--> 105 intersection = self.intersect_by_span(name=name) 106 if len(intersection) == 0 and len(self.boxes) > 0: 107 intersection = self.intersect_by_box(name=name)
File ~/papermage/papermage/magelib/entity.py:124, in Entity.intersect_by_span(self, name) 121 if self.layer.doc is None: 122 raise ValueError("This Entity's Layer is not attached to a Document")
--> 124 return self.layer.doc.intersect_by_span(query=self, name=name)
File ~/papermage/papermage/magelib/document.py:192, in Document.intersect_by_span(self, query, name) 190 def intersect_by_span(self, query: Entity, name: str) -> List[Entity]: 191 """Finds all entities that intersect with the query"""
--> 192 return self.get_layer(name=name).intersect_by_span(query=query)
... 69 def get_layer(self, name: str) -> Layer: 70 """Gets a layer by name. For example, doc.get_layer("sentences") returns sentences."""
---> 71 return getattr(self, name)
AttributeError: 'Document' object has no attribute 'words'
The text was updated successfully, but these errors were encountered:
How to resolve the issue 'Document' object has no attribute 'words'?
for sentence in doc.abstracts[0].sentences:
words = []
# skip the first two words, which header
for word in sentence.words:
words.append(word.text)
print(" ".join(words)[:80] + "...")
AttributeError Traceback (most recent call last)
Cell In[9], line 4
2 words = []
3 # skip the first two words, which header
----> 4 for word in sentence.words:
5 words.append(word.text)
6 print(" ".join(words)[:80] + "...")
File ~/papermage/papermage/magelib/entity.py:105, in Entity.getattr(self, name)
103 try:
104 if len(self.spans) > 0:
--> 105 intersection = self.intersect_by_span(name=name)
106 if len(intersection) == 0 and len(self.boxes) > 0:
107 intersection = self.intersect_by_box(name=name)
File ~/papermage/papermage/magelib/entity.py:124, in Entity.intersect_by_span(self, name)
121 if self.layer.doc is None:
122 raise ValueError("This Entity's Layer is not attached to a Document")
--> 124 return self.layer.doc.intersect_by_span(query=self, name=name)
File ~/papermage/papermage/magelib/document.py:192, in Document.intersect_by_span(self, query, name)
190 def intersect_by_span(self, query: Entity, name: str) -> List[Entity]:
191 """Finds all entities that intersect with the query"""
--> 192 return self.get_layer(name=name).intersect_by_span(query=query)
...
69 def get_layer(self, name: str) -> Layer:
70 """Gets a layer by name. For example,
doc.get_layer("sentences")
returns sentences."""---> 71 return getattr(self, name)
AttributeError: 'Document' object has no attribute 'words'
The text was updated successfully, but these errors were encountered: