I just started programming and I'm trying to follow along in this book: "Natural Language Processing with Python (2009)," but I can't seem to find a solution to this error. I think this graph_viz issue has been discussed before, but I'm also aware that the rules of syntax can change. It's supposed to show a cool-looking visualization. Is this a module or syntax problem?
import networkx as nx
import matplotlib
from nltk.corpus import wordnet as wn
def traverse(graph, start, node):
graph.depth[node.name] =
node.shortest_path_distance(start)
graph.add_edge(node.name, child.name)
traverse(graph, start, child)
def hyponym_graph(start):
G = nx.Graph()
G.depth = {}
traverse(G, start, start)
return G
def graph_draw(graph):
nx.draw_graphviz(graph,
node_size = [16 * graph.degree(n) for n in graph],
node_color = [graph.depth[n] for n in graoh],
with_labels = False)
matplotlib.pyplot.show()
dog = wn.synset('dog.n.01')
graph = hyponym_graph(dog)
graph_draw(graph)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in graph_draw
AttributeError: module 'networkx' has no attribute 'draw_graphviz'