We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
text processing module with slow internet conection
[textprocessingerr.txt](https://github.com/biolab/orange3-text/files/4551540/textprocessingerr.txt)
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->
Hi! I have slow internet connection, less than 400Kbit/s. And when I use text preprocessing module I have an error.
If I disconnect my internet connection (disable wifi), the text processing module works fine.
If I have have internet connection more than 3Mbit/s, everything works fine.
##### Text version 0.9/0.8
##### Orange version 3.26/3.25




--- 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/preprocess/normalize.py`
Content:
```
1 import os
2 import json
3 import ufal.udpipe as udpipe
4 import serverfiles
5 from nltk import stem
6 from requests.exceptions import ConnectionError
7 from Orange.misc.environ import data_dir
8 
9 
10 from orangecontrib.text.misc import wait_nltk_data
11 
12 __all__ = ['BaseNormalizer', 'WordNetLemmatizer', 'PorterStemmer',
13            'SnowballStemmer', 'DictionaryLookupNormalizer',
14            'UDPipeLemmatizer']
15 
16 
17 class BaseNormalizer:
18     """ A generic normalizer class.
19     You should either overwrite `normalize` method or provide a custom
20     normalizer.
21 
22     Attributes:
23         name(str): A short name for normalization method (will be used in OWPreprocessor)
24         normalizer(Callable): An callabale object to be used for normalization.
25 
26     """
27     name = NotImplemented
28     normalizer = NotImplemented
29     str_format = '{self.name}'
30 
31     def __call__(self, tokens):
32         """ Normalizes tokens to canonical form. """
33         if isinstance(tokens, str):
34             return self.normalize(tokens)
35         return [self.normalize(token) for token in tokens]
36 
37     def normalize(self, token):
38         return self.normalizer(token)
39 
40     def __str__(self):
41         return self.str_format.format(self=self)
42 
43 
44 class WordNetLemmatizer(BaseNormalizer):
45     name = 'WordNet Lemmatizer'
46     normalizer = stem.WordNetLemmatizer().lemmatize
47 
48     @wait_nltk_data
49     def __init__(self):
50         super().__init__()
51 
52 
53 class DictionaryLookupNormalizer(BaseNormalizer):
54     """ Normalizes token with a <token: canonical_form> dictionary. """
55     name = 'Dictionary Lookup'
56 
57     def __init__(self, dictionary):
58         super().__init__()
59         self.dictionary = dictionary
60 
61     def normalize(self, token):
62         return self.dictionary.get(token, token)
63 
64 
65 class PorterStemmer(BaseNormalizer):
66     name = 'Porter Stemmer'
67     normalizer = stem.PorterStemmer().stem
68 
69 
70 class SnowballStemmer(BaseNormalizer):
71     name = 'Snowball Stemmer'
72     str_format = '{self.name} ({self.language})'
73     supported_languages = [l.capitalize() for l in stem.SnowballStemmer.languages]
74 
75     def __init__(self, language='English'):
76         self._language = language
77         self.normalizer = stem.SnowballStemmer(self.language.lower())
78 
79     def normalize(self, token):
80         return self.normalizer.stem(token)
81 
82     @property
83     def language(self):
84         return self._language
85 
86     @language.setter
87     def language(self, value):
88         self._language = value
89         self.normalizer = stem.SnowballStemmer(self.language.lower())
90 
91 
92 def language_to_name(language):
93     return language.lower().replace(' ', '') + 'ud'
94 
95 
96 def file_to_name(file):
97     return file.replace('-', '').replace('_', '')
98 
99 
100 def file_to_language(file):
101     return file[:file.find('ud')-1]\
102         .replace('-', ' ').replace('_', ' ').capitalize()
103 
104 
105 class UDPipeModels:
106     server_url = "http://file.biolab.si/files/udpipe/"
107 
108     def __init__(self):
109         self.local_data = os.path.join(data_dir(versioned=False), 'udpipe/')
110         self.serverfiles = serverfiles.ServerFiles(self.server_url)
111         self.localfiles = serverfiles.LocalFiles(self.local_data,
112                                                  serverfiles=self.serverfiles)
113         self._supported_languages = []
114 
115     def __getitem__(self, language):
116         file_name = self._find_file(language_to_name(language))
117         return self.localfiles.localpath_download(file_name)
118 
119     @property
120     def model_files(self):
121         try:
122             return self.serverfiles.listfiles()
123         except ConnectionError:
124             return self.localfiles.listfiles()
125 
126     def _find_file(self, language):
127         return next(filter(lambda f: file_to_name(f).startswith(language),
128                            map(lambda f: f[0], self.model_files)))
129 
130     @property
131     def supported_languages(self):
132         self._supported_languages = list(map(lambda f: file_to_language(f[0]),
133                                              self.model_files))
134         return self._supported_languages
135 
136     @property
137     def online(self):
138         try:
139             self.serverfiles.listfiles()
140             return True
141         except ConnectionError:
142             return False
143 
144 
145 class UDPipeLemmatizer(BaseNormalizer):
146     name = 'UDPipe Lemmatizer'
147     str_format = '{self.name} ({self.language})'
148 
149     def __init__(self, language='English'):
150         self._language = language
151         self.models = UDPipeModels()
152         self.model = None
153         self.output_format = udpipe.OutputFormat.newOutputFormat('epe')
154         self.use_tokenizer = False
155 
156     def load_model(self):
157         if self.model is None:
158             self.model = udpipe.Model.load(self.models[self._language])
159 
160     def normalize(self, token):
161         self.load_model()
162         sentence = udpipe.Sentence()
163         sentence.addWord(token)
164         self.model.tag(sentence, self.model.DEFAULT)
165         output = self.output_format.writeSentence(sentence)
166         return json.loads(output)['nodes'][0]['properties']['lemma']
167 
168     def normalize_doc(self, document):
169         self.load_model()
170         tokens = []
171         tokenizer = self.model.newTokenizer(self.model.DEFAULT)
172         tokenizer.setText(document)
173         error = udpipe.ProcessingError()
174         sentence = udpipe.Sentence()
175         while tokenizer.nextSentence(sentence, error):
176             self.model.tag(sentence, self.model.DEFAULT)
177             output = self.output_format.writeSentence(sentence)
178             sentence = udpipe.Sentence()
179             tokens.extend([t['properties']['lemma']
180                            for t in json.loads(output)['nodes']])
181         return tokens
182 
183     @property
184     def language(self):
185         return self._language
186 
187     @language.setter
188     def language(self, value):
189         self._language = value
190         self.model = None
191 
192     def __getstate__(self):
193         return {'language': self.language}
194 
195     def __setstate__(self, state):
196         self.__init__(state['language'])
197 
198
```
--- 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()

```

diff --git a/orangecontrib/text/preprocess/normalize.py b/orangecontrib/text/preprocess/normalize.py
--- a/orangecontrib/text/preprocess/normalize.py
+++ b/orangecontrib/text/preprocess/normalize.py
@@ -103,7 +103,7 @@
 
 
 class UDPipeModels:
-    server_url = "http://file.biolab.si/files/udpipe/"
+    server_url = "https://file.biolab.si/files/udpipe/"
 
     def __init__(self):
         self.local_data = os.path.join(data_dir(versioned=False), 'udpipe/')

{"golden_diff": "diff --git a/orangecontrib/text/preprocess/normalize.py b/orangecontrib/text/preprocess/normalize.py\n--- a/orangecontrib/text/preprocess/normalize.py\n+++ b/orangecontrib/text/preprocess/normalize.py\n@@ -103,7 +103,7 @@\n \n \n class UDPipeModels:\n-    server_url = \"http://file.biolab.si/files/udpipe/\"\n+    server_url = \"https://file.biolab.si/files/udpipe/\"\n \n     def __init__(self):\n         self.local_data = os.path.join(data_dir(versioned=False), 'udpipe/')\n", "issue": "text processing module with slow internet conection\n[textprocessingerr.txt](https://github.com/biolab/orange3-text/files/4551540/textprocessingerr.txt)\r\n<!--\r\nThis is an issue template. Please fill in the relevant details in the\r\nsections below.\r\n-->\r\nHi! I have slow internet connection, less than 400Kbit/s. And when I use text preprocessing module I have an error.\r\nIf I disconnect my internet connection (disable wifi), the text processing module works fine.\r\nIf I have have internet connection more than 3Mbit/s, everything works fine.\r\n##### Text version 0.9/0.8\r\n##### Orange version 3.26/3.25\r\n\r\n\r\n\n", "before_files": [{"content": "import os\nimport json\nimport ufal.udpipe as udpipe\nimport serverfiles\nfrom nltk import stem\nfrom requests.exceptions import ConnectionError\nfrom Orange.misc.environ import data_dir\n\n\nfrom orangecontrib.text.misc import wait_nltk_data\n\n__all__ = ['BaseNormalizer', 'WordNetLemmatizer', 'PorterStemmer',\n           'SnowballStemmer', 'DictionaryLookupNormalizer',\n           'UDPipeLemmatizer']\n\n\nclass BaseNormalizer:\n    \"\"\" A generic normalizer class.\n    You should either overwrite `normalize` method or provide a custom\n    normalizer.\n\n    Attributes:\n        name(str): A short name for normalization method (will be used in OWPreprocessor)\n        normalizer(Callable): An callabale object to be used for normalization.\n\n    \"\"\"\n    name = NotImplemented\n    normalizer = NotImplemented\n    str_format = '{self.name}'\n\n    def __call__(self, tokens):\n        \"\"\" Normalizes tokens to canonical form. \"\"\"\n        if isinstance(tokens, str):\n            return self.normalize(tokens)\n        return [self.normalize(token) for token in tokens]\n\n    def normalize(self, token):\n        return self.normalizer(token)\n\n    def __str__(self):\n        return self.str_format.format(self=self)\n\n\nclass WordNetLemmatizer(BaseNormalizer):\n    name = 'WordNet Lemmatizer'\n    normalizer = stem.WordNetLemmatizer().lemmatize\n\n    @wait_nltk_data\n    def __init__(self):\n        super().__init__()\n\n\nclass DictionaryLookupNormalizer(BaseNormalizer):\n    \"\"\" Normalizes token with a <token: canonical_form> dictionary. \"\"\"\n    name = 'Dictionary Lookup'\n\n    def __init__(self, dictionary):\n        super().__init__()\n        self.dictionary = dictionary\n\n    def normalize(self, token):\n        return self.dictionary.get(token, token)\n\n\nclass PorterStemmer(BaseNormalizer):\n    name = 'Porter Stemmer'\n    normalizer = stem.PorterStemmer().stem\n\n\nclass SnowballStemmer(BaseNormalizer):\n    name = 'Snowball Stemmer'\n    str_format = '{self.name} ({self.language})'\n    supported_languages = [l.capitalize() for l in stem.SnowballStemmer.languages]\n\n    def __init__(self, language='English'):\n        self._language = language\n        self.normalizer = stem.SnowballStemmer(self.language.lower())\n\n    def normalize(self, token):\n        return self.normalizer.stem(token)\n\n    @property\n    def language(self):\n        return self._language\n\n    @language.setter\n    def language(self, value):\n        self._language = value\n        self.normalizer = stem.SnowballStemmer(self.language.lower())\n\n\ndef language_to_name(language):\n    return language.lower().replace(' ', '') + 'ud'\n\n\ndef file_to_name(file):\n    return file.replace('-', '').replace('_', '')\n\n\ndef file_to_language(file):\n    return file[:file.find('ud')-1]\\\n        .replace('-', ' ').replace('_', ' ').capitalize()\n\n\nclass UDPipeModels:\n    server_url = \"http://file.biolab.si/files/udpipe/\"\n\n    def __init__(self):\n        self.local_data = os.path.join(data_dir(versioned=False), 'udpipe/')\n        self.serverfiles = serverfiles.ServerFiles(self.server_url)\n        self.localfiles = serverfiles.LocalFiles(self.local_data,\n                                                 serverfiles=self.serverfiles)\n        self._supported_languages = []\n\n    def __getitem__(self, language):\n        file_name = self._find_file(language_to_name(language))\n        return self.localfiles.localpath_download(file_name)\n\n    @property\n    def model_files(self):\n        try:\n            return self.serverfiles.listfiles()\n        except ConnectionError:\n            return self.localfiles.listfiles()\n\n    def _find_file(self, language):\n        return next(filter(lambda f: file_to_name(f).startswith(language),\n                           map(lambda f: f[0], self.model_files)))\n\n    @property\n    def supported_languages(self):\n        self._supported_languages = list(map(lambda f: file_to_language(f[0]),\n                                             self.model_files))\n        return self._supported_languages\n\n    @property\n    def online(self):\n        try:\n            self.serverfiles.listfiles()\n            return True\n        except ConnectionError:\n            return False\n\n\nclass UDPipeLemmatizer(BaseNormalizer):\n    name = 'UDPipe Lemmatizer'\n    str_format = '{self.name} ({self.language})'\n\n    def __init__(self, language='English'):\n        self._language = language\n        self.models = UDPipeModels()\n        self.model = None\n        self.output_format = udpipe.OutputFormat.newOutputFormat('epe')\n        self.use_tokenizer = False\n\n    def load_model(self):\n        if self.model is None:\n            self.model = udpipe.Model.load(self.models[self._language])\n\n    def normalize(self, token):\n        self.load_model()\n        sentence = udpipe.Sentence()\n        sentence.addWord(token)\n        self.model.tag(sentence, self.model.DEFAULT)\n        output = self.output_format.writeSentence(sentence)\n        return json.loads(output)['nodes'][0]['properties']['lemma']\n\n    def normalize_doc(self, document):\n        self.load_model()\n        tokens = []\n        tokenizer = self.model.newTokenizer(self.model.DEFAULT)\n        tokenizer.setText(document)\n        error = udpipe.ProcessingError()\n        sentence = udpipe.Sentence()\n        while tokenizer.nextSentence(sentence, error):\n            self.model.tag(sentence, self.model.DEFAULT)\n            output = self.output_format.writeSentence(sentence)\n            sentence = udpipe.Sentence()\n            tokens.extend([t['properties']['lemma']\n                           for t in json.loads(output)['nodes']])\n        return tokens\n\n    @property\n    def language(self):\n        return self._language\n\n    @language.setter\n    def language(self, value):\n        self._language = value\n        self.model = None\n\n    def __getstate__(self):\n        return {'language': self.language}\n\n    def __setstate__(self, state):\n        self.__init__(state['language'])\n\n", "path": "orangecontrib/text/preprocess/normalize.py"}], "after_files": [{"content": "import os\nimport json\nimport ufal.udpipe as udpipe\nimport serverfiles\nfrom nltk import stem\nfrom requests.exceptions import ConnectionError\nfrom Orange.misc.environ import data_dir\n\n\nfrom orangecontrib.text.misc import wait_nltk_data\n\n__all__ = ['BaseNormalizer', 'WordNetLemmatizer', 'PorterStemmer',\n           'SnowballStemmer', 'DictionaryLookupNormalizer',\n           'UDPipeLemmatizer']\n\n\nclass BaseNormalizer:\n    \"\"\" A generic normalizer class.\n    You should either overwrite `normalize` method or provide a custom\n    normalizer.\n\n    Attributes:\n        name(str): A short name for normalization method (will be used in OWPreprocessor)\n        normalizer(Callable): An callabale object to be used for normalization.\n\n    \"\"\"\n    name = NotImplemented\n    normalizer = NotImplemented\n    str_format = '{self.name}'\n\n    def __call__(self, tokens):\n        \"\"\" Normalizes tokens to canonical form. \"\"\"\n        if isinstance(tokens, str):\n            return self.normalize(tokens)\n        return [self.normalize(token) for token in tokens]\n\n    def normalize(self, token):\n        return self.normalizer(token)\n\n    def __str__(self):\n        return self.str_format.format(self=self)\n\n\nclass WordNetLemmatizer(BaseNormalizer):\n    name = 'WordNet Lemmatizer'\n    normalizer = stem.WordNetLemmatizer().lemmatize\n\n    @wait_nltk_data\n    def __init__(self):\n        super().__init__()\n\n\nclass DictionaryLookupNormalizer(BaseNormalizer):\n    \"\"\" Normalizes token with a <token: canonical_form> dictionary. \"\"\"\n    name = 'Dictionary Lookup'\n\n    def __init__(self, dictionary):\n        super().__init__()\n        self.dictionary = dictionary\n\n    def normalize(self, token):\n        return self.dictionary.get(token, token)\n\n\nclass PorterStemmer(BaseNormalizer):\n    name = 'Porter Stemmer'\n    normalizer = stem.PorterStemmer().stem\n\n\nclass SnowballStemmer(BaseNormalizer):\n    name = 'Snowball Stemmer'\n    str_format = '{self.name} ({self.language})'\n    supported_languages = [l.capitalize() for l in stem.SnowballStemmer.languages]\n\n    def __init__(self, language='English'):\n        self._language = language\n        self.normalizer = stem.SnowballStemmer(self.language.lower())\n\n    def normalize(self, token):\n        return self.normalizer.stem(token)\n\n    @property\n    def language(self):\n        return self._language\n\n    @language.setter\n    def language(self, value):\n        self._language = value\n        self.normalizer = stem.SnowballStemmer(self.language.lower())\n\n\ndef language_to_name(language):\n    return language.lower().replace(' ', '') + 'ud'\n\n\ndef file_to_name(file):\n    return file.replace('-', '').replace('_', '')\n\n\ndef file_to_language(file):\n    return file[:file.find('ud')-1]\\\n        .replace('-', ' ').replace('_', ' ').capitalize()\n\n\nclass UDPipeModels:\n    server_url = \"https://file.biolab.si/files/udpipe/\"\n\n    def __init__(self):\n        self.local_data = os.path.join(data_dir(versioned=False), 'udpipe/')\n        self.serverfiles = serverfiles.ServerFiles(self.server_url)\n        self.localfiles = serverfiles.LocalFiles(self.local_data,\n                                                 serverfiles=self.serverfiles)\n        self._supported_languages = []\n\n    def __getitem__(self, language):\n        file_name = self._find_file(language_to_name(language))\n        return self.localfiles.localpath_download(file_name)\n\n    @property\n    def model_files(self):\n        try:\n            return self.serverfiles.listfiles()\n        except ConnectionError:\n            return self.localfiles.listfiles()\n\n    def _find_file(self, language):\n        return next(filter(lambda f: file_to_name(f).startswith(language),\n                           map(lambda f: f[0], self.model_files)))\n\n    @property\n    def supported_languages(self):\n        self._supported_languages = list(map(lambda f: file_to_language(f[0]),\n                                             self.model_files))\n        return self._supported_languages\n\n    @property\n    def online(self):\n        try:\n            self.serverfiles.listfiles()\n            return True\n        except ConnectionError:\n            return False\n\n\nclass UDPipeLemmatizer(BaseNormalizer):\n    name = 'UDPipe Lemmatizer'\n    str_format = '{self.name} ({self.language})'\n\n    def __init__(self, language='English'):\n        self._language = language\n        self.models = UDPipeModels()\n        self.model = None\n        self.output_format = udpipe.OutputFormat.newOutputFormat('epe')\n        self.use_tokenizer = False\n\n    def load_model(self):\n        if self.model is None:\n            self.model = udpipe.Model.load(self.models[self._language])\n\n    def normalize(self, token):\n        self.load_model()\n        sentence = udpipe.Sentence()\n        sentence.addWord(token)\n        self.model.tag(sentence, self.model.DEFAULT)\n        output = self.output_format.writeSentence(sentence)\n        return json.loads(output)['nodes'][0]['properties']['lemma']\n\n    def normalize_doc(self, document):\n        self.load_model()\n        tokens = []\n        tokenizer = self.model.newTokenizer(self.model.DEFAULT)\n        tokenizer.setText(document)\n        error = udpipe.ProcessingError()\n        sentence = udpipe.Sentence()\n        while tokenizer.nextSentence(sentence, error):\n            self.model.tag(sentence, self.model.DEFAULT)\n            output = self.output_format.writeSentence(sentence)\n            sentence = udpipe.Sentence()\n            tokens.extend([t['properties']['lemma']\n                           for t in json.loads(output)['nodes']])\n        return tokens\n\n    @property\n    def language(self):\n        return self._language\n\n    @language.setter\n    def language(self, value):\n        self._language = value\n        self.model = None\n\n    def __getstate__(self):\n        return {'language': self.language}\n\n    def __setstate__(self, state):\n        self.__init__(state['language'])\n\n", "path": "orangecontrib/text/preprocess/normalize.py"}]}