Skip to main content

(N)Grams

bigrams

Simply create (N)grams: N ~ Bi | Tri ...

PyPI PyPI - Python Version PyPI - License HitCount

Welcome to bigrams, a Python project that provides a non-intrusive way to connect tokenized sentences in (N)grams. This tool is designed to work with tokenized sentences, and it is focused on a single task: providing an efficient way to merge tokens from a list of tokenized sentences.

It's non-intrusive as it leaves tokenisation, stopwords removal and other text preprocessing out of its flow.


Source Code: https://github.com/proteusiq/bigrams

PyPI: https://pypi.org/project/bigrams/


Installation

pip install -U bigrams

Usage

To use bigrams, import it into your Python script, and use scikit-learn-ish API to transform your tokens.

from bigrams import Grams

# expects tokenised sentences
in_sentences = [["this", "is", "new", "york", "baby", "again!"],
              ["new", "york", "and", "baby", "again!"],
            ]
g = Grams(window_size=2, threshold=2)

out_sentences = g.fit_transform(in_stences)
print(out_sentences)
# [["this", "is", "new_york", "baby_again!"],
#   ["new_york", "and", "baby_again!"],
#  ]

Development

  • Clone this repository
  • Requirements:
  • Create a virtual environment and install the dependencies
poetry install
  • Activate the virtual environment
poetry shell

Testing

pytest

Pre-commit

Pre-commit hooks run all the auto-formatters (e.g. black, isort), linters (e.g. mypy, flake8), and other quality checks to make sure the changeset is in good shape before a commit/push happens.

You can install the hooks with (runs for each commit):

pre-commit install

Or if you want them to run only for each push:

pre-commit install -t pre-push

Or if you want e.g. want to run all checks manually for all files:

pre-commit run --all-files

Contributing are welcome

ToDo:

  • create a save & load function
  • compare it with gensim Phrases
  • write replacer in Rust - PyO3

Metadata

Release files for bigrams 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bigrams 0.1.2
File Size Uploaded Provenance Actions
bigrams-0.1.2.tar.gz 5.2 kB Without provenance Details for bigrams-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bigrams 0.1.2
File Interpreter ABI Platform Actions
bigrams-0.1.2-py3-none-any.whl Python 3 none any Details for bigrams-0.1.2-py3-none-any.whl

Total release size: 9.7 kB

Release files / bigrams-0.1.2.tar.gz

Download URL bigrams-0.1.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d05f4c48bfb9e53e29cec1f7cc39b8b8713c0937eba1b86623d59d98e1652d2e
BLAKE2b-256 checksum
How to use checksums
2d561509e8754aef4014a37041c2ab5f4070fd4cc1f07e65f32cb2785cfb9903
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.10.6 Linux/5.15.0-58-generic

Release files / bigrams-0.1.2-py3-none-any.whl

Download URL bigrams-0.1.2-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8859c06af9bd7afaefcee72c5c1db830173dbb26df76a6389d52a0801fdfc45
BLAKE2b-256 checksum
How to use checksums
ca5dda902072a88be792a359253d4fa47016a113ec50da126b024f57da1368f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.10.6 Linux/5.15.0-58-generic

Security for bigrams 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page