Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
dipanjanS merged 2 commits into dipanjanS:master from ambientlight:patch-1
Jul 3, 2017

Conversation

@ambientlight
Copy link
Contributor

@ambientlight ambientlight commented Jul 2, 2017
edited
Loading

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.

Copy link
Owner

@dipanjanS dipanjanS left a 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.

dep_tree.draw()


'''
Copy link
Owner

@dipanjanS dipanjanS Jul 3, 2017

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.

ambientlight reacted with thumbs up emoji
Copy link
Contributor Author

@ambientlight ambientlight Jul 3, 2017

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

Copy link
Contributor Author

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

dipanjanS reacted with thumbs up emoji

@dipanjanS dipanjanS merged commit e31d6ff into dipanjanS:master Jul 3, 2017
Copy link
Owner

Merged, thanks for the update!

ambientlight reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@dipanjanS dipanjanS dipanjanS requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /