prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Bag of Words: add option to disable hiding attributes
  Sometimes, one would want to inspect words in Box Plot, MDS, Geo Map, Networks. These widgets don't show hidden attributes, which BoW features are by default. Add a checkbox to 'unhide' these attributes.
  
  </issue>
  <code>
  [start of orangecontrib/text/widgets/utils/owbasevectorizer.py]
  1 from AnyQt.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout
  2 
  3 from Orange.widgets import gui
  4 from Orange.widgets import settings
  5 from Orange.widgets.widget import OWWidget, Input, Output
  6 from orangecontrib.text.corpus import Corpus
  7 
  8 
  9 class OWBaseVectorizer(OWWidget):
  10     """ A base class for feature extraction methods.
  11 
  12     Notes:
  13         Ensure that `create_configuration_layout` and `update_method` are overwritten.
  14     """
  15     # Input/output
  16     class Inputs:
  17         corpus = Input("Corpus", Corpus)
  18 
  19     class Outputs:
  20         corpus = Output("Corpus", Corpus)
  21 
  22     want_main_area = False
  23     resizing_enabled = False
  24 
  25     # Settings
  26     autocommit = settings.Setting(True)
  27 
  28     Method = NotImplemented
  29 
  30     def __init__(self):
  31         super().__init__()
  32         self.corpus = None
  33         self.method = None
  34 
  35         box = QGroupBox(title='Options')
  36         box.setLayout(self.create_configuration_layout())
  37         self.controlArea.layout().addWidget(box)
  38 
  39         buttons_layout = QHBoxLayout()
  40         buttons_layout.addSpacing(15)
  41         buttons_layout.addWidget(
  42             gui.auto_commit(None, self, 'autocommit', 'Commit', box=False)
  43         )
  44         self.controlArea.layout().addLayout(buttons_layout)
  45         self.update_method()
  46 
  47     @Inputs.corpus
  48     def set_data(self, data):
  49         self.corpus = data
  50         self.commit()
  51 
  52     def commit(self):
  53         self.apply()
  54 
  55     def apply(self):
  56         if self.corpus is not None:
  57             new_corpus = self.method.transform(self.corpus)
  58             self.Outputs.corpus.send(new_corpus)
  59 
  60     def update_method(self):
  61         self.method = self.Method()
  62 
  63     def on_change(self):
  64         self.update_method()
  65         self.commit()
  66 
  67     def send_report(self):
  68         self.report_items(self.method.report())
  69 
  70     def create_configuration_layout(self):
  71         return QVBoxLayout()
  72
  [end of orangecontrib/text/widgets/utils/owbasevectorizer.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/orangecontrib/text/widgets/utils/owbasevectorizer.py b/orangecontrib/text/widgets/utils/owbasevectorizer.py
  --- a/orangecontrib/text/widgets/utils/owbasevectorizer.py
  +++ b/orangecontrib/text/widgets/utils/owbasevectorizer.py
  @@ -1,4 +1,5 @@
  -from AnyQt.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout
  +
  +from AnyQt.QtWidgets import QGroupBox, QVBoxLayout
   
   from Orange.widgets import gui
   from Orange.widgets import settings
  @@ -24,6 +25,7 @@
   
       # Settings
       autocommit = settings.Setting(True)
  +    hidden_cb = settings.Setting(True)
   
       Method = NotImplemented
   
  @@ -31,38 +33,55 @@
           super().__init__()
           self.corpus = None
           self.method = None
  +        self.new_corpus = None
  +        self.new_attrs = None
   
           box = QGroupBox(title='Options')
           box.setLayout(self.create_configuration_layout())
           self.controlArea.layout().addWidget(box)
   
  -        buttons_layout = QHBoxLayout()
  -        buttons_layout.addSpacing(15)
  -        buttons_layout.addWidget(
  -            gui.auto_commit(None, self, 'autocommit', 'Commit', box=False)
  -        )
  -        self.controlArea.layout().addLayout(buttons_layout)
  +        output_layout = gui.hBox(self.controlArea)
  +        gui.checkBox(output_layout, self, "hidden_cb", "Hide bow attributes",
  +                     callback=self.hide_attrs)
  +
  +        buttons_layout = gui.hBox(self.controlArea)
  +        gui.auto_commit(buttons_layout, self, 'autocommit', 'Commit', box=False)
           self.update_method()
   
       @Inputs.corpus
       def set_data(self, data):
           self.corpus = data
  -        self.commit()
  +        self.invalidate()
  +
  +    def hide_attrs(self):
  +        if self.new_corpus:
  +            new_domain = self.new_corpus.domain
  +            for f in new_domain.attributes:
  +                if f.name in self.new_attrs:
  +                    f.attributes['hidden'] = self.hidden_cb
  +            self.new_corpus = self.new_corpus.transform(new_domain)
  +            self.commit()
   
       def commit(self):
  -        self.apply()
  +        self.Outputs.corpus.send(self.new_corpus)
   
       def apply(self):
           if self.corpus is not None:
  -            new_corpus = self.method.transform(self.corpus)
  -            self.Outputs.corpus.send(new_corpus)
  +            self.new_corpus = self.method.transform(self.corpus)
  +            self.new_attrs = {f.name for f in self.new_corpus.domain.attributes} \
  +                - {f.name for f in self.corpus.domain.attributes}
  +
  +    def invalidate(self):
  +        self.apply()
  +        self.hide_attrs()
  +        self.commit()
   
       def update_method(self):
           self.method = self.Method()
   
       def on_change(self):
           self.update_method()
  -        self.commit()
  +        self.invalidate()
   
       def send_report(self):
           self.report_items(self.method.report())
  
verification_info: {"golden_diff": "diff --git a/orangecontrib/text/widgets/utils/owbasevectorizer.py b/orangecontrib/text/widgets/utils/owbasevectorizer.py\n--- a/orangecontrib/text/widgets/utils/owbasevectorizer.py\n+++ b/orangecontrib/text/widgets/utils/owbasevectorizer.py\n@@ -1,4 +1,5 @@\n-from AnyQt.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout\n+\n+from AnyQt.QtWidgets import QGroupBox, QVBoxLayout\n \n from Orange.widgets import gui\n from Orange.widgets import settings\n@@ -24,6 +25,7 @@\n \n     # Settings\n     autocommit = settings.Setting(True)\n+    hidden_cb = settings.Setting(True)\n \n     Method = NotImplemented\n \n@@ -31,38 +33,55 @@\n         super().__init__()\n         self.corpus = None\n         self.method = None\n+        self.new_corpus = None\n+        self.new_attrs = None\n \n         box = QGroupBox(title='Options')\n         box.setLayout(self.create_configuration_layout())\n         self.controlArea.layout().addWidget(box)\n \n-        buttons_layout = QHBoxLayout()\n-        buttons_layout.addSpacing(15)\n-        buttons_layout.addWidget(\n-            gui.auto_commit(None, self, 'autocommit', 'Commit', box=False)\n-        )\n-        self.controlArea.layout().addLayout(buttons_layout)\n+        output_layout = gui.hBox(self.controlArea)\n+        gui.checkBox(output_layout, self, \"hidden_cb\", \"Hide bow attributes\",\n+                     callback=self.hide_attrs)\n+\n+        buttons_layout = gui.hBox(self.controlArea)\n+        gui.auto_commit(buttons_layout, self, 'autocommit', 'Commit', box=False)\n         self.update_method()\n \n     @Inputs.corpus\n     def set_data(self, data):\n         self.corpus = data\n-        self.commit()\n+        self.invalidate()\n+\n+    def hide_attrs(self):\n+        if self.new_corpus:\n+            new_domain = self.new_corpus.domain\n+            for f in new_domain.attributes:\n+                if f.name in self.new_attrs:\n+                    f.attributes['hidden'] = self.hidden_cb\n+            self.new_corpus = self.new_corpus.transform(new_domain)\n+            self.commit()\n \n     def commit(self):\n-        self.apply()\n+        self.Outputs.corpus.send(self.new_corpus)\n \n     def apply(self):\n         if self.corpus is not None:\n-            new_corpus = self.method.transform(self.corpus)\n-            self.Outputs.corpus.send(new_corpus)\n+            self.new_corpus = self.method.transform(self.corpus)\n+            self.new_attrs = {f.name for f in self.new_corpus.domain.attributes} \\\n+                - {f.name for f in self.corpus.domain.attributes}\n+\n+    def invalidate(self):\n+        self.apply()\n+        self.hide_attrs()\n+        self.commit()\n \n     def update_method(self):\n         self.method = self.Method()\n \n     def on_change(self):\n         self.update_method()\n-        self.commit()\n+        self.invalidate()\n \n     def send_report(self):\n         self.report_items(self.method.report())\n", "issue": "Bag of Words: add option to disable hiding attributes\nSometimes, one would want to inspect words in Box Plot, MDS, Geo Map, Networks. These widgets don't show hidden attributes, which BoW features are by default. Add a checkbox to 'unhide' these attributes.\n", "before_files": [{"content": "from AnyQt.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout\n\nfrom Orange.widgets import gui\nfrom Orange.widgets import settings\nfrom Orange.widgets.widget import OWWidget, Input, Output\nfrom orangecontrib.text.corpus import Corpus\n\n\nclass OWBaseVectorizer(OWWidget):\n    \"\"\" A base class for feature extraction methods.\n\n    Notes:\n        Ensure that `create_configuration_layout` and `update_method` are overwritten.\n    \"\"\"\n    # Input/output\n    class Inputs:\n        corpus = Input(\"Corpus\", Corpus)\n\n    class Outputs:\n        corpus = Output(\"Corpus\", Corpus)\n\n    want_main_area = False\n    resizing_enabled = False\n\n    # Settings\n    autocommit = settings.Setting(True)\n\n    Method = NotImplemented\n\n    def __init__(self):\n        super().__init__()\n        self.corpus = None\n        self.method = None\n\n        box = QGroupBox(title='Options')\n        box.setLayout(self.create_configuration_layout())\n        self.controlArea.layout().addWidget(box)\n\n        buttons_layout = QHBoxLayout()\n        buttons_layout.addSpacing(15)\n        buttons_layout.addWidget(\n            gui.auto_commit(None, self, 'autocommit', 'Commit', box=False)\n        )\n        self.controlArea.layout().addLayout(buttons_layout)\n        self.update_method()\n\n    @Inputs.corpus\n    def set_data(self, data):\n        self.corpus = data\n        self.commit()\n\n    def commit(self):\n        self.apply()\n\n    def apply(self):\n        if self.corpus is not None:\n            new_corpus = self.method.transform(self.corpus)\n            self.Outputs.corpus.send(new_corpus)\n\n    def update_method(self):\n        self.method = self.Method()\n\n    def on_change(self):\n        self.update_method()\n        self.commit()\n\n    def send_report(self):\n        self.report_items(self.method.report())\n\n    def create_configuration_layout(self):\n        return QVBoxLayout()\n", "path": "orangecontrib/text/widgets/utils/owbasevectorizer.py"}]}