Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

graph - How do I use Tree Isomorphic to solve language pattern matching?

In Algorithm Design Manual, it says

Are you testing whether two trees are isomorphic? – Faster algorithms exist for certain special cases of graph isomorphism, such as trees and planar graphs. Perhaps the most important case is detecting isomorphisms among trees, a problem that arises in language pattern matching and parsing applications. A parse tree is often used to describe the structure of a text; two parse trees will be isomorphic if the underlying pair of texts have the same structure.

I just wish someone please give me an example that how to use Tree Isomorphism to solve language pattern matching problem. i.e., how can I map language pattern matching to a tree isomorphism problem?

Normally, how do I construct a string or text as a tree and compare their identities?

Thanks

like image 668
Jackson Tale Avatar asked Oct 07 '22 21:10

Jackson Tale


1 Answers

Using English as an example, the idea is that some English sentences can be represented by the following parse trees:

        SENTENCE               SENTENCE
       /        \             /        \
  PROPER NOUN  VERB      COMMON NOUN  VERB
      /                    /    \
     NAME                ARTICLE NOUN

The English phrase "The dog barks." can then be parsed as follows

ARTICLE    NOUN      VERB
 /          /         /
The       dog       barks

    COMMON NOUN
     /      \
ARTICLE    NOUN      VERB
 /          /         /
The       dog       barks


            SENTENCE
             /     \
    COMMON NOUN     \
     /      \        \
ARTICLE    NOUN      VERB
 /          /         /
The       dog       barks

Another sentence with the same structure is "A leaf falls." Its parse tree would look to have the same shape, which means that the two parse trees would be isomorphic. That is, they have the same logical structure as a sentence even though the meaning is different.

            SENTENCE
             /     \
    COMMON NOUN     \
     /      \        \
ARTICLE    NOUN      VERB
 /          /         /
A         leaf      falls

Both parse trees are also isomorphic to the general pattern, also represented as a tree, if you ignore the actual physical words.

like image 116
Antti Huima Avatar answered Oct 31 '22 13:10

Antti Huima