Treesearch
Pattern matching for dependency treebanks.
⚠️ Early Stage: This project is under active development. The API and query language will change as we refine the design.
Overview
Treesearch finds syntactic patterns in dependency-parsed corpora. It reads treebanks in CoNLL-U format and returns all sentences matching a specified structural pattern. Designed for corpus linguistics research on large treebanks with automatic parallel processing for multi-file operations.
Installation
From PyPI
Requires Python 3.12+.
pip install treesearch-ud
# Optional: Install with visualization support (displaCy)
pip install treesearch-ud[viz]
From Source
Requires Python 3.12+ and Rust toolchain.
# Clone repository
git clone https://github.com/rmalouf/treesearch
cd treesearch
# Install with uv (recommended)
uv pip install -e .
# Or with pip
pip install maturin
maturin develop
Quick Example
Find passive constructions in an English treebank:
import treesearch
# Parse a pattern for passive voice
pattern = treesearch.compile_query("""
MATCH {
V [upos="VERB"];
Aux [lemma="be"];
V -[aux:pass]-> Aux;
}
""")
# Search a single file
for tree, match in treesearch.search("corpus.conllu", pattern):
verb = tree.word(match["V"])
print(f"{verb.form}: {tree.sentence_text}")
Search multiple files with automatic parallel processing:
# Glob pattern for multiple files
for tree, match in treesearch.search("data/*.conllu", pattern):
verb = tree.word(match["V"])
print(f"{verb.form}: {tree.sentence_text}")
# Or use the object-oriented API
treebank = treesearch.load("data/*.conllu")
for tree, match in treebank.search(pattern):
verb = tree.word(match["V"])
print(f"{verb.form}: {tree.sentence_text}")
Pattern Language
Patterns specify structural constraints on dependency trees:
MATCH {
Verb [upos="VERB" & lemma="help"];
Obj [upos="NOUN"];
Verb -[obj]-> Obj;
}
Node constraints: upos, xpos, lemma, form, deprel, feats.* (morphological features), misc.* (miscellaneous features); values are "literals" or /regexes/, combined with &, |, !=, and parentheses
Edge constraints: -> (child), -[label]-> (labeled edge), -/regex/-> (regex edge), !-> (negative), !-[label]-> (negative labeled), !-/regex/-> (negative regex)
Precedence: < (immediately precedes), << (precedes), <n< (precedes within n words, e.g. <3<)
EXCEPT blocks: Reject matches where a condition is true (negative existential)
OPTIONAL blocks: Extend matches with additional bindings if possible
Data Format
Reads treebanks in CoNLL-U format. Supports plain text (.conllu), gzip-compressed (.conllu.gz), and zstd-compressed files (.conllu.zst) with automatic decompression.
Documentation
- docs/api.md - Complete Python API reference
- RELEASING.md - CI workflows and release process (maintainers)
- GitHub repository - Source code and issue tracker
License
MIT
Citation
If you use Treesearch in your research, please cite:
@software{treesearch,
author = {Malouf, Robert},
title = {Treesearch: Pattern matching for dependency treebanks},
year = {2025},
url = {https://github.com/rmalouf/treesearch}
}
Metadata
Release files for treesearch-ud 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| treesearch_ud-0.3.1.tar.gz | 246.7 kB | Details |
Built distributions (wheels)
Total release size: 37.6 MB
Release files / treesearch_ud-0.3.1.tar.gz
| Download URL | treesearch_ud-0.3.1.tar.gz |
|---|---|
| Size | 246.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2248137966ac1fa2698edf34eaf9135bfeff237a24b57be175ee7a21f42aa3bd
|
|
BLAKE2b-256 checksum How to use checksums |
113f7c2411e811ef4ecaedca2e3785b19b8c1f69bff5fb10dc00f332acd712a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp314-cp314t-manylinux_2_34_x86_64.whl
| Download URL | treesearch_ud-0.3.1-cp314-cp314t-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 8.2 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
391ef4b28dd5d531e97d046197194253b16ccf2f403b27177530531ef846ea2a
|
|
BLAKE2b-256 checksum How to use checksums |
23df5b994becf8ce8931c4de756f66e291649e135b98e9ede6754862fccff2d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | treesearch_ud-0.3.1-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fb77f7f995acefd2e7b1ab2bcdaf9bfe511bf5ab093cf09313701e78a529a1c2
|
|
BLAKE2b-256 checksum How to use checksums |
720ca4347f61b047e5336cca857dd2790754752e157b52e35ccdf8ef50d4c890
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp313-cp313t-manylinux_2_34_x86_64.whl
| Download URL | treesearch_ud-0.3.1-cp313-cp313t-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 8.2 MB |
| Tags | CPython 3.13 CPython 3.13 free-threading Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
9d8bfba78fc4f5df3942faca25b243f62361129d8c1a9638bb4a72995c9864a1
|
|
BLAKE2b-256 checksum How to use checksums |
ed7d4da7778545dc45b10b6026188783dc5b7f3969d74765a4248e699c526792
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp313-cp313t-macosx_11_0_arm64.whl
| Download URL | treesearch_ud-0.3.1-cp313-cp313t-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.13 CPython 3.13 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b3a679aa53385ec3566ec9f80dfff60ad7ce21719ab81d6902962ec738e6cd6a
|
|
BLAKE2b-256 checksum How to use checksums |
0939e29d4be05da38f5e1a67d9036c2ef6a8fc7dc0b19e132c851077918400b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp312-abi3-win_amd64.whl
| Download URL | treesearch_ud-0.3.1-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4f1239b005cd7b0c8fa6c8f3fd86e1f4ab7c39ae2feb6dc3595cdcfcc6fea582
|
|
BLAKE2b-256 checksum How to use checksums |
a6100c65a271bb3caba9ac7f39c93b1b6400ca80463634b5007ae89ff772ddd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | treesearch_ud-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 8.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0e0be68c1bd6993c6671c38b08496b9fb9264be47da414124ff3d2d45942e349
|
|
BLAKE2b-256 checksum How to use checksums |
137eeae92fa27813632c7e34021b6473d7f706b859960f88083e12284063d900
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | treesearch_ud-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8c092a8cda8c996d28659c8511bb4d0ac52678b46bf74e64315250c8c2d62bec
|
|
BLAKE2b-256 checksum How to use checksums |
75ae337f6cd27e70fd641f2a03c5ef53a8c1bf4c5a1f27c1310e22fe9f4dbf9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | treesearch_ud-0.3.1-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b3a70bf744fe5f32288cf63de08268041382e8d2697622e7b58fa07ca5e185a3
|
|
BLAKE2b-256 checksum How to use checksums |
b096a12ec2dda05c155dea8abe452688eeabe21f4818deddeb62f32fcb2f7634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / treesearch_ud-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | treesearch_ud-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
74a14944e3859d3cede33f708a9d15a3d8f04dbc66ad2ed6794f6408aeb099c1
|
|
BLAKE2b-256 checksum How to use checksums |
2a01b61785108726cf02d6d69f4a95d4f0ed93e7069520802c25fc74e0d480b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency log