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

Adding Reverse Existence checks Issue #1334 #1351

Closed
wants to merge 2 commits into from
Closed

Conversation

vqle23
Copy link
Contributor

@vqle23 vqle23 commented Apr 21, 2023

I added a way to ensure that you only words within a certain set as requested in Issue #1334 or as the reporter coin as a "reverse-existence check". Currently, the two sets implemented with this new feature are the top 1000 words set as requested by the initial reporter, but I also added a set of words that elementary kids are taught to learn how to spell. With both sets, I have provided a suite of test cases for quality assurance. However, I did have to modify test_config_flag.py a bit to pass linter tests (some lines were too long, and had to turn a string into a variable on the line above).

@Nytelife26 Nytelife26 self-assigned this Jul 27, 2023
@Nytelife26 Nytelife26 added type: feat Issues and PRs related to new features. priority: null Issues and PRs that are of negligible importance so may be postponed. version: minor Issues and PRs with new features belonging to the next minor release. status: postponed Issues and PRs that are being temporarily set aside in favour of others. cat: new-rule Issues and PRs related to new proselint rules. labels Jul 27, 2023
@Nytelife26
Copy link
Member

Thank you for contributing! I am postponing this PR until my queries on the related issue are answered, but your work is appreciated nonetheless. In the meantime, I will proceed to review this.

msg = "'{}' is not a word kids learn in elementary school."

elementary = [
"a",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files are quite large. I would prefer if we implemented some way to condense them, like having a compressed dictionary available in the folder to import here, to avoid code bloat.

@memoize
def check(text):
"""Check the text."""
err = "reverse existence.top1000"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err = "reverse existence.top1000"
err = "reverse_existence.elementary"

This conforms to the directory path, and fixes a naming conflict with top1000.

def check(text):
"""Check the text."""
err = "reverse existence.top1000"
msg = "'{}' is not a word kids learn in elementary school."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, this check is not generally applicable enough to be included by default. How often do people write with the intention of exclusively using words understandable to infants? This seems to be more about intention than prose.

My official recommendation so far would be to remove these checks and keep this PR focused on implementing the non-existence mechanic (or exclusivity, more accurately), but I am always open to hearing your thoughts.

def check(text):
"""Check the text."""
err = "reverse existence.top1000"
msg = "'{}' is not it top 1,000 most popular words."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thoughts here are the same with the elementary check.

Comment on lines +90 to +91
"reverse_existence.top1000": False,
"reverse_existence.elementary": False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the direction we take with my prior comments, these may need to be adjusted. Disregard this for now.

@@ -365,6 +365,26 @@ def existence_check(text, list, err, msg, ignore_case=True, str=False,
return errors


def reverse_existence_check(text, list, err, msg):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should support the same options as existence_check, since it calls it internally anyway.

# containing the prohibited words
if(len(words_not_in_list) == 0):
return []
return existence_check(text, words_not_in_list, err, msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is highly inefficient to locate words that should not be in the source, and then have existence_check search for them anyway. I think it would be better to model this from existence_check, instead of calling it.

Comment on lines +29 to +30
json = "tests/test_config_flag_proselintrc.json"
overrides = load_options(json, default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to this file appear to be out of scope for this PR. They are unrelated to the functionality of the "reverse existence check," and should therefore be moved into their own PR. Thank you for tidying up, though. I appreciate going beyond the task at hand, and I understand how difficult it can be not to slide small fixes into larger PRs as a bundle.

Comment on lines -59 to +62

comm = "--dump-config --config tests/test_config_flag_proselintrc.json"
output = runner.invoke(
proselint, "--dump-config --config tests/test_config_flag_proselintrc.json")
proselint, comm)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just OOC, why couldn't this have just become this?

    output = runner.invoke(
        proselint,
        "--dump-config --config tests/test_config_flag_proselintrc.json")

That's under 80 chars on each line.

(For that matter, it could've been this, too, if it really came down to it. Python supports C-style automatic string-literal concatenation.)

    output = runner.invoke(
        proselint,
        "--dump-config "
        "--config tests/test_config_flag_proselintrc.json")

@Nytelife26
Copy link
Member

closing this for inactivity and in favour of #1370.

@Nytelife26 Nytelife26 closed this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat: new-rule Issues and PRs related to new proselint rules. priority: null Issues and PRs that are of negligible importance so may be postponed. status: postponed Issues and PRs that are being temporarily set aside in favour of others. type: feat Issues and PRs related to new features. version: minor Issues and PRs with new features belonging to the next minor release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants