Skip to content
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

Add a setup.py file #2

Open
timvieira opened this issue Aug 31, 2016 · 5 comments
Open

Add a setup.py file #2

timvieira opened this issue Aug 31, 2016 · 5 comments
Assignees

Comments

@timvieira
Copy link

timvieira commented Aug 31, 2016

Thanks for the great package. In an effort to make the package easier to use, I'd strongly recommend making it a python package by simply adding a setup.py file, which should (minimally) look like:

from setuptools import setup
setup(name='berkeley_parse_analyser',
      version='1.0',
      author='Jonathan Kummerfeld',
      description='A tool for classifying mistakes in the output of parsers',
      packages=['berkeley_parse_analyser'])

Note: It's conventional rename the src directory to the name of the project, e.g., berkeley_parse_analyser.

It would also be a good idea to run this code through pylint and the pep8 coding style checker (which pylint will do for you).

@jkkummerfeld
Copy link
Owner

Thanks for the suggestion! I followed your suggestions to make this change, and started making fixes as recommended by pylint. There are many more to address (and in an ideal world I would also make this python 3 compatible), but that will have to wait for another day.

@timvieira
Copy link
Author

Awesome! Thanks for replying so quickly :-D I'm glad you like the suggestions. Another one I'd recommend is using python classes instead of dicts for storing info, e.g. here

def gen_missing_successor(ctree, error):
    # ...
    info = {
        'type': 'add',
        'label': get_label(nnode),
        'span': nnode.span,
        'subtrees': [get_label(subtree) for subtree in nnode.subtrees],
        'parent': nnode.parent.label,
        # etc...
    }
    # ...

Becomes:

class Transform:
    def __init__(self, nnode, ttype)
        self.type = ttype
        self.label = get_label(nnode)
        self.span = nnode.span
        self.subtrees = [get_label(subtree) for subtree in nnode.subtrees]
        self.parent = nnode.parent.label
        # etc...

def gen_missing_successor(ctree, error):
    # ...
    info = Transform(nnode, ttype='add')
    # ...

@jkkummerfeld
Copy link
Owner

Yeah... that was definitely a case of a quick and dirty solution that grew and grew.

@timvieira
Copy link
Author

Ha! I know that phenomena all too well. Using dictionaries that way is very "Perl style" (as is quick 'n dirty). I thought maybe you were be a Perl hacker writing Python.

@jkkummerfeld
Copy link
Owner

I've written practically no Perl actually, but with sufficiently little effort poor programming style can be achieved in any language :)

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

No branches or pull requests

2 participants