Skip to content

Commit

Permalink
bugfix doc_len and doc_len_tokens means and std_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
guipenedo committed Mar 8, 2024
1 parent e1f9524 commit a98aafd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/datatrove/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def update_doc_stats(self, document: Document):
Returns:
"""
self.stats["doc_len"] += len(document.text)
self.stat_update("doc_len", value=len(document.text), unit="doc")
if token_count := document.metadata.get("token_count", None):
self.stats["doc_len_tokens"] += token_count
self.stat_update("doc_len_tokens", value=token_count, unit="doc")

def track_time(self, unit: str = None):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/datatrove/utils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def from_dict(cls, data):
unit=data.get("unit", cls.unit),
)
else:
return cls(total=data, min=data, max=data, mean=data, n=data, unit="task")
return cls(total=data, min=data, max=data, mean=data, n=1, unit="task")

def __repr__(self):
if self.mean != 1:
Expand Down

0 comments on commit a98aafd

Please sign in to comment.