cjm-text-plugin-nltk 0.0.1__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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2022, fastai
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include settings.ini
2
+ include LICENSE
3
+ include CONTRIBUTING.md
4
+ include README.md
5
+ recursive-exclude * __pycache__
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: cjm-text-plugin-nltk
3
+ Version: 0.0.1
4
+ Summary: A local, NLTK-based text processing worker for the cjm-plugin-system that provides sentence splitting and tokenization with character-level span tracking.
5
+ Home-page: https://github.com/cj-mills/cjm-text-plugin-nltk
6
+ Author: Christian J. Mills
7
+ Author-email: 9126128+cj-mills@users.noreply.github.com
8
+ License: Apache-2.0
9
+ Keywords: nbdev jupyter notebook python
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: cjm_text_plugin_system
20
+ Requires-Dist: nltk
21
+ Provides-Extra: dev
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: keywords
29
+ Dynamic: license
30
+ Dynamic: license-file
31
+ Dynamic: provides-extra
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # cjm-text-plugin-nltk
37
+
38
+
39
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
40
+
41
+ ## Install
42
+
43
+ ``` bash
44
+ pip install cjm_text_plugin_nltk
45
+ ```
46
+
47
+ ## Project Structure
48
+
49
+ nbs/
50
+ ├── meta.ipynb # Metadata introspection for the NLTK text plugin used by cjm-ctl to generate the registration manifest.
51
+ └── plugin.ipynb # Plugin implementation for NLTK-based text processing with character-level span tracking
52
+
53
+ Total: 2 notebooks
54
+
55
+ ## Module Dependencies
56
+
57
+ ``` mermaid
58
+ graph LR
59
+ meta[meta<br/>Metadata]
60
+ plugin[plugin<br/>NLTK Plugin]
61
+ ```
62
+
63
+ No cross-module dependencies detected.
64
+
65
+ ## CLI Reference
66
+
67
+ No CLI commands found in this project.
68
+
69
+ ## Module Overview
70
+
71
+ Detailed documentation for each module in the project:
72
+
73
+ ### Metadata (`meta.ipynb`)
74
+
75
+ > Metadata introspection for the NLTK text plugin used by cjm-ctl to
76
+ > generate the registration manifest.
77
+
78
+ #### Import
79
+
80
+ ``` python
81
+ from cjm_text_plugin_nltk.meta import (
82
+ get_plugin_metadata
83
+ )
84
+ ```
85
+
86
+ #### Functions
87
+
88
+ ``` python
89
+ def get_plugin_metadata() -> Dict[str, Any]: # Plugin metadata for manifest generation
90
+ """Return metadata required to register this plugin with the PluginManager."""
91
+ # Fallback base path (current behavior for backward compatibility)
92
+ base_path = os.path.dirname(os.path.dirname(sys.executable))
93
+
94
+ # Use CJM config if available, else fallback to env-relative paths
95
+ cjm_data_dir = os.environ.get("CJM_DATA_DIR")
96
+
97
+ # Plugin data directory
98
+ plugin_name = "cjm-text-plugin-nltk"
99
+ if cjm_data_dir
100
+ "Return metadata required to register this plugin with the PluginManager."
101
+ ```
102
+
103
+ ### NLTK Plugin (`plugin.ipynb`)
104
+
105
+ > Plugin implementation for NLTK-based text processing with
106
+ > character-level span tracking
107
+
108
+ #### Import
109
+
110
+ ``` python
111
+ from cjm_text_plugin_nltk.plugin import (
112
+ NLTKPluginConfig,
113
+ NLTKPlugin
114
+ )
115
+ ```
116
+
117
+ #### Classes
118
+
119
+ ``` python
120
+ @dataclass
121
+ class NLTKPluginConfig:
122
+ "Configuration for NLTK text processing plugin."
123
+
124
+ tokenizer: str = field(...)
125
+ language: str = field(...)
126
+ ```
127
+
128
+ ``` python
129
+ class NLTKPlugin:
130
+ def __init__(self):
131
+ """Initialize the NLTK plugin."""
132
+ self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
133
+ self.config: NLTKPluginConfig = None
134
+ "NLTK-based text processing plugin with character-level span tracking."
135
+
136
+ def __init__(self):
137
+ """Initialize the NLTK plugin."""
138
+ self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
139
+ self.config: NLTKPluginConfig = None
140
+ "Initialize the NLTK plugin."
141
+
142
+ def name(self) -> str: # Plugin name identifier
143
+ """Get the plugin name identifier."""
144
+ return "nltk_text"
145
+
146
+ @property
147
+ def version(self) -> str: # Plugin version string
148
+ "Get the plugin name identifier."
149
+
150
+ def version(self) -> str: # Plugin version string
151
+ """Get the plugin version string."""
152
+ return "1.0.0"
153
+
154
+ def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
155
+ "Get the plugin version string."
156
+
157
+ def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
158
+ """Return current configuration state."""
159
+ if not self.config
160
+ "Return current configuration state."
161
+
162
+ def get_config_schema(self) -> Dict[str, Any]: # JSON Schema for configuration
163
+ """Return JSON Schema for UI generation."""
164
+ return dataclass_to_jsonschema(NLTKPluginConfig)
165
+
166
+ @staticmethod
167
+ def get_config_dataclass() -> NLTKPluginConfig: # Configuration dataclass
168
+ "Return JSON Schema for UI generation."
169
+
170
+ def get_config_dataclass() -> NLTKPluginConfig: # Configuration dataclass
171
+ """Return dataclass describing the plugin's configuration options."""
172
+ return NLTKPluginConfig
173
+
174
+ def _ensure_nltk_data(self) -> None
175
+ "Return dataclass describing the plugin's configuration options."
176
+
177
+ def initialize(
178
+ self,
179
+ config: Optional[Any] = None # Configuration dataclass, dict, or None
180
+ ) -> None
181
+ "Initialize or re-configure the plugin (idempotent)."
182
+
183
+ def execute(
184
+ self,
185
+ action: str = "split_sentences", # Operation: 'split_sentences'
186
+ **kwargs
187
+ ) -> Dict[str, Any]: # JSON-serializable result
188
+ "Execute a text processing operation."
189
+
190
+ def split_sentences(
191
+ self,
192
+ text: str, # Input text to split into sentences
193
+ **kwargs
194
+ ) -> TextProcessResult: # Result with TextSpan objects containing character indices
195
+ "Split text into sentence spans with accurate character positions."
196
+
197
+ def cleanup(self) -> None
198
+ "Clean up resources."
199
+ ```
@@ -0,0 +1,164 @@
1
+ # cjm-text-plugin-nltk
2
+
3
+
4
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5
+
6
+ ## Install
7
+
8
+ ``` bash
9
+ pip install cjm_text_plugin_nltk
10
+ ```
11
+
12
+ ## Project Structure
13
+
14
+ nbs/
15
+ ├── meta.ipynb # Metadata introspection for the NLTK text plugin used by cjm-ctl to generate the registration manifest.
16
+ └── plugin.ipynb # Plugin implementation for NLTK-based text processing with character-level span tracking
17
+
18
+ Total: 2 notebooks
19
+
20
+ ## Module Dependencies
21
+
22
+ ``` mermaid
23
+ graph LR
24
+ meta[meta<br/>Metadata]
25
+ plugin[plugin<br/>NLTK Plugin]
26
+ ```
27
+
28
+ No cross-module dependencies detected.
29
+
30
+ ## CLI Reference
31
+
32
+ No CLI commands found in this project.
33
+
34
+ ## Module Overview
35
+
36
+ Detailed documentation for each module in the project:
37
+
38
+ ### Metadata (`meta.ipynb`)
39
+
40
+ > Metadata introspection for the NLTK text plugin used by cjm-ctl to
41
+ > generate the registration manifest.
42
+
43
+ #### Import
44
+
45
+ ``` python
46
+ from cjm_text_plugin_nltk.meta import (
47
+ get_plugin_metadata
48
+ )
49
+ ```
50
+
51
+ #### Functions
52
+
53
+ ``` python
54
+ def get_plugin_metadata() -> Dict[str, Any]: # Plugin metadata for manifest generation
55
+ """Return metadata required to register this plugin with the PluginManager."""
56
+ # Fallback base path (current behavior for backward compatibility)
57
+ base_path = os.path.dirname(os.path.dirname(sys.executable))
58
+
59
+ # Use CJM config if available, else fallback to env-relative paths
60
+ cjm_data_dir = os.environ.get("CJM_DATA_DIR")
61
+
62
+ # Plugin data directory
63
+ plugin_name = "cjm-text-plugin-nltk"
64
+ if cjm_data_dir
65
+ "Return metadata required to register this plugin with the PluginManager."
66
+ ```
67
+
68
+ ### NLTK Plugin (`plugin.ipynb`)
69
+
70
+ > Plugin implementation for NLTK-based text processing with
71
+ > character-level span tracking
72
+
73
+ #### Import
74
+
75
+ ``` python
76
+ from cjm_text_plugin_nltk.plugin import (
77
+ NLTKPluginConfig,
78
+ NLTKPlugin
79
+ )
80
+ ```
81
+
82
+ #### Classes
83
+
84
+ ``` python
85
+ @dataclass
86
+ class NLTKPluginConfig:
87
+ "Configuration for NLTK text processing plugin."
88
+
89
+ tokenizer: str = field(...)
90
+ language: str = field(...)
91
+ ```
92
+
93
+ ``` python
94
+ class NLTKPlugin:
95
+ def __init__(self):
96
+ """Initialize the NLTK plugin."""
97
+ self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
98
+ self.config: NLTKPluginConfig = None
99
+ "NLTK-based text processing plugin with character-level span tracking."
100
+
101
+ def __init__(self):
102
+ """Initialize the NLTK plugin."""
103
+ self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
104
+ self.config: NLTKPluginConfig = None
105
+ "Initialize the NLTK plugin."
106
+
107
+ def name(self) -> str: # Plugin name identifier
108
+ """Get the plugin name identifier."""
109
+ return "nltk_text"
110
+
111
+ @property
112
+ def version(self) -> str: # Plugin version string
113
+ "Get the plugin name identifier."
114
+
115
+ def version(self) -> str: # Plugin version string
116
+ """Get the plugin version string."""
117
+ return "1.0.0"
118
+
119
+ def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
120
+ "Get the plugin version string."
121
+
122
+ def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
123
+ """Return current configuration state."""
124
+ if not self.config
125
+ "Return current configuration state."
126
+
127
+ def get_config_schema(self) -> Dict[str, Any]: # JSON Schema for configuration
128
+ """Return JSON Schema for UI generation."""
129
+ return dataclass_to_jsonschema(NLTKPluginConfig)
130
+
131
+ @staticmethod
132
+ def get_config_dataclass() -> NLTKPluginConfig: # Configuration dataclass
133
+ "Return JSON Schema for UI generation."
134
+
135
+ def get_config_dataclass() -> NLTKPluginConfig: # Configuration dataclass
136
+ """Return dataclass describing the plugin's configuration options."""
137
+ return NLTKPluginConfig
138
+
139
+ def _ensure_nltk_data(self) -> None
140
+ "Return dataclass describing the plugin's configuration options."
141
+
142
+ def initialize(
143
+ self,
144
+ config: Optional[Any] = None # Configuration dataclass, dict, or None
145
+ ) -> None
146
+ "Initialize or re-configure the plugin (idempotent)."
147
+
148
+ def execute(
149
+ self,
150
+ action: str = "split_sentences", # Operation: 'split_sentences'
151
+ **kwargs
152
+ ) -> Dict[str, Any]: # JSON-serializable result
153
+ "Execute a text processing operation."
154
+
155
+ def split_sentences(
156
+ self,
157
+ text: str, # Input text to split into sentences
158
+ **kwargs
159
+ ) -> TextProcessResult: # Result with TextSpan objects containing character indices
160
+ "Split text into sentence spans with accurate character positions."
161
+
162
+ def cleanup(self) -> None
163
+ "Clean up resources."
164
+ ```
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
@@ -0,0 +1,37 @@
1
+ # Autogenerated by nbdev
2
+
3
+ d = { 'settings': { 'branch': 'main',
4
+ 'doc_baseurl': '/cjm-text-plugin-nltk',
5
+ 'doc_host': 'https://cj-mills.github.io',
6
+ 'git_url': 'https://github.com/cj-mills/cjm-text-plugin-nltk',
7
+ 'lib_path': 'cjm_text_plugin_nltk'},
8
+ 'syms': { 'cjm_text_plugin_nltk.meta': { 'cjm_text_plugin_nltk.meta.get_plugin_metadata': ( 'meta.html#get_plugin_metadata',
9
+ 'cjm_text_plugin_nltk/meta.py')},
10
+ 'cjm_text_plugin_nltk.plugin': { 'cjm_text_plugin_nltk.plugin.NLTKPlugin': ( 'plugin.html#nltkplugin',
11
+ 'cjm_text_plugin_nltk/plugin.py'),
12
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.__init__': ( 'plugin.html#nltkplugin.__init__',
13
+ 'cjm_text_plugin_nltk/plugin.py'),
14
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin._ensure_nltk_data': ( 'plugin.html#nltkplugin._ensure_nltk_data',
15
+ 'cjm_text_plugin_nltk/plugin.py'),
16
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin._get_tokenizer': ( 'plugin.html#nltkplugin._get_tokenizer',
17
+ 'cjm_text_plugin_nltk/plugin.py'),
18
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.cleanup': ( 'plugin.html#nltkplugin.cleanup',
19
+ 'cjm_text_plugin_nltk/plugin.py'),
20
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.execute': ( 'plugin.html#nltkplugin.execute',
21
+ 'cjm_text_plugin_nltk/plugin.py'),
22
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.get_config_dataclass': ( 'plugin.html#nltkplugin.get_config_dataclass',
23
+ 'cjm_text_plugin_nltk/plugin.py'),
24
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.get_config_schema': ( 'plugin.html#nltkplugin.get_config_schema',
25
+ 'cjm_text_plugin_nltk/plugin.py'),
26
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.get_current_config': ( 'plugin.html#nltkplugin.get_current_config',
27
+ 'cjm_text_plugin_nltk/plugin.py'),
28
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.initialize': ( 'plugin.html#nltkplugin.initialize',
29
+ 'cjm_text_plugin_nltk/plugin.py'),
30
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.name': ( 'plugin.html#nltkplugin.name',
31
+ 'cjm_text_plugin_nltk/plugin.py'),
32
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.split_sentences': ( 'plugin.html#nltkplugin.split_sentences',
33
+ 'cjm_text_plugin_nltk/plugin.py'),
34
+ 'cjm_text_plugin_nltk.plugin.NLTKPlugin.version': ( 'plugin.html#nltkplugin.version',
35
+ 'cjm_text_plugin_nltk/plugin.py'),
36
+ 'cjm_text_plugin_nltk.plugin.NLTKPluginConfig': ( 'plugin.html#nltkpluginconfig',
37
+ 'cjm_text_plugin_nltk/plugin.py')}}}
@@ -0,0 +1,60 @@
1
+ """Metadata introspection for the NLTK text plugin used by cjm-ctl to generate the registration manifest."""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/meta.ipynb.
4
+
5
+ # %% auto #0
6
+ __all__ = ['get_plugin_metadata']
7
+
8
+ # %% ../nbs/meta.ipynb #3508402d
9
+ import os
10
+ import sys
11
+ from typing import Any, Dict
12
+
13
+ from . import __version__
14
+
15
+ # %% ../nbs/meta.ipynb #791d750b
16
+ def get_plugin_metadata() -> Dict[str, Any]: # Plugin metadata for manifest generation
17
+ """Return metadata required to register this plugin with the PluginManager."""
18
+ # Fallback base path (current behavior for backward compatibility)
19
+ base_path = os.path.dirname(os.path.dirname(sys.executable))
20
+
21
+ # Use CJM config if available, else fallback to env-relative paths
22
+ cjm_data_dir = os.environ.get("CJM_DATA_DIR")
23
+
24
+ # Plugin data directory
25
+ plugin_name = "cjm-text-plugin-nltk"
26
+ if cjm_data_dir:
27
+ data_dir = os.path.join(cjm_data_dir, plugin_name)
28
+ else:
29
+ data_dir = os.path.join(base_path, "data")
30
+
31
+ # Ensure data directory exists
32
+ os.makedirs(data_dir, exist_ok=True)
33
+
34
+ # NLTK data directory
35
+ nltk_data_path = os.path.join(data_dir, "nltk_data")
36
+ os.makedirs(nltk_data_path, exist_ok=True)
37
+
38
+ return {
39
+ "name": plugin_name,
40
+ "version": __version__,
41
+ "type": "text-processing",
42
+ "category": "text-processing",
43
+ "interface": "cjm_text_plugin_system.plugin_interface.TextProcessingPlugin",
44
+
45
+ "module": "cjm_text_plugin_nltk.plugin",
46
+ "class": "NLTKPlugin",
47
+
48
+ # Critical: The absolute path to THIS environment's python
49
+ "python_path": sys.executable,
50
+
51
+ # NLTK is lightweight - no GPU required
52
+ "resources": {
53
+ "requires_gpu": False,
54
+ "min_system_ram_mb": 512
55
+ },
56
+
57
+ "env_vars": {
58
+ "NLTK_DATA": nltk_data_path
59
+ }
60
+ }
@@ -0,0 +1,204 @@
1
+ """Plugin implementation for NLTK-based text processing with character-level span tracking"""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/plugin.ipynb.
4
+
5
+ # %% auto #0
6
+ __all__ = ['NLTKPluginConfig', 'NLTKPlugin']
7
+
8
+ # %% ../nbs/plugin.ipynb #1899201c
9
+ import logging
10
+ import os
11
+ from dataclasses import dataclass, field
12
+ from typing import Dict, Any, Optional, List
13
+
14
+ import nltk
15
+ from nltk.tokenize import PunktSentenceTokenizer
16
+
17
+ from cjm_text_plugin_system.plugin_interface import TextProcessingPlugin
18
+ from cjm_text_plugin_system.core import TextProcessResult, TextSpan
19
+ from cjm_plugin_system.utils.validation import (
20
+ dict_to_config, config_to_dict, dataclass_to_jsonschema,
21
+ SCHEMA_TITLE, SCHEMA_DESC, SCHEMA_ENUM
22
+ )
23
+
24
+ # %% ../nbs/plugin.ipynb #687955b4
25
+ @dataclass
26
+ class NLTKPluginConfig:
27
+ """Configuration for NLTK text processing plugin."""
28
+ tokenizer: str = field(
29
+ default="punkt",
30
+ metadata={
31
+ SCHEMA_TITLE: "Tokenizer",
32
+ SCHEMA_DESC: "NLTK tokenizer to use for sentence splitting",
33
+ SCHEMA_ENUM: ["punkt"]
34
+ }
35
+ )
36
+ language: str = field(
37
+ default="english",
38
+ metadata={
39
+ SCHEMA_TITLE: "Language",
40
+ SCHEMA_DESC: "Language for tokenization (affects sentence boundary detection)",
41
+ SCHEMA_ENUM: ["english", "german", "french", "spanish", "italian", "portuguese", "dutch"]
42
+ }
43
+ )
44
+
45
+ # %% ../nbs/plugin.ipynb #330602bc
46
+ class NLTKPlugin(TextProcessingPlugin):
47
+ """NLTK-based text processing plugin with character-level span tracking."""
48
+
49
+ config_class = NLTKPluginConfig
50
+
51
+ def __init__(self):
52
+ """Initialize the NLTK plugin."""
53
+ self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
54
+ self.config: NLTKPluginConfig = None
55
+ self._tokenizer: PunktSentenceTokenizer = None
56
+ self._nltk_data_dir: Optional[str] = None
57
+
58
+ @property
59
+ def name(self) -> str: # Plugin name identifier
60
+ """Get the plugin name identifier."""
61
+ return "nltk_text"
62
+
63
+ @property
64
+ def version(self) -> str: # Plugin version string
65
+ """Get the plugin version string."""
66
+ return "1.0.0"
67
+
68
+ def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
69
+ """Return current configuration state."""
70
+ if not self.config:
71
+ return {}
72
+ return config_to_dict(self.config)
73
+
74
+ def get_config_schema(self) -> Dict[str, Any]: # JSON Schema for configuration
75
+ """Return JSON Schema for UI generation."""
76
+ return dataclass_to_jsonschema(NLTKPluginConfig)
77
+
78
+ @staticmethod
79
+ def get_config_dataclass() -> NLTKPluginConfig: # Configuration dataclass
80
+ """Return dataclass describing the plugin's configuration options."""
81
+ return NLTKPluginConfig
82
+
83
+ def _ensure_nltk_data(self) -> None:
84
+ """Ensure required NLTK data packages are downloaded to the configured directory."""
85
+ # Get NLTK data directory from environment (set by manifest env_vars)
86
+ nltk_data_dir = os.environ.get("NLTK_DATA")
87
+
88
+ if nltk_data_dir:
89
+ # Ensure the directory exists
90
+ os.makedirs(nltk_data_dir, exist_ok=True)
91
+
92
+ # Replace NLTK's search path to ONLY use our directory
93
+ # This prevents NLTK from finding/using data in ~/nltk_data
94
+ nltk.data.path = [nltk_data_dir]
95
+
96
+ self._nltk_data_dir = nltk_data_dir
97
+ self.logger.info(f"Using NLTK data directory: {nltk_data_dir}")
98
+
99
+ # Check if data exists in OUR directory specifically
100
+ punkt_path = os.path.join(nltk_data_dir, "tokenizers", "punkt")
101
+ punkt_tab_path = os.path.join(nltk_data_dir, "tokenizers", "punkt_tab")
102
+
103
+ if not os.path.exists(punkt_path):
104
+ self.logger.info(f"Downloading NLTK 'punkt' tokenizer to {nltk_data_dir}...")
105
+ nltk.download('punkt', quiet=True, download_dir=nltk_data_dir)
106
+
107
+ if not os.path.exists(punkt_tab_path):
108
+ self.logger.info(f"Downloading NLTK 'punkt_tab' tokenizer to {nltk_data_dir}...")
109
+ nltk.download('punkt_tab', quiet=True, download_dir=nltk_data_dir)
110
+ else:
111
+ # No custom directory - use NLTK defaults
112
+ try:
113
+ nltk.data.find('tokenizers/punkt')
114
+ except LookupError:
115
+ self.logger.info("Downloading NLTK 'punkt' tokenizer...")
116
+ nltk.download('punkt', quiet=True)
117
+
118
+ try:
119
+ nltk.data.find('tokenizers/punkt_tab')
120
+ except LookupError:
121
+ self.logger.info("Downloading NLTK 'punkt_tab' tokenizer...")
122
+ nltk.download('punkt_tab', quiet=True)
123
+
124
+ def initialize(
125
+ self,
126
+ config: Optional[Any] = None # Configuration dataclass, dict, or None
127
+ ) -> None:
128
+ """Initialize or re-configure the plugin (idempotent)."""
129
+ # Parse new config
130
+ new_config = dict_to_config(NLTKPluginConfig, config or {})
131
+
132
+ # Check for changes if already running
133
+ if self.config:
134
+ if self.config.language != new_config.language:
135
+ self.logger.info(f"Config change: Language {self.config.language} -> {new_config.language}")
136
+ self._tokenizer = None # Reset tokenizer for new language
137
+
138
+ # Apply new config
139
+ self.config = new_config
140
+
141
+ # Ensure NLTK data is available
142
+ self._ensure_nltk_data()
143
+
144
+ self.logger.info(f"Initialized NLTK plugin with language '{self.config.language}'")
145
+
146
+ def _get_tokenizer(self) -> PunktSentenceTokenizer:
147
+ """Get or create the sentence tokenizer (lazy loading)."""
148
+ if self._tokenizer is None:
149
+ self._tokenizer = PunktSentenceTokenizer()
150
+ return self._tokenizer
151
+
152
+ def execute(
153
+ self,
154
+ action: str = "split_sentences", # Operation: 'split_sentences'
155
+ **kwargs
156
+ ) -> Dict[str, Any]: # JSON-serializable result
157
+ """Execute a text processing operation."""
158
+ if action == "split_sentences":
159
+ text = kwargs.pop("text", "")
160
+ result = self.split_sentences(text, **kwargs)
161
+
162
+ # Serialize for IPC
163
+ return {
164
+ "spans": [s.to_dict() for s in result.spans],
165
+ "metadata": result.metadata
166
+ }
167
+ else:
168
+ raise ValueError(f"Unknown action: {action}")
169
+
170
+ def split_sentences(
171
+ self,
172
+ text: str, # Input text to split into sentences
173
+ **kwargs
174
+ ) -> TextProcessResult: # Result with TextSpan objects containing character indices
175
+ """Split text into sentence spans with accurate character positions."""
176
+ tokenizer = self._get_tokenizer()
177
+
178
+ # Get (start, end) tuples using span_tokenize
179
+ span_indices = list(tokenizer.span_tokenize(text))
180
+
181
+ text_spans: List[TextSpan] = []
182
+ for start, end in span_indices:
183
+ span_text = text[start:end]
184
+ text_spans.append(TextSpan(
185
+ text=span_text,
186
+ start_char=start,
187
+ end_char=end,
188
+ label="sentence"
189
+ ))
190
+
191
+ return TextProcessResult(
192
+ spans=text_spans,
193
+ metadata={
194
+ "processor": self.name,
195
+ "tokenizer": self.config.tokenizer if self.config else "punkt",
196
+ "language": self.config.language if self.config else "english",
197
+ "nltk_data_dir": self._nltk_data_dir
198
+ }
199
+ )
200
+
201
+ def cleanup(self) -> None:
202
+ """Clean up resources."""
203
+ self._tokenizer = None
204
+ self.logger.info("NLTK plugin cleanup completed")
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: cjm-text-plugin-nltk
3
+ Version: 0.0.1
4
+ Summary: A local, NLTK-based text processing worker for the cjm-plugin-system that provides sentence splitting and tokenization with character-level span tracking.
5
+ Home-page: https://github.com/cj-mills/cjm-text-plugin-nltk
6
+ Author: Christian J. Mills
7
+ Author-email: 9126128+cj-mills@users.noreply.github.com
8
+ License: Apache-2.0
9
+ Keywords: nbdev jupyter notebook python
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: cjm_text_plugin_system
20
+ Requires-Dist: nltk
21
+ Provides-Extra: dev
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: keywords
29
+ Dynamic: license
30
+ Dynamic: license-file
31
+ Dynamic: provides-extra
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # cjm-text-plugin-nltk
37
+
38
+
39
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
40
+
41
+ ## Install
42
+
43
+ ``` bash
44
+ pip install cjm_text_plugin_nltk
45
+ ```
46
+
47
+ ## Project Structure
48
+
49
+ nbs/
50
+ ├── meta.ipynb # Metadata introspection for the NLTK text plugin used by cjm-ctl to generate the registration manifest.
51
+ └── plugin.ipynb # Plugin implementation for NLTK-based text processing with character-level span tracking
52
+
53
+ Total: 2 notebooks
54
+
55
+ ## Module Dependencies
56
+
57
+ ``` mermaid
58
+ graph LR
59
+ meta[meta<br/>Metadata]
60
+ plugin[plugin<br/>NLTK Plugin]
61
+ ```
62
+
63
+ No cross-module dependencies detected.
64
+
65
+ ## CLI Reference
66
+
67
+ No CLI commands found in this project.
68
+
69
+ ## Module Overview
70
+
71
+ Detailed documentation for each module in the project:
72
+
73
+ ### Metadata (`meta.ipynb`)
74
+
75
+ > Metadata introspection for the NLTK text plugin used by cjm-ctl to
76
+ > generate the registration manifest.
77
+
78
+ #### Import
79
+
80
+ ``` python
81
+ from cjm_text_plugin_nltk.meta import (
82
+ get_plugin_metadata
83
+ )
84
+ ```
85
+
86
+ #### Functions
87
+
88
+ ``` python
89
+ def get_plugin_metadata() -> Dict[str, Any]: # Plugin metadata for manifest generation
90
+ """Return metadata required to register this plugin with the PluginManager."""
91
+ # Fallback base path (current behavior for backward compatibility)
92
+ base_path = os.path.dirname(os.path.dirname(sys.executable))
93
+
94
+ # Use CJM config if available, else fallback to env-relative paths
95
+ cjm_data_dir = os.environ.get("CJM_DATA_DIR")
96
+
97
+ # Plugin data directory
98
+ plugin_name = "cjm-text-plugin-nltk"
99
+ if cjm_data_dir
100
+ "Return metadata required to register this plugin with the PluginManager."
101
+ ```
102
+
103
+ ### NLTK Plugin (`plugin.ipynb`)
104
+
105
+ > Plugin implementation for NLTK-based text processing with
106
+ > character-level span tracking
107
+
108
+ #### Import
109
+
110
+ ``` python
111
+ from cjm_text_plugin_nltk.plugin import (
112
+ NLTKPluginConfig,
113
+ NLTKPlugin
114
+ )
115
+ ```
116
+
117
+ #### Classes
118
+
119
+ ``` python
120
+ @dataclass
121
+ class NLTKPluginConfig:
122
+ "Configuration for NLTK text processing plugin."
123
+
124
+ tokenizer: str = field(...)
125
+ language: str = field(...)
126
+ ```
127
+
128
+ ``` python
129
+ class NLTKPlugin:
130
+ def __init__(self):
131
+ """Initialize the NLTK plugin."""
132
+ self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
133
+ self.config: NLTKPluginConfig = None
134
+ "NLTK-based text processing plugin with character-level span tracking."
135
+
136
+ def __init__(self):
137
+ """Initialize the NLTK plugin."""
138
+ self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
139
+ self.config: NLTKPluginConfig = None
140
+ "Initialize the NLTK plugin."
141
+
142
+ def name(self) -> str: # Plugin name identifier
143
+ """Get the plugin name identifier."""
144
+ return "nltk_text"
145
+
146
+ @property
147
+ def version(self) -> str: # Plugin version string
148
+ "Get the plugin name identifier."
149
+
150
+ def version(self) -> str: # Plugin version string
151
+ """Get the plugin version string."""
152
+ return "1.0.0"
153
+
154
+ def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
155
+ "Get the plugin version string."
156
+
157
+ def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
158
+ """Return current configuration state."""
159
+ if not self.config
160
+ "Return current configuration state."
161
+
162
+ def get_config_schema(self) -> Dict[str, Any]: # JSON Schema for configuration
163
+ """Return JSON Schema for UI generation."""
164
+ return dataclass_to_jsonschema(NLTKPluginConfig)
165
+
166
+ @staticmethod
167
+ def get_config_dataclass() -> NLTKPluginConfig: # Configuration dataclass
168
+ "Return JSON Schema for UI generation."
169
+
170
+ def get_config_dataclass() -> NLTKPluginConfig: # Configuration dataclass
171
+ """Return dataclass describing the plugin's configuration options."""
172
+ return NLTKPluginConfig
173
+
174
+ def _ensure_nltk_data(self) -> None
175
+ "Return dataclass describing the plugin's configuration options."
176
+
177
+ def initialize(
178
+ self,
179
+ config: Optional[Any] = None # Configuration dataclass, dict, or None
180
+ ) -> None
181
+ "Initialize or re-configure the plugin (idempotent)."
182
+
183
+ def execute(
184
+ self,
185
+ action: str = "split_sentences", # Operation: 'split_sentences'
186
+ **kwargs
187
+ ) -> Dict[str, Any]: # JSON-serializable result
188
+ "Execute a text processing operation."
189
+
190
+ def split_sentences(
191
+ self,
192
+ text: str, # Input text to split into sentences
193
+ **kwargs
194
+ ) -> TextProcessResult: # Result with TextSpan objects containing character indices
195
+ "Split text into sentence spans with accurate character positions."
196
+
197
+ def cleanup(self) -> None
198
+ "Clean up resources."
199
+ ```
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ settings.ini
6
+ setup.py
7
+ cjm_text_plugin_nltk/__init__.py
8
+ cjm_text_plugin_nltk/_modidx.py
9
+ cjm_text_plugin_nltk/meta.py
10
+ cjm_text_plugin_nltk/plugin.py
11
+ cjm_text_plugin_nltk.egg-info/PKG-INFO
12
+ cjm_text_plugin_nltk.egg-info/SOURCES.txt
13
+ cjm_text_plugin_nltk.egg-info/dependency_links.txt
14
+ cjm_text_plugin_nltk.egg-info/entry_points.txt
15
+ cjm_text_plugin_nltk.egg-info/not-zip-safe
16
+ cjm_text_plugin_nltk.egg-info/requires.txt
17
+ cjm_text_plugin_nltk.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [nbdev]
2
+ cjm_text_plugin_nltk = cjm_text_plugin_nltk._modidx:d
@@ -0,0 +1,4 @@
1
+ cjm_text_plugin_system
2
+ nltk
3
+
4
+ [dev]
@@ -0,0 +1 @@
1
+ cjm_text_plugin_nltk
@@ -0,0 +1,11 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name="cjm-text-plugin-nltk"
7
+ requires-python=">=3.11"
8
+ dynamic = [ "keywords", "description", "version", "dependencies", "optional-dependencies", "readme", "license", "authors", "classifiers", "entry-points", "scripts", "urls"]
9
+
10
+ [tool.uv]
11
+ cache-keys = [{ file = "pyproject.toml" }, { file = "settings.ini" }, { file = "setup.py" }]
@@ -0,0 +1,46 @@
1
+ [DEFAULT]
2
+ # All sections below are required unless otherwise specified.
3
+ # See https://github.com/AnswerDotAI/nbdev/blob/main/settings.ini for examples.
4
+
5
+ ### Python library ###
6
+ repo = cjm-text-plugin-nltk
7
+ lib_name = %(repo)s
8
+ version = 0.0.1
9
+ min_python = 3.11
10
+ license = apache2
11
+ black_formatting = False
12
+
13
+ ### nbdev ###
14
+ doc_path = _docs
15
+ lib_path = cjm_text_plugin_nltk
16
+ nbs_path = nbs
17
+ recursive = True
18
+ tst_flags = notest
19
+ put_version_in_init = True
20
+ update_pyproject = True
21
+
22
+ ### Docs ###
23
+ branch = main
24
+ custom_sidebar = False
25
+ doc_host = https://%(user)s.github.io
26
+ doc_baseurl = /%(repo)s
27
+ git_url = https://github.com/%(user)s/%(repo)s
28
+ title = %(lib_name)s
29
+
30
+ ### PyPI ###
31
+ audience = Developers
32
+ author = Christian J. Mills
33
+ author_email = 9126128+cj-mills@users.noreply.github.com
34
+ copyright = 2026 onwards, %(author)s
35
+ description = A local, NLTK-based text processing worker for the cjm-plugin-system that provides sentence splitting and tokenization with character-level span tracking.
36
+ keywords = nbdev jupyter notebook python
37
+ language = English
38
+ status = 3
39
+ user = cj-mills
40
+
41
+ ### Optional ###
42
+ requirements = cjm_text_plugin_system nltk
43
+ # dev_requirements =
44
+ # console_scripts =
45
+ # conda_user =
46
+ # package_data =
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,63 @@
1
+ from pkg_resources import parse_version
2
+ from configparser import ConfigParser
3
+ import setuptools, shlex
4
+ assert parse_version(setuptools.__version__)>=parse_version('36.2')
5
+
6
+ # note: all settings are in settings.ini; edit there, not here
7
+ config = ConfigParser(delimiters=['='])
8
+ config.read('settings.ini', encoding='utf-8')
9
+ cfg = config['DEFAULT']
10
+
11
+ cfg_keys = 'version description keywords author author_email'.split()
12
+ expected = cfg_keys + "lib_name user branch license status min_python audience language".split()
13
+ for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
14
+ setup_cfg = {o:cfg[o] for o in cfg_keys}
15
+
16
+ licenses = {
17
+ 'apache2': 'Apache-2.0',
18
+ 'mit': 'MIT',
19
+ 'gpl2': 'GPL-2.0-only',
20
+ 'gpl3': 'GPL-3.0-or-later',
21
+ 'bsd3': 'BSD-3-Clause',
22
+ }
23
+ statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
24
+ '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ]
25
+ py_versions = '3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13'.split()
26
+
27
+ requirements = shlex.split(cfg.get('requirements', ''))
28
+ if cfg.get('pip_requirements'): requirements += shlex.split(cfg.get('pip_requirements', ''))
29
+ min_python = cfg['min_python']
30
+ dev_requirements = (cfg.get('dev_requirements') or '').split()
31
+
32
+ package_data = dict()
33
+ pkg_data = cfg.get('package_data', None)
34
+ if pkg_data:
35
+ package_data[cfg['lib_name']] = pkg_data.split() # split as multiple files might be listed
36
+ # Add package data to setup_cfg for setuptools.setup(..., **setup_cfg)
37
+ setup_cfg['package_data'] = package_data
38
+
39
+ setuptools.setup(
40
+ name = cfg['lib_name'],
41
+ license = licenses.get(cfg['license'].lower(), cfg['license']),
42
+ classifiers = [
43
+ 'Development Status :: ' + statuses[int(cfg['status'])],
44
+ 'Intended Audience :: ' + cfg['audience'].title(),
45
+ 'Natural Language :: ' + cfg['language'].title(),
46
+ ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]],
47
+ url = cfg['git_url'],
48
+ packages = setuptools.find_packages(),
49
+ include_package_data = True,
50
+ install_requires = requirements,
51
+ extras_require={ 'dev': dev_requirements },
52
+ dependency_links = cfg.get('dep_links','').split(),
53
+ python_requires = '>=' + cfg['min_python'],
54
+ long_description = open('README.md', encoding='utf-8').read(),
55
+ long_description_content_type = 'text/markdown',
56
+ zip_safe = False,
57
+ entry_points = {
58
+ 'console_scripts': cfg.get('console_scripts','').split(),
59
+ 'nbdev': [f'{cfg.get("lib_path")}={cfg.get("lib_path")}._modidx:d']
60
+ },
61
+ **setup_cfg)
62
+
63
+