Parsing sentences with Link Grammar and Python

This is my PyCon 2012 talk on parsing sentences with Link Grammar and Python

About these ads

12 Responses to “Parsing sentences with Link Grammar and Python”


  1. 1 Duncan McGreggor April 1, 2012 at 3:54 am

    Hey Jeff, I chaired your session and wanted to remind you of my offer: to host the AJAX app on a DreamHost server.

    If you can get permission to release the source code, provide some basic setup/install info, then I can get this puppy running on a public ip address for you.

    Let me know!

    • 2 Jeff Elmore April 10, 2012 at 11:08 am

      Hey Duncan, thanks for following up!

      My apologies for the delay in responding. Things have been a bit crazy around here. I am working on separating the Link Grammar portion of the project so we can deploy it. We may host it ourselves, but if not I will definitely hit you up.

      Thanks again.!

  2. 3 yarkot April 7, 2012 at 4:27 pm

    Hey Jeff –

    Thanks for your presentation at PyCon2012. You were going to look into making your localhost “lexile lab” available. Any progress on that?

    • 4 Jeff Elmore April 10, 2012 at 11:09 am

      We are working on separating the components that we can release publicly.

      I’ll make a post on this blog when we put something up!

  3. 5 Alok October 4, 2013 at 12:37 am

    Hi Jeff,

    Thanks for the talk. It was very accessible, which is something I find as a culture in the python community! Can you please share the slides for this talk?

    Thanks

  4. 6 Alok October 4, 2013 at 12:59 am

    Hi Jeff,

    In your presentation, you briefly mentioned “common coverage link grammar” for efforts in enhancing Link Grammars based on training data as opposed to hand-crafted rules. I have not been able to find much on this. Could you please provide some pointers to more information on this?

    Thanks

  5. 8 Hesham A. Amin October 4, 2013 at 1:32 pm

    Thanks for the good introduction to link grammar.
    I have a question: is it possible to traverse the parse tree using pylinkgrammar? because it seems that Linkage and Link objects contain links and words as strings not as pointers or references to other sentences.

    thanks

    • 9 Jeff Elmore October 9, 2013 at 3:46 pm

      You can access a nested constituent phrase structure from a Linkage object like so:

      >>> from pylinkgrammar.linkgrammar import Parser
      >>> p = Parser()
      >>> linkage = p.parse_sent('The quick brown fox jumped over the lazy dog.')[0]
      >>> linkage.constituent_phrases_nested

      For some reason, WordPress won’t display the result, but basically it’s a nested list of lists with the constituent phrases. Try it and let me know if you run into any problems.

      • 10 Hesham A. Amin December 12, 2013 at 3:06 pm

        Thanks Jeff.
        This displays the constituent structure, but it lacks some important information that exists in the linkage like whether a noun is a subject or object etc.
        For example:
        in the constituent structure generated: (NP The quick brown fox) and (NP the lazy dog) both means that these phrases are Noun Phrases.
        But linkages show more information: “the quick.a brown.a fox” is linked to the verb “jumped” using the “Ss” link which means it’s a subject. (http://www.link.cs.cmu.edu/link/dict/section-S.html)
        while “the lazy dog” is conencted to “Js” which means it’s an object (http://www.link.cs.cmu.edu/link/dict/section-J.html).
        The Linkage objects generated in the python library have the links in form of strings so it’s tricky to use them.

      • 11 Jeff Elmore December 26, 2013 at 4:09 pm

        Ahh, I think I understand your question now.

        Link Grammar can’t be transversed like a tree because it doesn’t have a head node. It is just a collection of links that meet certain criteria. It might be possible to bring some more of the “link” information into the tree structure of the constituent data structure, but that seems non-trivial to me (and I’m not the developers of Link Grammar, just the Python bindings).

        You can, of course, access all of the link information through the Linkage and Link objects, like:

        from pylinkgrammar.linkgrammar import Parser
        p = Parser()
        l = p.parse_sent('The quick brown fox jumps over a lazy dog.')[0]
        print l.links
        

        This yields

        [Link: LEFT-WALL-Xp-.,
         Link: LEFT-WALL-Wd-fox.n,
         Link: the-D-Ds-fox.n,
         Link: quick.a-A-fox.n,
         Link: brown.a-A-fox.n,
         Link: fox.n-Ss-jumps.v,
         Link: jumps.v-MV-MVp-over,
         Link: over-J-Js-dog.n,
         Link: a-Ds-dog.n,
         Link: lazy.a-A-dog.n,
         Link: .-RW-RIGHT-WALL]
        

        You can access the left link, right link, left word, right word, etc. from the Link object.

    • 12 Jeff Elmore December 27, 2013 at 2:29 am

      I’ve thought about it some more since my last comment. I see what you’re asking for now..

      Unfortunately, the way the bindings are written now, what you get from the C library is just the words, not like an index or something which would allow you to link to the specific words. Which is bad, because then if you have the same word twice, you don’t know which word is which.

      Obviously the library has this information since it can produce the parse tree diagram.

      It’s definitely something worth looking into. I haven’t been doing as much lately with LinkGrammar, but I would be happy to entertain a pull request. Here is the public repo: https://bitbucket.org/metametrics/pylinkgrammar/

      Hope this helps!

      Sorry to not be able to provide more.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Twitter-feed


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: