xTrAct-NLP: A Code Query and Embedding Toolkit
xTrAct-NLP is a toolkit designed to process codebases, generate embeddings from code chunks, and retrieve relevant snippets using natural language queries. It uses state-of-the-art models to create meaningful embeddings and facilitates sophisticated query expansion and ranking mechanisms. This project is especially useful for developers looking to integrate NLP into code search engines.
Features
- Code Parsing: Supports code parsing using AST to extract functions and classes as code chunks.
- Embedding Generation: Generates embeddings from code chunks using HuggingFace models (e.g., CodeBERT, T5).
- Query Expansion: Automatically expands natural language queries with relevant technical terms using language models.
- Reranking: Supports BM25 and cosine similarity-based ranking for more relevant code retrieval.
- Visualization: Supports both scatter plots (for PCA and t-SNE) and heatmaps to visually analyze and compare code embeddings.
Installation
pip install xtract-nlp
For development:
git clone https://github.com/ooojustin/xTrAct-NLP.git
cd xTrAct-NLP
pip install -e .
Usage
CLI Usage
-
Process Codebase:
xtract process <path_to_codebase>
-
Generate Embeddings:
xtract generate -
Query the Codebase:
xtract query "parse python code using ast"
Python Library Usage
from xtract.core import process_code, generate_embeddings, query_code
# Process codebase
num_chunks = process_code("/path/to/codebase")
# Generate embeddings
num_embeddings = generate_embeddings()
# Query codebase
results = query_code("parse python code using ast")
License
This project is licensed under the MIT License. See the LICENSE for more details.
Metadata
Release files for xtract-nlp 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xtract_nlp-0.1.2.tar.gz | 82.2 kB | Without provenance | Details for xtract_nlp-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xtract_nlp-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for xtract_nlp-0.1.2-py3-none-any.whl |
Total release size: 94.6 kB
Release files / xtract_nlp-0.1.2.tar.gz
| Download URL | xtract_nlp-0.1.2.tar.gz |
|---|---|
| Size | 82.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93485b5dee549a58ee84c3a67b20782476cb40df5f9aba7f21c85e673ffbd658
|
|
BLAKE2b-256 checksum How to use checksums |
25cec3dc7f79a4f53d02b4d1b86e5b5440645a62eb8fc3de9237f4a9fe667cd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / xtract_nlp-0.1.2-py3-none-any.whl
| Download URL | xtract_nlp-0.1.2-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d96bb182f503a0c61e7a3ea098aa9b24e2738e4a7cdadcae2df73a5aefa9da7e
|
|
BLAKE2b-256 checksum How to use checksums |
047433dd43b3c7215b3df354d58b60716405a5a2c987fba6224f9582d85263eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for xtract-nlp 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.