Skip to content

Commit

Permalink
Fix initialization of word_filters in Document.
Browse files Browse the repository at this point in the history
Fix initialization of word_filters in Document.
Use None instead of [] so that lists aren't shared.
  • Loading branch information
jgerrish committed Nov 28, 2023
1 parent 803c2a1 commit 1fe35d6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions documents/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Document:
def __init__(
self,
data: Union[str, Dict[Any, Any]],
word_filters: List[Filter] = [],
word_filters: Optional[List[Filter]] = None,
) -> None:
self.nltk_text = None
self.body_attribute = Document.BodyAttribute
Expand All @@ -48,7 +48,10 @@ def __init__(
self.document = data.copy()
if "id" in self.document:
self.set_doc_id(self.document["id"])
self.word_filters = word_filters
if word_filters is not None:
self.word_filters = word_filters
else:
self.word_filters = []

def __len__(self) -> int:
"length of the document in characters"
Expand Down

0 comments on commit 1fe35d6

Please sign in to comment.