Skip to content

Code chunking is not working due to recent tree-sitter api changes #483

@fpertl

Description

@fpertl

https://github.com/docling-project/docling-core/blob/ffe48dbe991bca46c8fb2e3e9b6447dbd4924731/docling_core/transforms/chunker/code_chunking/_utils.py#L157C1-L162C38

patching the _utils file with

...
from tree_sitter import Node, Tree, QueryCursor
...
def _query_tree(language, tree: Tree, query: str):
    """Query a tree-sitter tree with the given query string."""
    if not language:
        return []
    q = language.query(query)
    return QueryCursor(q).captures(tree.root_node)

seems to fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions