Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compare50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(self, option_strings, dest=argparse.SUPPRESS, default=argparse.SUPP
def __call__(self, parser, namespace, values, option_string=None):
indentation = " " * 4
for pass_ in _data.Pass._get_all():
print(str(pass_.__name__))
print(str(pass_.__name__), f"(default: {'ON' if pass_.default else 'OFF'})")
for line in textwrap.wrap(pass_.__doc__ or "No description provided", 80 - len(indentation)):
print("{}{}".format(indentation, line))
parser.exit()
Expand Down Expand Up @@ -225,7 +225,8 @@ def main():
parser.add_argument("-p", "--passes",
dest="passes",
nargs="+",
default=[pass_.__name__ for pass_ in _data.Pass._get_all()],
default=[pass_.__name__ for pass_ in _data.Pass._get_all()
if pass_.default],
help="Specify which passes to use. compare50 ranks only by the first pass, but will render views for every pass.")
parser.add_argument("-i", "--include",
callback=submission_factory.include,
Expand Down
3 changes: 3 additions & 0 deletions compare50/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Pass(metaclass=_PassRegistry):
"""
__register = False

# Whether or not the pass should be enabled by default
default = False

@abc.abstractmethod
def preprocessors(self):
pass
Expand Down
15 changes: 13 additions & 2 deletions compare50/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class structure(Pass):
"""Compares code structure by removing whitespace and comments; normalizing variable names, string literals, and numeric literals; and then running the winnowing algorithm."""

default = True
preprocessors = [preprocessors.strip_whitespace,
preprocessors.strip_comments,
preprocessors.normalize_identifiers,
Expand All @@ -20,16 +20,27 @@ class structure(Pass):

class exact(Pass):
"""Removes all whitespace, then uses the winnowing algorithm to compare submissions."""
default = True
preprocessors = [preprocessors.split_on_whitespace,
preprocessors.strip_whitespace]
comparator = comparators.Winnowing(k=25, t=35)


class misspellings(Pass):
"""Compares comments for identically misspelled English words."""

default = True
preprocessors = [preprocessors.comments,
preprocessors.normalize_case,
preprocessors.words]
comparator = comparators.Misspellings(resource_filename("compare50.comparators",
"english_dictionary.txt"))

class nocomments(Pass):
"""Removes comments, but keeps whitespace, then uses the winnowing algorithm to compare submissions"""
preprocessors = [preprocessors.strip_comments, preprocessors.split_on_whitespace]
comparator = comparators.Winnowing(k=25, t=35)

class verbatim(Pass):
"""Removes nothing, not even whitespace, then uses the winnowing algorithm to compare submissions"""
preprocessors = []
comparator = comparators.Winnowing(k=25, t=35)