title: Constituent tree in Python (NLTK)
body: <p>I have found this code <a href="https://www.geeksforgeeks.org/syntax-tree-natural-language-processing/" rel="nofollow noreferrer">here</a>:</p>
  <pre><code># Import required libraries 
  import nltk 
  nltk.download('punkt') 
  nltk.download('averaged_perceptron_tagger') 
  from nltk import pos_tag, word_tokenize, RegexpParser 
     
  # Example text 
  sample_text = &quot;The quick brown fox jumps over the lazy dog&quot;
     
  # Find all parts of speech in above sentence 
  tagged = pos_tag(word_tokenize(sample_text)) 
     
  #Extract all parts of speech from any text 
  chunker = RegexpParser(&quot;&quot;&quot; 
                         NP: {&lt;DT&gt;?&lt;JJ&gt;*&lt;NN&gt;}    #To extract Noun Phrases 
                         P: {&lt;IN&gt;}               #To extract Prepositions 
                         V: {&lt;V.*&gt;}              #To extract Verbs 
                         PP: {&lt;P&gt; &lt;NP&gt;}          #To extract Prepostional Phrases 
                         VP: {&lt;V&gt; &lt;NP|PP&gt;*}      #To extarct Verb Phrases 
                         &quot;&quot;&quot;) 
    
  # Print all parts of speech in above sentence 
  output = chunker.parse(tagged) 
  print(&quot;After Extracting\n&quot;, output) 
  </code></pre>
  <p>As I understand, this code defines PP, NP and VP... My doubt is that the syntactic tags are already defined <a href="https://catalog.ldc.upenn.edu/docs/LDC95T7/cl93.html" rel="nofollow noreferrer">here</a>. Aren't these composed tags defined in NLTK? Is that the point? Furthermore, in the last row of the chunker <code>{&lt;V&gt; &lt;NP|PP&gt;*}</code>, is it using the above-defined <code>NP: {&lt;DT&gt;?&lt;JJ&gt;*&lt;NN&gt;}</code> and <code>PP: {&lt;P&gt; &lt;NP&gt;}</code>?</p>