code: def rule_based_demo():
      from nltk.grammar import DependencyGrammar
  
      grammar = DependencyGrammar.fromstring(
          """
      'taught' -> 'play' | 'man'
      'man' -> 'the' | 'in'
      'in' -> 'corner'
      'corner' -> 'the'
      'play' -> 'golf' | 'dachshund' | 'to'
      'dachshund' -> 'his'
      """
      )
      print(grammar)
      ndp = NonprojectiveDependencyParser(grammar)
      graphs = ndp.parse(
          [
              "the",
              "man",
              "in",
              "the",
              "corner",
              "taught",
              "his",
              "dachshund",
              "to",
              "play",
              "golf",
          ]
      )
      print("Graphs:")
      for graph in graphs:
          print(graph)
  
imports: import logging
  import math
  from nltk.parse.dependencygraph import DependencyGraph
label_desc: Use image node_id 4 for calling a global function with example usage: rule_based_demo() without return types