From 40c182adcdcd6100a2e0659d20b8a1c2f8dfe41c Mon Sep 17 00:00:00 2001 From: SanchoSamba Date: Mon, 16 Dec 2024 18:33:37 +0100 Subject: [PATCH 1/2] Added comma thousands separator for n_tokens and n_types --- orangecontrib/text/widgets/owpreprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orangecontrib/text/widgets/owpreprocess.py b/orangecontrib/text/widgets/owpreprocess.py index 19265c086..c2c6695be 100644 --- a/orangecontrib/text/widgets/owpreprocess.py +++ b/orangecontrib/text/widgets/owpreprocess.py @@ -1338,7 +1338,7 @@ def update_preview(self, data): self.preview = ", ".join(tokens[:5]) n_tokens = data.count_tokens() if data.has_tokens() else '' n_types = data.count_unique_tokens() if data.has_tokens() else '' - self.output_info = f"Tokens: {n_tokens}\nTypes: {n_types}" + self.output_info = f"Tokens: {n_tokens:,}\nTypes: {n_types:,}" except StopIteration: self.preview = "" self.output_info = "" From 31c2aef54344e48efb14cf58bc5c909e33a93c5e Mon Sep 17 00:00:00 2001 From: SanchoSamba Date: Tue, 17 Dec 2024 11:52:46 +0100 Subject: [PATCH 2/2] Thousands separator added to corpus viewer --- orangecontrib/text/widgets/owcorpusviewer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/orangecontrib/text/widgets/owcorpusviewer.py b/orangecontrib/text/widgets/owcorpusviewer.py index ef18fdaef..adb4f0440 100644 --- a/orangecontrib/text/widgets/owcorpusviewer.py +++ b/orangecontrib/text/widgets/owcorpusviewer.py @@ -604,7 +604,7 @@ def refresh_search(self): def on_done(self, res: int): """When matches count is done show the result in the label""" - self.n_matches = res if res is not None else "n/a" + self.n_matches = f"{int(res):,}" if res is not None else "n/a" def on_exception(self, ex): raise ex @@ -613,8 +613,8 @@ def update_info(self): if self.corpus is not None: has_tokens = self.corpus.has_tokens() self.n_matching = f"{self.doc_list.model().rowCount()}/{len(self.corpus)}" - self.n_tokens = self.corpus.count_tokens() if has_tokens else "n/a" - self.n_types = self.corpus.count_unique_tokens() if has_tokens else "n/a" + self.n_tokens = f"{int(self.corpus.count_tokens()):,}" if has_tokens else "n/a" + self.n_types = f"{int(self.corpus.count_unique_tokens()):,}" if has_tokens else "n/a" else: self.n_matching = "n/a" self.n_matches = "n/a"