Source code for langchain_community.document_loaders.parsers.language.php
from typing import TYPE_CHECKING
from langchain_community.document_loaders.parsers.language.tree_sitter_segmenter import ( # noqa: E501
TreeSitterSegmenter,
)
if TYPE_CHECKING:
from tree_sitter import Language
CHUNK_QUERY = """
[
(function_definition) @function
(class_declaration) @class
(interface_declaration) @interface
(trait_declaration) @trait
(enum_declaration) @enum
(namespace_definition) @namespace
]
""".strip()
[docs]class PHPSegmenter(TreeSitterSegmenter):
"""Code segmenter for PHP."""
[docs] def get_language(self) -> "Language":
from tree_sitter_languages import get_language
return get_language("php")
[docs] def get_chunk_query(self) -> str:
return CHUNK_QUERY