Skip to main content

Treesearch

PyPI

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)

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

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.0

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

Source distribution (sdist)

Source distribution for treesearch-ud 0.3.0
File Size Uploaded
treesearch_ud-0.3.0.tar.gz 244.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for treesearch-ud 0.3.0
File
treesearch_ud-0.3.0-cp314-cp314t-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.34+ x86-64 Details
treesearch_ud-0.3.0-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details
treesearch_ud-0.3.0-cp313-cp313t-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 free-threading Linux glibc 2.34+ x86-64 Details
treesearch_ud-0.3.0-cp313-cp313t-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 free-threading macOS 11.0+ ARM64 Details
treesearch_ud-0.3.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
treesearch_ud-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details
treesearch_ud-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details
treesearch_ud-0.3.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
treesearch_ud-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 37.3 MB

Release files / treesearch_ud-0.3.0.tar.gz

Download URL treesearch_ud-0.3.0.tar.gz
Size 244.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f78c3ae69e8459af379c9cb184ea4cbb5f8d8f53676643133525cad2faa186a6
BLAKE2b-256 checksum
How to use checksums
daaacffe61d74cabffecbcc720fe5d4a384c9fd19d4b695b520a6e9a02ebb3bc
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp314-cp314t-manylinux_2_34_x86_64.whl

Download URL treesearch_ud-0.3.0-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
b075c0de60079e8b0743156bcac72a2c1cbf23513d4aaef3a916e3b487ae0589
BLAKE2b-256 checksum
How to use checksums
57b7855089a063f1e6f5b9fefb143fb7adb30ab7ef070ed2d9933b946bf7a726
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp314-cp314t-macosx_11_0_arm64.whl

Download URL treesearch_ud-0.3.0-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
de756ef61162c3dcfbbd8fd68e823df8ffe88574c34c5d11ed5828ebd4a6cc76
BLAKE2b-256 checksum
How to use checksums
fa8976111a8c103baade88ccbf91c0b47498f444a7cb7587bfecf5d743bc3cc7
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp313-cp313t-manylinux_2_34_x86_64.whl

Download URL treesearch_ud-0.3.0-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
f0d640be01c788e6cc8459aa419814b3e214cd95d6e270f6462d1c2463c3fc43
BLAKE2b-256 checksum
How to use checksums
8ae92e1c3f37d7543ffc95757c7c2397b8f51d20566103fa98ba836e4892e12c
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp313-cp313t-macosx_11_0_arm64.whl

Download URL treesearch_ud-0.3.0-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
13dc4c67bd2697d964d666fcecb0afad8a35f7dec8671072907c41ad0964fda3
BLAKE2b-256 checksum
How to use checksums
afcd6e88333a9ac6467490f225283f60b45ee114d7dae7b850b93076991b936d
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp312-abi3-win_amd64.whl

Download URL treesearch_ud-0.3.0-cp312-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a066ca435fec9ce42ad1d3b5c72d1f4d98be6aac76d6fb2cb73389af9e41297a
BLAKE2b-256 checksum
How to use checksums
43a7c1d0c777efba5fca4ee7e23801585f23c8bc79e5f1b958d1466e345c8799
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL treesearch_ud-0.3.0-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
d838e0bf974527da8e3ee31093cc172873f7a802d2b28accaf502086c31948bc
BLAKE2b-256 checksum
How to use checksums
97d977a419b158cd8f0629570038472b4f1a31099f94f916762bab0ec54db41e
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL treesearch_ud-0.3.0-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
4a6396fe544627f325261902c2e417566a399dca0002863f6be2d8702311fe0e
BLAKE2b-256 checksum
How to use checksums
292ee7ed1ccc3316d96ab24e952088e75f268d6b5e00865bde3ffcf814136b19
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL treesearch_ud-0.3.0-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
5050b0cb003e748a3e7a2743c50ab6a4585e7cef0baab1639afa79adc6abdf10
BLAKE2b-256 checksum
How to use checksums
baae2f4a7385b794abba06dcc146c31cf7133ab970f21ace1cbcd7c8727170b7
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 Sep 23, 2026.

Transparency log

Release files / treesearch_ud-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL treesearch_ud-0.3.0-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
40ce75a9406dec456e89ece694eaeca13210c5d71cd66778f2fdd4d8af5b9ffe
BLAKE2b-256 checksum
How to use checksums
9751fab8a145d8a71dfae6c72a94af00ceccdbe1ce5f115c9fd1e34bc51fc8c3
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 Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

10 release files

0.2.1

6 release files

0.2.0

8 release files

0.1.0

6 release files

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