ChatterBot 1.2.3__tar.gz → 1.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. {chatterbot-1.2.3 → chatterbot-1.2.4}/ChatterBot.egg-info/PKG-INFO +8 -18
  2. {chatterbot-1.2.3 → chatterbot-1.2.4}/ChatterBot.egg-info/requires.txt +1 -0
  3. {chatterbot-1.2.3 → chatterbot-1.2.4}/PKG-INFO +8 -18
  4. {chatterbot-1.2.3 → chatterbot-1.2.4}/README.md +1 -1
  5. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/__init__.py +1 -1
  6. chatterbot-1.2.4/chatterbot/__main__.py +27 -0
  7. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/chatterbot.py +52 -6
  8. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/comparisons.py +3 -13
  9. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/sqlalchemy_app/models.py +2 -2
  10. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/logic/specific_response.py +3 -7
  11. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/logic/time_adapter.py +3 -7
  12. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/search.py +0 -55
  13. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/storage/sql_storage.py +1 -1
  14. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/tagging.py +3 -7
  15. chatterbot-1.2.4/chatterbot/trainers.py +569 -0
  16. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/utils.py +16 -25
  17. {chatterbot-1.2.3 → chatterbot-1.2.4}/pyproject.toml +4 -4
  18. {chatterbot-1.2.3 → chatterbot-1.2.4}/setup.cfg +0 -6
  19. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_chatbot.py +43 -0
  20. chatterbot-1.2.3/chatterbot/__main__.py +0 -12
  21. chatterbot-1.2.3/chatterbot/trainers.py +0 -381
  22. {chatterbot-1.2.3 → chatterbot-1.2.4}/ChatterBot.egg-info/SOURCES.txt +0 -0
  23. {chatterbot-1.2.3 → chatterbot-1.2.4}/ChatterBot.egg-info/dependency_links.txt +0 -0
  24. {chatterbot-1.2.3 → chatterbot-1.2.4}/ChatterBot.egg-info/top_level.txt +0 -0
  25. {chatterbot-1.2.3 → chatterbot-1.2.4}/LICENSE +0 -0
  26. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/adapters.py +0 -0
  27. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/components.py +0 -0
  28. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/constants.py +0 -0
  29. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/conversation.py +0 -0
  30. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/corpus.py +0 -0
  31. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/exceptions.py +0 -0
  32. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/__init__.py +0 -0
  33. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/__init__.py +0 -0
  34. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/abstract_models.py +0 -0
  35. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/admin.py +0 -0
  36. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/apps.py +0 -0
  37. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0001_initial.py +0 -0
  38. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0002_statement_extra_data.py +0 -0
  39. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0003_change_occurrence_default.py +0 -0
  40. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0004_rename_in_response_to.py +0 -0
  41. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0005_statement_created_at.py +0 -0
  42. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0006_create_conversation.py +0 -0
  43. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0007_response_created_at.py +0 -0
  44. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0008_update_conversations.py +0 -0
  45. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0009_tags.py +0 -0
  46. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0010_statement_text.py +0 -0
  47. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0011_blank_extra_data.py +0 -0
  48. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0012_statement_created_at.py +0 -0
  49. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0013_change_conversations.py +0 -0
  50. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0014_remove_statement_extra_data.py +0 -0
  51. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0015_statement_persona.py +0 -0
  52. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0016_statement_stemmed_text.py +0 -0
  53. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0017_tags_unique.py +0 -0
  54. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0018_text_max_length.py +0 -0
  55. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/0019_alter_statement_id_alter_tag_id_and_more.py +0 -0
  56. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/migrations/__init__.py +0 -0
  57. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/model_admin.py +0 -0
  58. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/models.py +0 -0
  59. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/django_chatterbot/settings.py +0 -0
  60. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/ext/sqlalchemy_app/__init__.py +0 -0
  61. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/filters.py +0 -0
  62. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/languages.py +0 -0
  63. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/logic/__init__.py +0 -0
  64. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/logic/best_match.py +0 -0
  65. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/logic/logic_adapter.py +0 -0
  66. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/logic/mathematical_evaluation.py +0 -0
  67. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/logic/unit_conversion.py +0 -0
  68. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/parsing.py +0 -0
  69. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/preprocessors.py +0 -0
  70. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/response_selection.py +0 -0
  71. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/storage/__init__.py +0 -0
  72. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/storage/django_storage.py +0 -0
  73. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/storage/mongodb.py +0 -0
  74. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/storage/redis.py +0 -0
  75. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/storage/storage_adapter.py +0 -0
  76. {chatterbot-1.2.3 → chatterbot-1.2.4}/chatterbot/vectorstores.py +0 -0
  77. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_adapter_validation.py +0 -0
  78. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_benchmarks.py +0 -0
  79. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_cli.py +0 -0
  80. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_comparisons.py +0 -0
  81. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_conversations.py +0 -0
  82. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_corpus.py +0 -0
  83. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_examples.py +0 -0
  84. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_filters.py +0 -0
  85. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_initialization.py +0 -0
  86. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_languages.py +0 -0
  87. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_parsing.py +0 -0
  88. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_preprocessors.py +0 -0
  89. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_response_selection.py +0 -0
  90. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_search.py +0 -0
  91. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_tagging.py +0 -0
  92. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_turing.py +0 -0
  93. {chatterbot-1.2.3 → chatterbot-1.2.4}/tests/test_utils.py +0 -0
@@ -1,27 +1,15 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: ChatterBot
3
- Version: 1.2.3
3
+ Version: 1.2.4
4
4
  Summary: ChatterBot is a machine learning, conversational dialog engine
5
5
  Author: Gunther Cox
6
- License: Copyright (c) 2016 - 2025, Gunther Cox
7
- All rights reserved.
8
-
9
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10
-
11
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12
-
13
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
14
-
15
- * Neither the name of ChatterBot nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
16
-
17
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
-
6
+ License-Expression: BSD-3-Clause
19
7
  Project-URL: Documentation, https://docs.chatterbot.us
20
8
  Project-URL: Repository, https://github.com/gunthercox/ChatterBot
9
+ Project-URL: Changelog, https://github.com/gunthercox/ChatterBot/releases
21
10
  Keywords: ChatterBot,chatbot,chat,bot,natural language processing,nlp,artificial intelligence,ai
22
11
  Classifier: Development Status :: 4 - Beta
23
12
  Classifier: Intended Audience :: Developers
24
- Classifier: License :: OSI Approved :: BSD License
25
13
  Classifier: Operating System :: OS Independent
26
14
  Classifier: Environment :: Console
27
15
  Classifier: Environment :: Web Environment
@@ -40,7 +28,7 @@ Classifier: Programming Language :: Python
40
28
  Classifier: Programming Language :: Python :: 3
41
29
  Classifier: Programming Language :: Python :: 3.9
42
30
  Classifier: Programming Language :: Python :: 3 :: Only
43
- Requires-Python: ~=3.9
31
+ Requires-Python: <3.13,>=3.9
44
32
  Description-Content-Type: text/markdown
45
33
  License-File: LICENSE
46
34
  Requires-Dist: mathparse<0.2,>=0.1
@@ -54,6 +42,7 @@ Requires-Dist: coverage; extra == "test"
54
42
  Requires-Dist: nose; extra == "test"
55
43
  Requires-Dist: sphinx<8.2,>=5.3; extra == "test"
56
44
  Requires-Dist: sphinx-sitemap>=2.6.0; extra == "test"
45
+ Requires-Dist: huggingface_hub; extra == "test"
57
46
  Provides-Extra: dev
58
47
  Requires-Dist: pint>=0.8.1; extra == "dev"
59
48
  Requires-Dist: pyyaml<7.0,>=6.0; extra == "dev"
@@ -65,6 +54,7 @@ Requires-Dist: langchain-huggingface; extra == "redis"
65
54
  Requires-Dist: sentence-transformers; extra == "redis"
66
55
  Provides-Extra: mongodb
67
56
  Requires-Dist: pymongo<4.12,>=4.11; extra == "mongodb"
57
+ Dynamic: license-file
68
58
 
