-
Notifications
You must be signed in to change notification settings - Fork 852
Graphviz code for Fig 3-4 generation #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ambientlight This looks interesting. Is it working with the data I had used in this book? Would be great if you could show a sample snapshot. Other than that please check out the review comment I posted in your code. Uncomment it out and remove the quotes. It is alright to directly put the code snippet in the file. Let me know once you do this, I will merge the PR.
Chapter-3/dependency_parsing.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you uncomment this and send the pull request. If this is working, its ok to put the code snippet directly in the main file. No need to put it in quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dipanjanS that should be it
Is it working with the data I had used in this book?
Sure here is the exact code I am using:
import os
import nltk
from nltk.parse.stanford import StanfordDependencyParser
from nltk.parse.stanford import StanfordParser
from spacy.en import English
from graphviz import Source
os.environ['CLASSPATH'] = r'/usr/local/Cellar/stanford-parser/3.6.0/libexec'
sentence = 'The brown fox is quick and he is jumping over the lazy dog'
# dependency tree printing
sdp = StanfordDependencyParser()
result = list(sdp.raw_parse(sentence))
dep_tree_dot_repr = [parse for parse in result][0].to_dot()
source = Source(dep_tree_dot_repr, filename="dep_tree", format="png")
source.view()
and the result:
dep_tree
Merged, thanks for the update!
Uh oh!
There was an error while loading. Please reload this page.
It would be great for readers to see how to generate annotated dependency tree in Fig 3-4.
This is also related to https://stackoverflow.com/a/44867616/2380455, where installation of dependencies has been presented for os x.