code: def roget_graph():
      """Return the thesaurus graph from the roget.dat example in
      the Stanford Graph Base.
      """
      # open file roget_dat.txt.gz
      fh = gzip.open("roget_dat.txt.gz", "r")
  
      G = nx.DiGraph()
  
      for line in fh.readlines():
          line = line.decode()
          if line.startswith("*"):  # skip comments
              continue
          if line.startswith(
              " "
          ):  # this is a continuation line, append
              line = oldline + line
          if line.endswith(
              "\\\n"
          ):  # continuation line, buffer, goto next
              oldline = line.strip("\\\n")
              continue
  
          (headname, tails) = line.split(":")
  
          # head
          numfind = re.compile(
              r"^\d+"
          )  # re to find the number of this word
          head = numfind.findall(headname)[0]  # get the number
  
          G.add_node(head)
  
          for tail in tails.split():
              if head == tail:
                  print(
                      "skipping self loop", head, tail, file=sys.stderr
                  )
              G.add_edge(head, tail)
  
      return G
  
imports: import gzip
  import re
  import sys
  import matplotlib.pyplot
  import networkx
label_desc: Use image node_id 1 for calling a global function with example usage: roget_graph() and returns: G