all 18 comments

[–]k9rosie 3 ポイント4 ポイント

Cool bot. your code could be a little neater. putting all of the ableist words in a .txt file and have the bot loop through would be ideal, so you can avoid all of those if statements.

[–]WybothPython, C++, Java[S] 0 ポイント1 ポイント

That's true, but then I wouldn't get the elifs in. I purposefully put them there so it wouldn't be redundant when searching for certain words (ex. finding "idiot" and "idiotic" in the word "idiotic"). I wish I could actually use the bot, but the SRS mods are telling me I'm not allowed to. I don't see why.

[–]curious_electric 2 ポイント3 ポイント

You could have a list of regexes too, with things like /idiot(ic)?/ so it'll pick up either "idiot" or "idiotic". You could do that with things like /short( -)bus/ too. And you don't need to have a separate section appending a capitalized ableist word, just use the actual detected word, capitalized if you like, in the results.

A few of these seem like odd choices. Do people ever really use "invalid" as a slur in SRS? That seems likely to pick up a lot of false positives from the use of the paroxytone adjective instead of the proparoxytone noun. (YES! Achievement unlocked, I managed to work the word "proparoxytone" into a sentence.)

Anyway, cool to see a nice little python program. I would like to get into Python one of these days...

[–]WybothPython, C++, Java[S] 0 ポイント1 ポイント

I don't know Regex, but I hear it's magical. I could learn it.

You make a good point about some of those words. I basically copy-pasted the list of ableist words from this site, without thinking much about how often they'd be used on SRS. I'll remove invalid from the list. Any others you can think of?

Also, if you're interested in Python, this is a good tutorial.

[–]curious_electric 0 ポイント1 ポイント

I actually just worked my way through the python tutorial on the python site itself. It's a pretty cool language!

Simple regex stuff is simple. in Python you don't need the // you just need the Regex module.

The one I used: 'idiot(ic)?' will match the word 'idiot' with an optional 'ic' at the end (it considers the 'ic' to be a unit because of the (), and it makes it optional because of the ? )

They can get extremely complicated but the basics are easy.

Nothing else on the list struck me as as likely to create false positives as the 'invalid' one :)

[–]WybothPython, C++, Java[S] 0 ポイント1 ポイント

That's good to hear, although I'll probably use /u/intortus's solution, since it eliminates the need for the long if-elif chains.

[–]curious_electric 0 ポイント1 ポイント

Oh, I was figuring you could do it without the if-else chain too. Put each regexp in a line of a file, read it in, build up a list of regexes in memory, that kinda thing. But either way works!

[–]throwaway0a0a0a0a 0 ポイント1 ポイント

insanely

:\

[–]curious_electric 0 ポイント1 ポイント

DAMMIT

edited

[–]WybothPython, C++, Java[S] 0 ポイント1 ポイント

Hahahahaha! Do I take it everyone here likes the idea of this bot?

[–]curious_electric 0 ポイント1 ポイント

It seems nice, but if the mods aren't down with it I'm fine with that too. Don't really want to tell them how to do their job.

[–]intortus 0 ポイント1 ポイント

You could group words, for example by listing "idiot" and "idiotic" on the same line. Then you could implement your short-circuiting logic with a for loop rather than an unrolled if-elif chain.

[–]WybothPython, C++, Java[S] 0 ポイント1 ポイント

I'm not sure how I'd do that. Do you think you could give an example?

[–]intortus 0 ポイント1 ポイント

ableistWords = []
for line in file('badwords.txt'):
  for word in line.split():
    if word.lower() in commentText.lower():
      ableistWords.append(word)
      break

EDIT: You probably want to match longer words first, so I think this would work:

  for word in sorted(line.split(), key=len, reverse=True):

[–]WybothPython, C++, Java[S] 0 ポイント1 ポイント

Ah! That's very clever. I was really confused for a while how this would skip over the second word on the line. My eyes skipped over the break statement. Thank you for this; I'll implement it! Although I'll probably make the if statement this:

if (" " + word.lower()) in commentText.lower():

So that it won't do things like finding "lame" in "blame." Thanks for your help!

Edit: Since you're an SRS mod, and you're talking to me, do you know why bots are disallowed on the fempire? It seems to me like this one would do nothing but help.

[–]intortus -3 ポイント-2 ポイント

Sorry, I don't know anything about the policy or why it's in place. I'm just there to troll.

That's a clever approach to requiring matches to occur at word boundaries. I'd also add a space to the beginning of commentText, so that the beginning of the comment also counts as a word boundary.

Unfortunately you'll miss out on cases where punctuation delimits instead of spacing. This is where the re package might be handy. You could build a pattern that is something like r'\b(%s)' % '|'.join(line.split()).

[–]totes_meta_bot -1 ポイント0 ポイント

This thread has been linked to from elsewhere on reddit.

I am a bot. Comments? Complaints? Message me here. I don't read PMs!

[–]k9rosie -2 ポイント-1 ポイント

I was wondering where these downvotes were coming from with a sub of only 100 people in it