Package: gensim / 4.3.3+dfsg-2

0004-Make-lee_corpus_list-initialised-on-first-access.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 82fabbe5e63ff1affd7fa4bb06c8a4dbe5edf577 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Sat, 26 Feb 2022 17:59:05 +0800
Subject: [PATCH 4/4] Make lee_corpus_list initialised on first access.

Uses PEP 562 module __getattr__ and requires Python 3.7 or later.

See-also: https://www.python.org/dev/peps/pep-0562/
---
 gensim/test/utils.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gensim/test/utils.py b/gensim/test/utils.py
index 9453b448..c610c06e 100644
--- a/gensim/test/utils.py
+++ b/gensim/test/utils.py
@@ -218,4 +218,9 @@ class LeeCorpus:
                 yield simple_preprocess(line)
 
 
-lee_corpus_list = list(LeeCorpus())
+def __getattr__(name):
+    if name == 'lee_corpus_list':
+        global lee_corpus_list
+        lee_corpus_list = list(LeeCorpus())
+        return lee_corpus_list
+    raise AttributeError(f"module {__name__} has no attribute {name}")
-- 
2.36.0