Tree matching algorithm?

I am working on a tree library and part of the necessary functionality to be able to search for node for child nodes matching the pattern.

A “template” is a specification (or criterion) that defines the structure as well as the attributes of the nodes in the subtree (s) to be matched.

For example, suppose a tree represents data on a particular bird species. Further, suppose that the nodes of such a tree have the following attributes:

  • a place
  • sex
  • Wingspan
  • weight
  • brood_size

Given the parent node, I would like to search in plain English:

“Bring me all the male birds that are descendants of this bird and live in a city of XXX and weighs> 100 g. Any bird found must also have at least 2 brothers and one sister and must have at least one child”

<note>

Just to clarify, I do not expect that I can request simple English, as I did above. I used a "simple English query" to illustrate the type of correspondence that I would like to execute on a tree. I fully expect to use characters to match (as opposed to plain text) in practice.

</note>

. , node, , , , , - , supersets .., , - - .

- , () node ?

, Python. , ( ), .

+5
2

. , , , . .

, Google Scholar . .

EDIT: , , XPath . XML - , XPath , , .

, (, PyLucene - , , , ).

+2

Lisp Sexpression ? a node. , . Sexpressions .

node, A, - , X, 1 A:

(?root A ? (X 1 A))

; Lisp .

Lisp ( , ), 20 : http://norvig.com/paip/patmatch.lisp

, . , LISP.

+4

All Articles