69
59
  ![ChatterBot: Machine learning in Python](https://i.imgur.com/b3SCmGT.png)
70
60
 
@@ -167,7 +157,7 @@ See release notes for changes https://github.com/gunthercox/ChatterBot/releases
167
157
  a new branch `my-pull-request`.
168
158
  3. [Create a pull request](https://help.github.com/articles/creating-a-pull-request/).
169
159
  4. Please follow the [Python style guide for PEP-8](https://www.python.org/dev/peps/pep-0008/).
170
- 5. Use the projects [built-in automated testing](https://docs.chatterbot.us/testing.html).
160
+ 5. Use the projects [built-in automated testing](https://docs.chatterbot.us/testing/).
171
161
  to help make sure that your contribution is free from errors.
172
162
 
173
163
  # License
@@ -24,3 +24,4 @@ coverage
24
24
  nose
25
25
  sphinx<8.2,>=5.3
26
26
  sphinx-sitemap>=2.6.0
27
+ huggingface_hub
@@ -1,27 +1,15 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: ChatterBot
3
- Version: 1.2.3
3
+ Version: 1.2.4
4
4
  Summary: ChatterBot is a machine learning, conversational dialog engine
5
5
  Author: Gunther Cox
6
- License: Copyright (c) 2016 - 2025, Gunther Cox
7
- All rights reserved.
8
-
9
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10
-
11
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12
-
13
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
14
-
15
- * Neither the name of ChatterBot nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
16
-
17
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
-
6
+ License-Expression: BSD-3-Clause
19
7
  Project-URL: Documentation, https://docs.chatterbot.us
20
8
  Project-URL: Repository, https://github.com/gunthercox/ChatterBot
9
+ Project-URL: Changelog, https://github.com/gunthercox/ChatterBot/releases
21
10
  Keywords: ChatterBot,chatbot,chat,bot,natural language processing,nlp,artificial intelligence,ai
22
11
  Classifier: Development Status :: 4 - Beta
23
12
  Classifier: Intended Audience :: Developers
24
- Classifier: License :: OSI Approved :: BSD License
25
13
  Classifier: Operating System :: OS Independent
26
14
  Classifier: Environment :: Console
27
15
  Classifier: Environment :: Web Environment
@@ -40,7 +28,7 @@ Classifier: Programming Language :: Python
40
28
  Classifier: Programming Language :: Python :: 3
41
29
  Classifier: Programming Language :: Python :: 3.9
42
30
  Classifier: Programming Language :: Python :: 3 :: Only
43
- Requires-Python: ~=3.9
31
+ Requires-Python: <3.13,>=3.9
44
32
  Description-Content-Type: text/markdown
45
33
  License-File: LICENSE
46
34
  Requires-Dist: mathparse<0.2,>=0.1
@@ -54,6 +42,7 @@ Requires-Dist: coverage; extra == "test"
54
42
  Requires-Dist: nose; extra == "test"
55
43
  Requires-Dist: sphinx<8.2,>=5.3; extra == "test"
56
44
  Requires-Dist: sphinx-sitemap>=2.6.0; extra == "test"
45
+ Requires-Dist: huggingface_hub; extra == "test"
57
46
  Provides-Extra: dev
58
47
  Requires-Dist: pint>=0.8.1; extra == "dev"
59
48
  Requires-Dist: pyyaml<7.0,>=6.0; extra == "dev"
@@ -65,6 +54,7 @@ Requires-Dist: langchain-huggingface; extra == "redis"
65
54
  Requires-Dist: sentence-transformers; extra == "redis"
66
55
  Provides-Extra: mongodb
67
56
  Requires-Dist: pymongo<4.12,>=4.11; extra == "mongodb"
57
+ Dynamic: license-file
68
58
 
69
59
  ![ChatterBot: Machine learning in Python](https://i.imgur.com/b3SCmGT.png)
70
60
 
@@ -167,7 +157,7 @@ See release notes for changes https://github.com/gunthercox/ChatterBot/releases
167
157
  a new branch `my-pull-request`.
168
158
  3. [Create a pull request](https://help.github.com/articles/creating-a-pull-request/).
169
159
  4. Please follow the [Python style guide for PEP-8](https://www.python.org/dev/peps/pep-0008/).
170
- 5. Use the projects [built-in automated testing](https://docs.chatterbot.us/testing.html).
160
+ 5. Use the projects [built-in automated testing](https://docs.chatterbot.us/testing/).
171
161
  to help make sure that your contribution is free from errors.
172
162
 
173
163
  # License
@@ -99,7 +99,7 @@ See release notes for changes https://github.com/gunthercox/ChatterBot/releases
99
99
  a new branch `my-pull-request`.
100
100
  3. [Create a pull request](https://help.github.com/articles/creating-a-pull-request/).
101
101
  4. Please follow the [Python style guide for PEP-8](https://www.python.org/dev/peps/pep-0008/).
102
- 5. Use the projects [built-in automated testing](https://docs.chatterbot.us/testing.html).
102
+ 5. Use the projects [built-in automated testing](https://docs.chatterbot.us/testing/).
103
103
  to help make sure that your contribution is free from errors.
104
104
 
105
105
  # License
@@ -4,7 +4,7 @@ ChatterBot is a machine learning, conversational dialog engine.
4
4
  from .chatterbot import ChatBot
5
5
 
6
6
 
7
- __version__ = '1.2.3'
7
+ __version__ = '1.2.4'
8
8
 
9
9
  __all__ = (
10
10
  'ChatBot',
@@ -0,0 +1,27 @@
1
+ """
2
+ Example usage for ChatterBot command line arguments:
3
+
4
+ python -m chatterbot --help
5
+ """
6
+
7
+ import sys
8
+
9
+
10
+ def get_chatterbot_version():
11
+ """
12
+ Return the version of the current package.
13
+ """
14
+ from chatterbot import __version__
15
+
16
+ return __version__
17
+
18
+
19
+ if __name__ == '__main__':
20
+ if '--version' in sys.argv:
21
+ print(get_chatterbot_version())
22
+ elif '--help' in sys.argv:
23
+ print('usage: chatterbot [--version, --help]')
24
+ print(' --version: Print the version of ChatterBot')
25
+ print(' --help: Print this help message')
26
+ print()
27
+ print('Documentation at https://docs.chatterbot.us')
@@ -11,11 +11,41 @@ import spacy
11
11
  class ChatBot(object):
12
12
  """
13
13
  A conversational dialog chat bot.
14
+
15
+ :param name: A name is the only required parameter for the ChatBot class.
16
+ :type name: str
17
+
18
+ :keyword storage_adapter: The dot-notated import path to a storage adapter class.
19
+ Defaults to ``"chatterbot.storage.SQLStorageAdapter"``.
20
+ :type storage_adapter: str
21
+
22
+ :param logic_adapters: A list of dot-notated import paths to each logic adapter the bot uses.
23
+ Defaults to ``["chatterbot.logic.BestMatch"]``.
24
+ :type logic_adapters: list
25
+
26
+ :param tagger: The tagger to use for the chat bot.
27
+ Defaults to :class:`~chatterbot.tagging.PosLemmaTagger`
28
+ :type tagger: object
29
+
30
+ :param tagger_language: The language to use for the tagger.
31
+ Defaults to :class:`~chatterbot.languages.ENG`.
32
+ :type tagger_language: object
33
+
34
+ :param preprocessors: A list of preprocessor functions to use for the chat bot.
35
+ :type preprocessors: list
36
+
37
+ :param read_only: If True, the chat bot will not save any input it receives, defaults to False.
38
+ :type read_only: bool
39
+
40
+ :param logger: A ``Logger`` object.
41
+ :type logger: logging.Logger
14
42
  """
15
43
 
16
44
  def __init__(self, name, **kwargs):
17
45
  self.name = name
18
46
 
47
+ self.logger = kwargs.get('logger', logging.getLogger(__name__))
48
+
19
49
  storage_adapter = kwargs.get('storage_adapter', 'chatterbot.storage.SQLStorageAdapter')
20
50
 
21
51
  logic_adapters = kwargs.get('logic_adapters', [
@@ -30,11 +60,29 @@ class ChatBot(object):
30
60
 
31
61
  self.storage = utils.initialize_class(storage_adapter, **kwargs)
32
62
 
33
- Tagger = kwargs.get('tagger', PosLemmaTagger)
63
+ tagger_language = kwargs.get('tagger_language', languages.ENG)
34
64
 
35
- self.tagger = Tagger(language=kwargs.get(
36
- 'tagger_language', languages.ENG
37
- ))
65
+ try:
66
+ Tagger = kwargs.get('tagger', PosLemmaTagger)
67
+
68
+ self.tagger = Tagger(language=tagger_language)
69
+ except IOError as io_error:
70
+ # Return a more helpful error message if possible
71
+ if "Can't find model" in str(io_error):
72
+ model_name = utils.get_model_for_language(tagger_language)
73
+ if hasattr(tagger_language, 'ENGLISH_NAME'):
74
+ language_name = tagger_language.ENGLISH_NAME
75
+ else:
76
+ language_name = tagger_language
77
+ raise self.ChatBotException(
78
+ 'Setup error:\n'
79
+ f'The Spacy model for "{language_name}" language is missing.\n'
80
+ 'Please install the model using the command:\n\n'
81
+ f'python -m spacy download {model_name}\n\n'
82
+ 'See https://spacy.io/usage/models for more information about available models.'
83
+ ) from io_error
84
+ else:
85
+ raise io_error
38
86
 
39
87
  primary_search_algorithm = IndexedTextSearch(self, **kwargs)
40
88
  text_search_algorithm = TextSearch(self, **kwargs)
@@ -63,8 +111,6 @@ class ChatBot(object):
63
111
  # NOTE: 'xx' is the language code for a multi-language model
64
112
  self.nlp = spacy.blank(self.tagger.language.ISO_639_1)
65
113
 
66
- self.logger = kwargs.get('logger', logging.getLogger(__name__))
67
-
68
114
  # Allow the bot to save input it receives so that it can learn
69
115
  self.read_only = kwargs.get('read_only', False)
70
116
 
@@ -2,7 +2,7 @@
2
2
  This module contains various text-comparison algorithms
3
3
  designed to compare one statement to another.
4
4
  """
5
- from chatterbot import constants
5
+ from chatterbot.utils import get_model_for_language
6
6
  from difflib import SequenceMatcher
7
7
  import spacy
8
8
 
@@ -100,12 +100,7 @@ class SpacySimilarity(Comparator):
100
100
  def __init__(self, language):
101
101
  super().__init__(language)
102
102
 
103
- try:
104
- model = constants.DEFAULT_LANGUAGE_TO_SPACY_MODEL_MAP[self.language]
105
- except KeyError as e:
106
- raise KeyError(
107
- f'Spacy model is not available for language {self.language}'
108
- ) from e
103
+ model = get_model_for_language(language)
109
104
 
110
105
  # Disable the Named Entity Recognition (NER) component because it is not necessary
111
106
  self.nlp = spacy.load(model, exclude=['ner'])
@@ -157,12 +152,7 @@ class JaccardSimilarity(Comparator):
157
152
  def __init__(self, language):
158
153
  super().__init__(language)
159
154
 
160
- try:
161
- model = constants.DEFAULT_LANGUAGE_TO_SPACY_MODEL_MAP[self.language]
162
- except KeyError as e:
163
- raise KeyError(
164
- f'Spacy model is not available for language {self.language}'
165
- ) from e
155
+ model = get_model_for_language(language)
166
156
 
167
157
  # Disable the Named Entity Recognition (NER) component because it is not necessary
168
158
  self.nlp = spacy.load(model, exclude=['ner'])
@@ -1,7 +1,7 @@
1
1
  from sqlalchemy import Table, Column, Integer, String, DateTime, ForeignKey
2
- from sqlalchemy.orm import relationship
2
+ from sqlalchemy.orm import relationship, declarative_base
3
3
  from sqlalchemy.sql import func
4
- from sqlalchemy.ext.declarative import declared_attr, declarative_base
4
+ from sqlalchemy.ext.declarative import declared_attr
5
5
 
6
6
  from chatterbot.conversation import StatementMixin
7
7
  from chatterbot import constants
@@ -1,6 +1,7 @@
1
1
  from chatterbot.logic import LogicAdapter
2
2
  from chatterbot.conversation import Statement
3
- from chatterbot import constants, languages
3
+ from chatterbot import languages
4
+ from chatterbot.utils import get_model_for_language
4
5
  import spacy
5
6
 
6
7
 
@@ -35,12 +36,7 @@ class SpecificResponseAdapter(LogicAdapter):
35
36
  self._output_text = kwargs.get('output_text')
36
37
 
37
38
  def _initialize_nlp(self, language):
38
- try:
39
- model = constants.DEFAULT_LANGUAGE_TO_SPACY_MODEL_MAP[language]
40
- except KeyError as e:
41
- raise KeyError(
42
- f'Spacy model is not available for language {language}'
43
- ) from e
39
+ model = get_model_for_language(language)
44
40
 
45
41
  return spacy.load(model)
46
42
 
@@ -1,7 +1,8 @@
1
1
  from datetime import datetime
2
- from chatterbot import constants, languages
2
+ from chatterbot import languages
3
3
  from chatterbot.logic import LogicAdapter
4
4
  from chatterbot.conversation import Statement
5
+ from chatterbot.utils import get_model_for_language
5
6
  import spacy
6
7
 
7
8
 
@@ -36,12 +37,7 @@ class TimeLogicAdapter(LogicAdapter):
36
37
 
37
38
  language = kwargs.get('language', languages.ENG)
38
39
 
39
- try:
40
- model = constants.DEFAULT_LANGUAGE_TO_SPACY_MODEL_MAP[language]
41
- except KeyError as e:
42
- raise KeyError(
43
- f'Spacy model is not available for language {language}'
44
- ) from e
40
+ model = get_model_for_language(language)
45
41
 
46
42
  self.nlp = spacy.load(model)
47
43
 
@@ -149,58 +149,3 @@ class TextSearch:
149
149
  ))
150
150
 
151
151
  yield statement
152
-
153
-
154
- class VectorSearch:
155
- """
156
- .. note:: BETA feature: this search method is new and experimental.
157
-
158
- Search for similar text based on a :term:`vector database`.
159
- """
160
-
161
- name = 'vector_search'
162
-
163
- def __init__(self, chatbot, **kwargs):
164
- from chatterbot.storage import RedisVectorStorageAdapter
165
-
166
- # Good documentation:
167
- # https://python.langchain.com/docs/integrations/vectorstores/redis/
168
- #
169
- # https://hub.docker.com/r/redis/redis-stack
170
-
171
- # Mondodb:
172
- # > Vector Search is only supported on Atlas Clusters
173
- # https://www.mongodb.com/community/forums/t/can-a-local-mongodb-instance-be-used-when-working-with-langchain-mongodbatlasvectorsearch/265356
174
-
175
- # FAISS:
176
- # https://python.langchain.com/docs/integrations/vectorstores/faiss/
177
-
178
- print("Starting Redis Vector Store")
179
-
180
- # TODO: look into:
181
- # https://python.langchain.com/api_reference/redis/chat_message_history/langchain_redis.chat_message_history.RedisChatMessageHistory.html
182
-
183
- # The VectorSearch class is only compatible with the RedisVectorStorageAdapter
184
- if not isinstance(chatbot.storage, RedisVectorStorageAdapter):
185
- raise Exception(
186
- 'The VectorSearch search method requires the RedisVectorStorageAdapter storage adapter.'
187
- )
188
-
189
- def search(self, input_statement, **additional_parameters):
190
- print("Querying Vector Store")
191
-
192
- # Similarity search with score and filter
193
- # NOTE: It looks like `return_all` is needed to return the full document
194
- # specifically what we need here is the ID
195
- scored_results = self.storage.vector_store.similarity_search_with_score(
196
- input_statement.text, k=2, return_all=True
197
- )
198
- # sort_by="score", filter={"category": "likes"})
199
-
200
- print("Similarity Search with Score Results:\n")
201
- for doc, score in scored_results:
202
- print(f"Content: {doc.page_content[:150]}...")
203
- print(f"ID: {doc.id}")
204
- print(f"Metadata: {doc.metadata}")
205
- print(f"Score: {score}")
206
- print()
@@ -326,7 +326,7 @@ class SQLStorageAdapter(StorageAdapter):
326
326
  record = None
327
327
 
328
328
  if hasattr(statement, 'id') and statement.id is not None:
329
- record = session.query(Statement).get(statement.id)
329
+ record = session.get(Statement, statement.id)
330
330
  else:
331
331
  record = session.query(Statement).filter(
332
332
  Statement.text == statement.text,
@@ -1,4 +1,5 @@
1
- from chatterbot import languages, constants
1
+ from chatterbot import languages
2
+ from chatterbot.utils import get_model_for_language
2
3
  import spacy
3
4
 
4
5
 
@@ -42,12 +43,7 @@ class PosLemmaTagger(object):
42
43
 
43
44
  self.language = language or languages.ENG
44
45
 
45
- try:
46
- model = constants.DEFAULT_LANGUAGE_TO_SPACY_MODEL_MAP[self.language]
47
- except KeyError as e:
48
- raise KeyError(
49
- f'Spacy model is not available for language {self.language}'
50
- ) from e
46
+ model = get_model_for_language(self.language)
51
47
 
52
48
  # Disable the Named Entity Recognition (NER) component because it is not necessary
53
49
  self.nlp = spacy.load(model, exclude=['ner'])