prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  OWCorpus: save Text Features in Settings
  <!--
  This is an issue template. Please fill in the relevant details in the
  sections below.
  -->
  
  ##### Text version
  <!-- From menu _Options→Add-ons→Orange3-Text_ or code `orangecontrib.text.version.full_version` -->
  0.2.3
  
  ##### Orange version
  <!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
  3.5.dev
  
  ##### Expected behavior
  Corpus widget remembers set Text Features.
  
  
  ##### Actual behavior
  Saved workflow (i.e. Corpus) doesn't store Text Features the user has set.
  
  
  ##### Steps to reproduce the behavior
  Corpus (load a data set with several string attributes, set the Text Feature to be one of them, but not default).
  Save and reload workflow.
  Text Feature is reloaded to default instead of the selected one.
  
  
  ##### Additional info (worksheets, data, screenshots, ...)
  
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `orangecontrib/text/widgets/owloadcorpus.py`
  Content:
  ```
  1 import os
  2 
  3 from Orange.data.io import FileFormat
  4 from Orange.widgets import gui
  5 from Orange.widgets.utils.itemmodels import VariableListModel
  6 from Orange.widgets.data.owselectcolumns import VariablesListItemView
  7 from Orange.widgets.settings import Setting
  8 from Orange.widgets.widget import OWWidget, Msg
  9 from orangecontrib.text.corpus import Corpus, get_sample_corpora_dir
  10 from orangecontrib.text.widgets.utils import widgets
  11 
  12 
  13 class Output:
  14     CORPUS = "Corpus"
  15 
  16 
  17 class OWLoadCorpus(OWWidget):
  18     name = "Corpus"
  19     description = "Load a corpus of text documents, (optionally) tagged with categories."
  20     icon = "icons/TextFile.svg"
  21     priority = 10
  22 
  23     outputs = [(Output.CORPUS, Corpus)]
  24     want_main_area = False
  25     resizing_enabled = False
  26 
  27     dlgFormats = (
  28         "All readable files ({});;".format(
  29             '*' + ' *'.join(FileFormat.readers.keys())) +
  30         ";;".join("{} (*{})".format(f.DESCRIPTION, ' *'.join(f.EXTENSIONS))
  31                   for f in sorted(set(FileFormat.readers.values()),
  32                                   key=list(FileFormat.readers.values()).index)))
  33 
  34     recent_files = Setting([])
  35 
  36     class Error(OWWidget.Error):
  37         read_file = Msg("Can't read file {} ({})")
  38 
  39     def __init__(self):
  40         super().__init__()
  41 
  42         self.corpus = None
  43 
  44         # Browse file box
  45         fbox = gui.widgetBox(self.controlArea, "Corpus file", orientation=0)
  46         widget = widgets.FileWidget(recent_files=self.recent_files, icon_size=(16, 16), on_open=self.open_file,
  47                                     directory_aliases={"Browse documentation corpora ...": get_sample_corpora_dir()},
  48                                     dialog_format=self.dlgFormats, dialog_title='Open Orange Document Corpus',
  49                                     allow_empty=False, reload_label='Reload', browse_label='Browse')
  50         fbox.layout().addWidget(widget)
  51 
  52         # Corpus info
  53         ibox = gui.widgetBox(self.controlArea, "Corpus info", addSpace=True)
  54         corp_info = "Corpus of 0 documents."
  55         self.info_label = gui.label(ibox, self, corp_info)
  56 
  57         # Used Text Features
  58         fbox = gui.widgetBox(self.controlArea, orientation=0)
  59         ubox = gui.widgetBox(fbox, "Used text features", addSpace=True)
  60         self.used_attrs = VariableListModel(enable_dnd=True)
  61         self.used_attrs_view = VariablesListItemView()
  62         self.used_attrs_view.setModel(self.used_attrs)
  63         ubox.layout().addWidget(self.used_attrs_view)
  64 
  65         aa = self.used_attrs
  66         aa.dataChanged.connect(self.update_feature_selection)
  67         aa.rowsInserted.connect(self.update_feature_selection)
  68         aa.rowsRemoved.connect(self.update_feature_selection)
  69 
  70         # Ignored Text Features
  71         ibox = gui.widgetBox(fbox, "Ignored text features", addSpace=True)
  72         self.unused_attrs = VariableListModel(enable_dnd=True)
  73         self.unused_attrs_view = VariablesListItemView()
  74         self.unused_attrs_view.setModel(self.unused_attrs)
  75         ibox.layout().addWidget(self.unused_attrs_view)
  76 
  77         # load first file
  78         widget.select(0)
  79 
  80     def open_file(self, path):
  81         self.Error.read_file.clear()
  82         self.used_attrs[:] = []
  83         self.unused_attrs[:] = []
  84         if path:
  85             try:
  86                 self.corpus = Corpus.from_file(path)
  87                 self.corpus.name = os.path.splitext(os.path.basename(path))[0]
  88                 self.info_label.setText("Corpus of {} documents.".format(len(self.corpus)))
  89                 self.used_attrs.extend(self.corpus.text_features)
  90                 self.unused_attrs.extend([f for f in self.corpus.domain.metas
  91                                           if f.is_string and f not in self.corpus.text_features])
  92             except BaseException as err:
  93                 self.Error.read_file(path, str(err))
  94 
  95     def update_feature_selection(self):
  96         # TODO fix VariablesListItemView so it does not emit
  97         # duplicated data when reordering inside a single window
  98         def remove_duplicates(l):
  99             unique = []
  100             for i in l:
  101                 if i not in unique:
  102                     unique.append(i)
  103             return unique
  104 
  105         if self.corpus is not None:
  106             self.corpus.set_text_features(remove_duplicates(self.used_attrs))
  107             self.send(Output.CORPUS, self.corpus)
  108 
  109 
  110 if __name__ == '__main__':
  111     from AnyQt.QtWidgets import QApplication
  112     app = QApplication([])
  113     widget = OWLoadCorpus()
  114     widget.show()
  115     app.exec()
  116     widget.saveSettings()
  117
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/orangecontrib/text/widgets/owloadcorpus.py b/orangecontrib/text/widgets/owloadcorpus.py
  --- a/orangecontrib/text/widgets/owloadcorpus.py
  +++ b/orangecontrib/text/widgets/owloadcorpus.py
  @@ -4,7 +4,7 @@
   from Orange.widgets import gui
   from Orange.widgets.utils.itemmodels import VariableListModel
   from Orange.widgets.data.owselectcolumns import VariablesListItemView
  -from Orange.widgets.settings import Setting
  +from Orange.widgets.settings import Setting, ContextSetting, PerfectDomainContextHandler
   from Orange.widgets.widget import OWWidget, Msg
   from orangecontrib.text.corpus import Corpus, get_sample_corpora_dir
   from orangecontrib.text.widgets.utils import widgets
  @@ -31,7 +31,12 @@
                     for f in sorted(set(FileFormat.readers.values()),
                                     key=list(FileFormat.readers.values()).index)))
   
  +    settingsHandler = PerfectDomainContextHandler(
  +        match_values=PerfectDomainContextHandler.MATCH_VALUES_ALL
  +    )
  +
       recent_files = Setting([])
  +    used_attrs = ContextSetting([])
   
       class Error(OWWidget.Error):
           read_file = Msg("Can't read file {} ({})")
  @@ -57,38 +62,41 @@
           # Used Text Features
           fbox = gui.widgetBox(self.controlArea, orientation=0)
           ubox = gui.widgetBox(fbox, "Used text features", addSpace=True)
  -        self.used_attrs = VariableListModel(enable_dnd=True)
  +        self.used_attrs_model = VariableListModel(enable_dnd=True)
           self.used_attrs_view = VariablesListItemView()
  -        self.used_attrs_view.setModel(self.used_attrs)
  +        self.used_attrs_view.setModel(self.used_attrs_model)
           ubox.layout().addWidget(self.used_attrs_view)
   
  -        aa = self.used_attrs
  +        aa = self.used_attrs_model
           aa.dataChanged.connect(self.update_feature_selection)
           aa.rowsInserted.connect(self.update_feature_selection)
           aa.rowsRemoved.connect(self.update_feature_selection)
   
           # Ignored Text Features
           ibox = gui.widgetBox(fbox, "Ignored text features", addSpace=True)
  -        self.unused_attrs = VariableListModel(enable_dnd=True)
  +        self.unused_attrs_model = VariableListModel(enable_dnd=True)
           self.unused_attrs_view = VariablesListItemView()
  -        self.unused_attrs_view.setModel(self.unused_attrs)
  +        self.unused_attrs_view.setModel(self.unused_attrs_model)
           ibox.layout().addWidget(self.unused_attrs_view)
   
           # load first file
           widget.select(0)
   
       def open_file(self, path):
  +        self.closeContext()
           self.Error.read_file.clear()
  -        self.used_attrs[:] = []
  -        self.unused_attrs[:] = []
  +        self.used_attrs_model[:] = []
  +        self.unused_attrs_model[:] = []
           if path:
               try:
                   self.corpus = Corpus.from_file(path)
                   self.corpus.name = os.path.splitext(os.path.basename(path))[0]
                   self.info_label.setText("Corpus of {} documents.".format(len(self.corpus)))
  -                self.used_attrs.extend(self.corpus.text_features)
  -                self.unused_attrs.extend([f for f in self.corpus.domain.metas
  -                                          if f.is_string and f not in self.corpus.text_features])
  +                self.used_attrs = list(self.corpus.text_features)
  +                self.openContext(self.corpus)
  +                self.used_attrs_model.extend(self.used_attrs)
  +                self.unused_attrs_model.extend([f for f in self.corpus.domain.metas
  +                                          if f.is_string and f not in self.used_attrs_model])
               except BaseException as err:
                   self.Error.read_file(path, str(err))
   
  @@ -103,8 +111,9 @@
               return unique
   
           if self.corpus is not None:
  -            self.corpus.set_text_features(remove_duplicates(self.used_attrs))
  +            self.corpus.set_text_features(remove_duplicates(self.used_attrs_model))
               self.send(Output.CORPUS, self.corpus)
  +            self.used_attrs = list(self.used_attrs_model)
   
   
   if __name__ == '__main__':
  
verification_info: {"golden_diff": "diff --git a/orangecontrib/text/widgets/owloadcorpus.py b/orangecontrib/text/widgets/owloadcorpus.py\n--- a/orangecontrib/text/widgets/owloadcorpus.py\n+++ b/orangecontrib/text/widgets/owloadcorpus.py\n@@ -4,7 +4,7 @@\n from Orange.widgets import gui\n from Orange.widgets.utils.itemmodels import VariableListModel\n from Orange.widgets.data.owselectcolumns import VariablesListItemView\n-from Orange.widgets.settings import Setting\n+from Orange.widgets.settings import Setting, ContextSetting, PerfectDomainContextHandler\n from Orange.widgets.widget import OWWidget, Msg\n from orangecontrib.text.corpus import Corpus, get_sample_corpora_dir\n from orangecontrib.text.widgets.utils import widgets\n@@ -31,7 +31,12 @@\n                   for f in sorted(set(FileFormat.readers.values()),\n                                   key=list(FileFormat.readers.values()).index)))\n \n+    settingsHandler = PerfectDomainContextHandler(\n+        match_values=PerfectDomainContextHandler.MATCH_VALUES_ALL\n+    )\n+\n     recent_files = Setting([])\n+    used_attrs = ContextSetting([])\n \n     class Error(OWWidget.Error):\n         read_file = Msg(\"Can't read file {} ({})\")\n@@ -57,38 +62,41 @@\n         # Used Text Features\n         fbox = gui.widgetBox(self.controlArea, orientation=0)\n         ubox = gui.widgetBox(fbox, \"Used text features\", addSpace=True)\n-        self.used_attrs = VariableListModel(enable_dnd=True)\n+        self.used_attrs_model = VariableListModel(enable_dnd=True)\n         self.used_attrs_view = VariablesListItemView()\n-        self.used_attrs_view.setModel(self.used_attrs)\n+        self.used_attrs_view.setModel(self.used_attrs_model)\n         ubox.layout().addWidget(self.used_attrs_view)\n \n-        aa = self.used_attrs\n+        aa = self.used_attrs_model\n         aa.dataChanged.connect(self.update_feature_selection)\n         aa.rowsInserted.connect(self.update_feature_selection)\n         aa.rowsRemoved.connect(self.update_feature_selection)\n \n         # Ignored Text Features\n         ibox = gui.widgetBox(fbox, \"Ignored text features\", addSpace=True)\n-        self.unused_attrs = VariableListModel(enable_dnd=True)\n+        self.unused_attrs_model = VariableListModel(enable_dnd=True)\n         self.unused_attrs_view = VariablesListItemView()\n-        self.unused_attrs_view.setModel(self.unused_attrs)\n+        self.unused_attrs_view.setModel(self.unused_attrs_model)\n         ibox.layout().addWidget(self.unused_attrs_view)\n \n         # load first file\n         widget.select(0)\n \n     def open_file(self, path):\n+        self.closeContext()\n         self.Error.read_file.clear()\n-        self.used_attrs[:] = []\n-        self.unused_attrs[:] = []\n+        self.used_attrs_model[:] = []\n+        self.unused_attrs_model[:] = []\n         if path:\n             try:\n                 self.corpus = Corpus.from_file(path)\n                 self.corpus.name = os.path.splitext(os.path.basename(path))[0]\n                 self.info_label.setText(\"Corpus of {} documents.\".format(len(self.corpus)))\n-                self.used_attrs.extend(self.corpus.text_features)\n-                self.unused_attrs.extend([f for f in self.corpus.domain.metas\n-                                          if f.is_string and f not in self.corpus.text_features])\n+                self.used_attrs = list(self.corpus.text_features)\n+                self.openContext(self.corpus)\n+                self.used_attrs_model.extend(self.used_attrs)\n+                self.unused_attrs_model.extend([f for f in self.corpus.domain.metas\n+                                          if f.is_string and f not in self.used_attrs_model])\n             except BaseException as err:\n                 self.Error.read_file(path, str(err))\n \n@@ -103,8 +111,9 @@\n             return unique\n \n         if self.corpus is not None:\n-            self.corpus.set_text_features(remove_duplicates(self.used_attrs))\n+            self.corpus.set_text_features(remove_duplicates(self.used_attrs_model))\n             self.send(Output.CORPUS, self.corpus)\n+            self.used_attrs = list(self.used_attrs_model)\n \n \n if __name__ == '__main__':\n", "issue": "OWCorpus: save Text Features in Settings\n<!--\r\nThis is an issue template. Please fill in the relevant details in the\r\nsections below.\r\n-->\r\n\r\n##### Text version\r\n<!-- From menu _Options\u2192Add-ons\u2192Orange3-Text_ or code `orangecontrib.text.version.full_version` -->\r\n0.2.3\r\n\r\n##### Orange version\r\n<!-- From menu _Help\u2192About\u2192Version_ or code `Orange.version.full_version` -->\r\n3.5.dev\r\n\r\n##### Expected behavior\r\nCorpus widget remembers set Text Features.\r\n\r\n\r\n##### Actual behavior\r\nSaved workflow (i.e. Corpus) doesn't store Text Features the user has set.\r\n\r\n\r\n##### Steps to reproduce the behavior\r\nCorpus (load a data set with several string attributes, set the Text Feature to be one of them, but not default).\r\nSave and reload workflow.\r\nText Feature is reloaded to default instead of the selected one.\r\n\r\n\r\n##### Additional info (worksheets, data, screenshots, ...)\r\n\r\n\r\n\n", "before_files": [{"content": "import os\n\nfrom Orange.data.io import FileFormat\nfrom Orange.widgets import gui\nfrom Orange.widgets.utils.itemmodels import VariableListModel\nfrom Orange.widgets.data.owselectcolumns import VariablesListItemView\nfrom Orange.widgets.settings import Setting\nfrom Orange.widgets.widget import OWWidget, Msg\nfrom orangecontrib.text.corpus import Corpus, get_sample_corpora_dir\nfrom orangecontrib.text.widgets.utils import widgets\n\n\nclass Output:\n    CORPUS = \"Corpus\"\n\n\nclass OWLoadCorpus(OWWidget):\n    name = \"Corpus\"\n    description = \"Load a corpus of text documents, (optionally) tagged with categories.\"\n    icon = \"icons/TextFile.svg\"\n    priority = 10\n\n    outputs = [(Output.CORPUS, Corpus)]\n    want_main_area = False\n    resizing_enabled = False\n\n    dlgFormats = (\n        \"All readable files ({});;\".format(\n            '*' + ' *'.join(FileFormat.readers.keys())) +\n        \";;\".join(\"{} (*{})\".format(f.DESCRIPTION, ' *'.join(f.EXTENSIONS))\n                  for f in sorted(set(FileFormat.readers.values()),\n                                  key=list(FileFormat.readers.values()).index)))\n\n    recent_files = Setting([])\n\n    class Error(OWWidget.Error):\n        read_file = Msg(\"Can't read file {} ({})\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.corpus = None\n\n        # Browse file box\n        fbox = gui.widgetBox(self.controlArea, \"Corpus file\", orientation=0)\n        widget = widgets.FileWidget(recent_files=self.recent_files, icon_size=(16, 16), on_open=self.open_file,\n                                    directory_aliases={\"Browse documentation corpora ...\": get_sample_corpora_dir()},\n                                    dialog_format=self.dlgFormats, dialog_title='Open Orange Document Corpus',\n                                    allow_empty=False, reload_label='Reload', browse_label='Browse')\n        fbox.layout().addWidget(widget)\n\n        # Corpus info\n        ibox = gui.widgetBox(self.controlArea, \"Corpus info\", addSpace=True)\n        corp_info = \"Corpus of 0 documents.\"\n        self.info_label = gui.label(ibox, self, corp_info)\n\n        # Used Text Features\n        fbox = gui.widgetBox(self.controlArea, orientation=0)\n        ubox = gui.widgetBox(fbox, \"Used text features\", addSpace=True)\n        self.used_attrs = VariableListModel(enable_dnd=True)\n        self.used_attrs_view = VariablesListItemView()\n        self.used_attrs_view.setModel(self.used_attrs)\n        ubox.layout().addWidget(self.used_attrs_view)\n\n        aa = self.used_attrs\n        aa.dataChanged.connect(self.update_feature_selection)\n        aa.rowsInserted.connect(self.update_feature_selection)\n        aa.rowsRemoved.connect(self.update_feature_selection)\n\n        # Ignored Text Features\n        ibox = gui.widgetBox(fbox, \"Ignored text features\", addSpace=True)\n        self.unused_attrs = VariableListModel(enable_dnd=True)\n        self.unused_attrs_view = VariablesListItemView()\n        self.unused_attrs_view.setModel(self.unused_attrs)\n        ibox.layout().addWidget(self.unused_attrs_view)\n\n        # load first file\n        widget.select(0)\n\n    def open_file(self, path):\n        self.Error.read_file.clear()\n        self.used_attrs[:] = []\n        self.unused_attrs[:] = []\n        if path:\n            try:\n                self.corpus = Corpus.from_file(path)\n                self.corpus.name = os.path.splitext(os.path.basename(path))[0]\n                self.info_label.setText(\"Corpus of {} documents.\".format(len(self.corpus)))\n                self.used_attrs.extend(self.corpus.text_features)\n                self.unused_attrs.extend([f for f in self.corpus.domain.metas\n                                          if f.is_string and f not in self.corpus.text_features])\n            except BaseException as err:\n                self.Error.read_file(path, str(err))\n\n    def update_feature_selection(self):\n        # TODO fix VariablesListItemView so it does not emit\n        # duplicated data when reordering inside a single window\n        def remove_duplicates(l):\n            unique = []\n            for i in l:\n                if i not in unique:\n                    unique.append(i)\n            return unique\n\n        if self.corpus is not None:\n            self.corpus.set_text_features(remove_duplicates(self.used_attrs))\n            self.send(Output.CORPUS, self.corpus)\n\n\nif __name__ == '__main__':\n    from AnyQt.QtWidgets import QApplication\n    app = QApplication([])\n    widget = OWLoadCorpus()\n    widget.show()\n    app.exec()\n    widget.saveSettings()\n", "path": "orangecontrib/text/widgets/owloadcorpus.py"}], "after_files": [{"content": "import os\n\nfrom Orange.data.io import FileFormat\nfrom Orange.widgets import gui\nfrom Orange.widgets.utils.itemmodels import VariableListModel\nfrom Orange.widgets.data.owselectcolumns import VariablesListItemView\nfrom Orange.widgets.settings import Setting, ContextSetting, PerfectDomainContextHandler\nfrom Orange.widgets.widget import OWWidget, Msg\nfrom orangecontrib.text.corpus import Corpus, get_sample_corpora_dir\nfrom orangecontrib.text.widgets.utils import widgets\n\n\nclass Output:\n    CORPUS = \"Corpus\"\n\n\nclass OWLoadCorpus(OWWidget):\n    name = \"Corpus\"\n    description = \"Load a corpus of text documents, (optionally) tagged with categories.\"\n    icon = \"icons/TextFile.svg\"\n    priority = 10\n\n    outputs = [(Output.CORPUS, Corpus)]\n    want_main_area = False\n    resizing_enabled = False\n\n    dlgFormats = (\n        \"All readable files ({});;\".format(\n            '*' + ' *'.join(FileFormat.readers.keys())) +\n        \";;\".join(\"{} (*{})\".format(f.DESCRIPTION, ' *'.join(f.EXTENSIONS))\n                  for f in sorted(set(FileFormat.readers.values()),\n                                  key=list(FileFormat.readers.values()).index)))\n\n    settingsHandler = PerfectDomainContextHandler(\n        match_values=PerfectDomainContextHandler.MATCH_VALUES_ALL\n    )\n\n    recent_files = Setting([])\n    used_attrs = ContextSetting([])\n\n    class Error(OWWidget.Error):\n        read_file = Msg(\"Can't read file {} ({})\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.corpus = None\n\n        # Browse file box\n        fbox = gui.widgetBox(self.controlArea, \"Corpus file\", orientation=0)\n        widget = widgets.FileWidget(recent_files=self.recent_files, icon_size=(16, 16), on_open=self.open_file,\n                                    directory_aliases={\"Browse documentation corpora ...\": get_sample_corpora_dir()},\n                                    dialog_format=self.dlgFormats, dialog_title='Open Orange Document Corpus',\n                                    allow_empty=False, reload_label='Reload', browse_label='Browse')\n        fbox.layout().addWidget(widget)\n\n        # Corpus info\n        ibox = gui.widgetBox(self.controlArea, \"Corpus info\", addSpace=True)\n        corp_info = \"Corpus of 0 documents.\"\n        self.info_label = gui.label(ibox, self, corp_info)\n\n        # Used Text Features\n        fbox = gui.widgetBox(self.controlArea, orientation=0)\n        ubox = gui.widgetBox(fbox, \"Used text features\", addSpace=True)\n        self.used_attrs_model = VariableListModel(enable_dnd=True)\n        self.used_attrs_view = VariablesListItemView()\n        self.used_attrs_view.setModel(self.used_attrs_model)\n        ubox.layout().addWidget(self.used_attrs_view)\n\n        aa = self.used_attrs_model\n        aa.dataChanged.connect(self.update_feature_selection)\n        aa.rowsInserted.connect(self.update_feature_selection)\n        aa.rowsRemoved.connect(self.update_feature_selection)\n\n        # Ignored Text Features\n        ibox = gui.widgetBox(fbox, \"Ignored text features\", addSpace=True)\n        self.unused_attrs_model = VariableListModel(enable_dnd=True)\n        self.unused_attrs_view = VariablesListItemView()\n        self.unused_attrs_view.setModel(self.unused_attrs_model)\n        ibox.layout().addWidget(self.unused_attrs_view)\n\n        # load first file\n        widget.select(0)\n\n    def open_file(self, path):\n        self.closeContext()\n        self.Error.read_file.clear()\n        self.used_attrs_model[:] = []\n        self.unused_attrs_model[:] = []\n        if path:\n            try:\n                self.corpus = Corpus.from_file(path)\n                self.corpus.name = os.path.splitext(os.path.basename(path))[0]\n                self.info_label.setText(\"Corpus of {} documents.\".format(len(self.corpus)))\n                self.used_attrs = list(self.corpus.text_features)\n                self.openContext(self.corpus)\n                self.used_attrs_model.extend(self.used_attrs)\n                self.unused_attrs_model.extend([f for f in self.corpus.domain.metas\n                                          if f.is_string and f not in self.used_attrs_model])\n            except BaseException as err:\n                self.Error.read_file(path, str(err))\n\n    def update_feature_selection(self):\n        # TODO fix VariablesListItemView so it does not emit\n        # duplicated data when reordering inside a single window\n        def remove_duplicates(l):\n            unique = []\n            for i in l:\n                if i not in unique:\n                    unique.append(i)\n            return unique\n\n        if self.corpus is not None:\n            self.corpus.set_text_features(remove_duplicates(self.used_attrs_model))\n            self.send(Output.CORPUS, self.corpus)\n            self.used_attrs = list(self.used_attrs_model)\n\n\nif __name__ == '__main__':\n    from AnyQt.QtWidgets import QApplication\n    app = QApplication([])\n    widget = OWLoadCorpus()\n    widget.show()\n    app.exec()\n    widget.saveSettings()\n", "path": "orangecontrib/text/widgets/owloadcorpus.py"}]}