Skip to main content

keylexbundles

keylexbundles provides a Python function compute_keyness to compute 4-gram lexical bundle keyness between a target and a reference corpus.


Install and Usage

First, to install keylexbundles, use pip in terminal:

pip install keylexbundles

Once installed, import the package in your python code by running the following code:

import keylexbundles

Once imported, call the function with two required arguments: target_path and reference_path and an optional arguement output_file:

keylexbundles.compute_keyness(target_path="data/target/", reference_path="data/reference/", output_file="output.csv")
argument Description
target_path Folder/directory with .txt files for a target corpus
reference_path Folder/directory with .txt files for a target corpus
output_file (Optional) Name of the CSV file to save results to. Defaults to "output.csv".

Features

  • Accepts two folders that contain .txt files for a target corpus and a reference corpus
  • Extracts 4-gram bundles (contiguous sequences of 4 tokens)

Computes:

  • Whole-corpus frequency keyness: log-likelihood (G²) using raw whole-corpus token counts
  • Text dispersion keyness: log-likelihood (G²) using text dispersion (i.e., the number of texts in which a bundle occurs)
  • Mean text frequency keyness: Cohen's d (standardized difference of mean normalized per-text frequencies)

Outputs a CSV with metrics below, sorted primary by text dispersion keyness and secondary by raw whole-corpus token counts in a target corpus


Output CSV Columns

Column Description
lexical bundle Lexical bundle
whole-corpus frequency keyness Log-likelihood (G²) based on whole-corpus frequency
text dispersion keyness Log-likelihood (G²) based on text dispersion
mean text frequency keyness Cohen's d
raw frequency (target) token count in target corpus
normed frequency (target) token frequency per 1,000 words in target corpus
text dispersion (target) Number of texts where bundle appears in target corpus
mean of normed frequency (target) Mean per-text normalized frequency in target corpus
sd of normed frequency (target) Standard deviation of per-text normalized frequency in target corpus
raw frequency (reference) raw token count in reference corpus
normed frequency (reference) token frequency per 1,000 words in reference corpus
text dispersion (reference) Number of texts where bundle appears in reference corpus
mean of normed frequency (reference) Mean per-text normalized frequency in reference corpus
sd of normed frequency (reference) Standard deviation of per-text normalized frequency in reference corpus

Citation

If you use keylexbundles in your research, please cite it as:
Larsson, T., Kim, T., & Egbert, J. (2025). Introducing and comparing two techniques for key lexical bundles analysis. Research Methods in Applied Linguistics, 4(3), 100245. https://doi.org/10.1016/j.rmal.2025.100245

Metadata

Release files for keylexbundles 0.1.3

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

Source distribution (sdist)

Source distribution for keylexbundles 0.1.3
File Size Uploaded Provenance Actions
keylexbundles-0.1.3.tar.gz 6.5 kB Without provenance Details for keylexbundles-0.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 13.7 kB

Release files / keylexbundles-0.1.3.tar.gz

Download URL keylexbundles-0.1.3.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
52c6c018d6a4f0aafee36371b14a058a40a9484247d970df745ece759ab62230
BLAKE2b-256 checksum
How to use checksums
b809eb93747ddabe14370e06896f5c5058eb294dd8862da93172dcb621ea7752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / keylexbundles-0.1.3-py3-none-any.whl

Download URL keylexbundles-0.1.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
667d54fcba11555b70a3e516de6f83ae8793a8a0d2978223bf804555593f267f
BLAKE2b-256 checksum
How to use checksums
32fd8ca9df382ebbc5158f341ad0a008f9eae283c3eb6bd48e30749d55fefcff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Security for keylexbundles 0.1.3

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.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

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