Skip to content

Commit 4b90c20

Browse files
committed
Download nltk data if it hasn't been downloaded already
1 parent aaa92e2 commit 4b90c20

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/text_mining.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55

66
df = pd.read_json('datasets/text/artm_test_dataset.json', orient='records')
77
documents = df['text'].tolist()
8-
corpus = Corpus.from_list(documents)
8+
9+
try:
10+
corpus = Corpus.from_list(documents)
11+
except LookupError:
12+
import nltk
13+
nltk.download('punkt')
14+
nltk.download('stopwords')
15+
corpus = Corpus.from_list(documents)
916

1017
algorithm = ParticleSwarmOptimization(population_size=200, seed=123)
1118
metrics = ('support', 'confidence', 'aws')

0 commit comments

Comments
 (0)