Repository: biolab/orange3-text

Issue:
Preprocess Text: Add info on the number of output tokens
**Is your feature request related to a problem? Please describe.**
Preprocess Text used to report the number of output tokens. It no longer does.

**Describe the solution you'd like**
Add the number of output tokens and types to the widget. The info can be added to either the status bar (output section) or directly to the widget under the Preview.

**Describe alternatives you've considered**
/

**Additional context**
/



Discussion:

Resolving patch:
diff --git a/orangecontrib/text/widgets/owpreprocess.py b/orangecontrib/text/widgets/owpreprocess.py
--- a/orangecontrib/text/widgets/owpreprocess.py
+++ b/orangecontrib/text/widgets/owpreprocess.py
@@ -952,15 +952,20 @@ class Warning(Orange.widgets.data.owpreprocess.OWPreprocess.Warning):
                                     ("preprocess.filter", {})]
                   }  # type: Dict[str, List[Tuple[str, Dict]]]
     storedsettings = Setting(DEFAULT_PP)
+    buttons_area_orientation = Qt.Vertical
 
     def __init__(self):
         ConcurrentWidgetMixin.__init__(self)
         Orange.widgets.data.owpreprocess.OWPreprocess.__init__(self)
+
         box = gui.vBox(self.controlArea, "Preview")
         self.preview = ""
         gui.label(box, self, "%(preview)s", wordWrap=True)
         self.controlArea.layout().insertWidget(1, box)
-        self.controlArea.setFixedWidth(220)
+        box = gui.vBox(self.buttonsArea, "Output")
+        self.output_info = ""
+        gui.label(box, self, "%(output_info)s", wordWrap=True)
+        self.buttonsArea.layout().insertWidget(0, box)
 
     def load(self, saved: Dict) -> StandardItemModel:
         for i, (name, params) in enumerate(saved.get("preprocessors", [])):
@@ -1090,11 +1095,17 @@ def update_preview(self, data):
             try:
                 tokens = next(data.ngrams_iterator(include_postags=True))
                 self.preview = ", ".join(tokens[:5])
+                n_tokens = sum(
+                    map(len, data.tokens)) if data.has_tokens() else ''
+                n_types = len(data.dictionary) if data.has_tokens() else ''
+                self.output_info = f"Tokens: {n_tokens}\nTypes: {n_types}"
             except StopIteration:
                 self.preview = ""
+                self.output_info = ""
 
         else:
             self.preview = ""
+            self.output_info = ""
 
     def workflowEnvChanged(self, key: str, *_):
         if key == "basedir":


Test patch:
diff --git a/orangecontrib/text/widgets/tests/test_owpreprocess.py b/orangecontrib/text/widgets/tests/test_owpreprocess.py
--- a/orangecontrib/text/widgets/tests/test_owpreprocess.py
+++ b/orangecontrib/text/widgets/tests/test_owpreprocess.py
@@ -27,6 +27,16 @@ def test_outputs(self):
         self.assertIsNot(pp_data, self.corpus)
         self.assertNotEqual(pp_data, self.corpus)
 
+    def test_previews(self):
+        self.send_signal(self.widget.Inputs.corpus, self.corpus)
+        self.wait_until_finished()
+        self.assertTrue(self.widget.preview)
+        self.assertTrue(self.widget.output_info)
+        self.send_signal(self.widget.Inputs.corpus, None)
+        self.wait_until_finished()
+        self.assertFalse(self.widget.preview)
+        self.assertFalse(self.widget.output_info)
+
     def test_available_preprocessors(self):
         self.assertEqual(self.widget.preprocessors.rowCount(), 6)