cltk
Lightweight package init exposing the public API.
Goals:
- Avoid importing heavy dependencies or performing I/O at import time.
- Re-export only stable, leaf-level names.
- Define __all__ to the exact public surface.
NLP
NLP(
language_code: Optional[str] = None,
backend: BACKEND_TYPES = "stanza",
model: Optional[
Union[str, AVAILABLE_OPENAI_MODELS]
] = None,
custom_pipeline: Optional[Pipeline] = None,
suppress_banner: bool = False,
cltk_config: Optional[CLTKConfig] = None,
)
Convenience facade for running CLTK pipelines.
Parameters:
-
language_code(Optional[str], default:None) –Language key (Glottolog code, ISO code, or exact name). Required unless
cltk_configis provided. -
backend(BACKEND_TYPES, default:'stanza') –One of
"stanza"(default),"openai","ollama","ollama-cloud", ormistral. The"spacy"backend is not yet implemented and will raiseNotImplementedError. -
model(Optional[Union[str, AVAILABLE_OPENAI_MODELS]], default:None) –Optional model name when using generative backends (
"openai","ollama","ollama-cloud",mistral). Ignored for"stanza". -
custom_pipeline(Optional[Pipeline], default:None) –Optional pipeline to use instead of the default mapping.
-
suppress_banner(bool, default:False) –If true, suppresses informational console output.
-
cltk_config(Optional[CLTKConfig], default:None) –Optional :class:
~cltk.core.data_types.CLTKConfigbundle. When provided, its values override the other constructor arguments.
Notes
- When
backend == "openai"and nomodelis provided, defaults to"gpt-5-mini". RequiresOPENAI_API_KEYin the environment. - When
backendis"ollama"or"ollama-cloud"and nomodelis provided, defaults to"llama3.1:8b"."ollama-cloud"requiresOLLAMA_CLOUD_API_KEYin the environment. - The
"stanza"backend does not accept amodelparameter; language models are bound to the pipeline for each language.
Source code in cltk/nlp.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
pipeline
instance-attribute
analyze
Run text through the selected NLP pipeline and return a document.
Parameters:
-
text(str) –Raw text to analyze.
Returns:
-
A(Doc) –class:
~cltk.core.data_types.Docenriched by each process in the -
Doc–pipeline (e.g., sentence boundaries, tokens, features).
Raises:
-
ValueError–If
textis empty or not a string. -
RuntimeError–If any process fails during execution.
Source code in cltk/nlp.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
Submodules
cltk.__main__cltk.clicltk.cli.analyzecltk.cli.comparecltk.cli.compare_backendscltk.cli.dispatchcltk.cli.exportcltk.cli.maincltk.cli.pipelinecltk.cli.utilscltk.compare_backendscltk.corecltk.core.cltk_loggercltk.core.data_typescltk.core.exceptionscltk.core.logging_utilscltk.core.process_registrycltk.core.provenancecltk.dependencycltk.dependency.processescltk.dependency.utilscltk.enrichmentcltk.enrichment.processescltk.enrichment.utilscltk.evaluationcltk.evaluation.compare_backendscltk.exportscltk.exports._helperscltk.exports.igtcltk.exports.readers_guide_htmlcltk.exports.teicltk.genaicltk.genai.mistralcltk.genai.ollamacltk.genai.openaicltk.genai.prompt_registrycltk.genai.promptscltk.languagescltk.languages.example_textscltk.languages.glottologcltk.languages.languagescltk.languages.pipelinescltk.languages.utilscltk.morphosyntaxcltk.morphosyntax.conllcltk.morphosyntax.normalizationcltk.morphosyntax.processescltk.morphosyntax.ud_deprelscltk.morphosyntax.ud_featurescltk.morphosyntax.ud_language_featurescltk.morphosyntax.ud_poscltk.morphosyntax.utilscltk.nlpcltk.pipelinecltk.pipeline.compilercltk.pipeline.presetscltk.pipeline.spec_iocltk.pipeline.specscltk.sentencecltk.sentence.processescltk.sentence.utilscltk.stanzacltk.stanza.processescltk.textcltk.text.processescltk.text.utilscltk.translationcltk.translation.processescltk.translation.utilscltk.utilscltk.utils.file_operationscltk.utils.file_outputscltk.utils.utils