From 5505fae9390512e5c461810f5cadec225ce36c08 Mon Sep 17 00:00:00 2001 From: Gunther Cox Date: Tue, 27 Jun 2017 06:00:05 -0400 Subject: [PATCH 1/2] Add utility method for listing nltk data --- chatterbot/__main__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chatterbot/__main__.py b/chatterbot/__main__.py index 873be1c55..5b6c416d0 100644 --- a/chatterbot/__main__.py +++ b/chatterbot/__main__.py @@ -6,3 +6,8 @@ if '--version' in sys.argv: print(chatterbot.__version__) + + if 'list_nltk_data' in sys.argv: + import nltk.data + + print('\n'.join(nltk.data.path)) From cc7b82572a90b22200589f8f173927bdbaa06422 Mon Sep 17 00:00:00 2001 From: Gunther Cox Date: Tue, 27 Jun 2017 06:07:15 -0400 Subject: [PATCH 2/2] Add commad line utility to find NLTK data --- chatterbot/__main__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chatterbot/__main__.py b/chatterbot/__main__.py index 5b6c416d0..54e866d32 100644 --- a/chatterbot/__main__.py +++ b/chatterbot/__main__.py @@ -8,6 +8,15 @@ print(chatterbot.__version__) if 'list_nltk_data' in sys.argv: + import os import nltk.data - print('\n'.join(nltk.data.path)) + data_directories = [] + + # Find each data directory in the NLTK path that has content + for path in nltk.data.path: + if os.path.exists(path): + if os.listdir(path): + data_directories.append(path) + + print(os.linesep.join(data_directories))