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

Added 'mostly dots' rule #602

Merged
merged 1 commit into from Mar 19, 2017
Merged

Added 'mostly dots' rule #602

merged 1 commit into from Mar 19, 2017

Conversation

quartata
Copy link
Member

We've been getting a rash of spam posts that try to be "clever" like this: http://chat.stackexchange.com/transcript/message/36131864#36131864

We catch them anyways since our phone number detection isn't dumb, but I figured it wouldn't hurt to throw in an extra rule to catch them. This rule will trip if the ratio of dots to characters in the post is greater than 40%.


dot_count = len(regex.findall("\.", body))

if body_length and dot_count / float(body_length) >= 0.4:
Copy link
Member

Choose a reason for hiding this comment

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

Why float(body_length)?

Copy link
Member Author

@quartata quartata Mar 19, 2017

Choose a reason for hiding this comment

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

Because Python 2 does integer division when both are ints. (and we're not using __future__)

Copy link
Member

Choose a reason for hiding this comment

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

/me is too used to Python 3.

Copy link
Member

Choose a reason for hiding this comment

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

We can always import __future__ but we'd have to redo a large portion of our math. I only recently starting using the division aspect of __future__ in one of my other scripts, but so far I'm a fan of it. I'm not a fan of some other aspects of Python 3 though. Yet.

Copy link
Member

Choose a reason for hiding this comment

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

from __future__ import braces

Copy link
Member

Choose a reason for hiding this comment

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

from __future__ import division would work too, but... eh.

@ArtOfCode- ArtOfCode- merged commit ad14da7 into Charcoal-SE:master Mar 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants