Skip to main content

Importable modules for learning machine learning and deep learning.

Project description

ai-starter-kit

PyPI

Importable boilerplate for machine learning / deep learning projects — reusable code wrapped around common libraries (like NLTK) so you don't have to rewrite the same setup every time. Install it, import what you need.

Install

pip install ai-starter-kit

Available modules

Module Description
ask.text Chains common NLP preprocessing steps (lowercasing, noise/punctuation removal, tokenization, stopword removal, stemming, lemmatization) behind a fluent, resettable TextProcessor API using NLTK.

More modules will be added as the project grows.

Text Processing

Each preprocessing step is a method on TextProcessor that returns self, so they can be called individually, one at a time, or chained together in a single fluent pipeline:

from ask.text import TextProcessor, PartOfSpeech

tp = TextProcessor([
    "Running, runners ran quickly through the running trails.",
    "Check out <b>this</b> amazing offer at https://example.com!! Call 12345 now.",
])

By default, constructing a TextProcessor downloads the NLTK data it needs (punkt, punkt_tab, stopwords, wordnet) the first time, which requires network access and can be slow — or fail outright in offline/sandboxed environments. Pass auto_download=False to skip this (e.g. if you've already fetched the data yourself via nltk.download(), or don't need methods that depend on it).

Individually, one step at a time, resetting back to the original input between each:

tp.reset().tokenize()
tp.reset().to_lowercase().tokenize()
tp.reset().remove_punctuation().tokenize()
tp.reset().tokenize().remove_stopwords()
tp.reset().remove_noise().tokenize()
tp.reset().tokenize().stem()
tp.reset().tokenize().lemmatize(pos=PartOfSpeech.Noun)

Or chained together as a full preprocessing pipeline:

tp.reset().to_lowercase().remove_noise().remove_punctuation().tokenize().remove_stopwords().lemmatize(pos=PartOfSpeech.Verb)

print(tp.tokens)
# [['run', 'runners', 'run', 'quickly', 'run', 'trail'], ['check', 'amaze', 'offer', 'call']]

Methods

TextProcessor holds two pieces of state: .sentences (a list of strings) and .tokens (a list of word lists, populated by .tokenize()). Most methods work on one or the other, and .remove_stopwords(), .stem(), and .lemmatize() require .tokenize() to have been called first — call them too early and they raise ValueError.

Method Operates on Description
to_lowercase() .sentences Lowercases every sentence.
remove_noise(html=True, urls=True, numbers=True, special_chars=True) .sentences Strips HTML tags, URLs, digits, and/or non-letter characters. Each kind of noise can be toggled off.
remove_punctuation() .sentences Strips punctuation from each sentence.
tokenize() .sentences.tokens Splits each sentence into a list of word tokens.
remove_stopwords() .tokens Drops common stopwords (e.g. "the", "a") from each token list.
stem() .tokens Reduces each token to its word stem (Porter stemmer).
lemmatize(pos=PartOfSpeech.Verb) .tokens Reduces each token to its dictionary form for the given part of speech.
reset() both Restores .sentences to the original constructor input and clears .tokens.

PartOfSpeech is an enum with Noun, Verb, Adjective, and Adverb — pass one to lemmatize(pos=...) to control how words are reduced.

Development

To set up a local environment for running the test suite:

# Windows
powershell -ExecutionPolicy Bypass -File .\scripts\bootstrap.ps1
# macOS/Linux
./scripts/bootstrap.sh

This creates a .venv, installs the package in editable mode, and pulls in dev/test dependencies (nltk, pytest). Then activate it and run the tests:

# Windows
. .\.venv\Scripts\Activate.ps1
pytest -v
# macOS/Linux
source .venv/bin/activate
pytest -v

Contributing

New modules are welcome. Add a package under src/ask/<name>/, cover it with tests, then open a PR.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_starter_kit-0.3.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_starter_kit-0.3.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file ai_starter_kit-0.3.1.tar.gz.

File metadata

  • Download URL: ai_starter_kit-0.3.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ai_starter_kit-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2c24998065c74d8acfb0de77d15c66e789bfcf7a7a3270d6b57daab0118e26c2
MD5 dc076b87ffbfd6d01c30bad566c885c3
BLAKE2b-256 809231b6b4ce78c3dc48171c38218276d310adcab5473e329d83e011b3f2ee97

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_starter_kit-0.3.1.tar.gz:

Publisher: release.yml on mikovilla/ai-starter-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_starter_kit-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: ai_starter_kit-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ai_starter_kit-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d100165fa9208b412424dd5f7627cc37d46197fde14543ff03ec98d3b5963f88
MD5 a6f174b8a8c51e487bc2a9ad84898bec
BLAKE2b-256 99e96b0339fab28b1248e43970cf1dfcc929bf97836eb61ca87075280ef16e71

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_starter_kit-0.3.1-py3-none-any.whl:

Publisher: release.yml on mikovilla/ai-starter-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page