internals.py bugs fixed

31 views
Skip to first unread message

Dougal Graham

unread,
May 21, 2013, 9:29:21 PM5/21/13
to nltk...@googlegroups.com
Hi All,

I've discovered and fixed a few bugs in internals.py so that it should now correctly locate java on windows if users have set their path. I also found another small bug on lines 58-63 which I've fixed.

This code needs to be tested in Mac OS and Unix to ensure it works correctly. I've attached it here, because there doesn't seem to be a git repo or anything that I could find. If there is another place that I should post this, please let me know

Thanks and regards,

Dougal
internals.py

Alex Rudnick

unread,
May 22, 2013, 1:12:53 AM5/22/13
to nltk...@googlegroups.com
Hey Dougal,

Thanks for the contribution!

There is indeed a git repo -- it's on github!
https://github.com/nltk/nltk/

If you use github, would you open a pull request there? That would be
more convenient. (but if you're not into github, that's OK too --
we'll still take a look :) )

What's the other small bug?
Cheers!

--
-- alexr

Dougal Graham

unread,
May 22, 2013, 2:28:38 AM5/22/13
to nltk...@googlegroups.com
I am into github. I've never done a pull request, so not sure how that works, but I'll try to figure it out.

The bug was that the re.sub function was unclosed. The last line was accidentally in the comment of the previous line. Interestingly, this doesn't raise a parsing error, not sure why.

    return re.sub(r'''(?x)
        \\.           |  # Backslashed character
        \(\?P<[^>]*>  |  # Named group
        \(\?          |  # Extension group
        \(               # Grouping parenthesis''', subfunc, pattern)

Here, the comments look like they should be of the form (?# Commen...) and I'm not sure about the whitespace. I'm not exactly sure of the use-case for this, so it might be better for someone with more knowledge to test it. My attempt at a fix is:

    return re.sub(r'''(?x)
        \\.           |  (?# Backslashed character)
        \(\?P<[^>]*>  |  (?# Named group)
        \(\?          |  (?# Extension group)
        \(               (?# Grouping parenthesis)
        ''', subfunc, pattern)

Thank you very much,

Dougal
Reply all
Reply to author
Forward
0 new messages