Skip to content

Auto-Reply Functionality for Unformatted Code #167

Open

Description

@togakangaroo

Problem:

We tend to have people posting often who don't know the three main ways to format code on slack. A bot to help them do this properly would save everyone some time and annoyance. Plus it should be fun to code.

This bot will activate when there is a post where a subset of the lines contains something that looks like code but is not formatted as such

So how to determine if something looks like code? Two possible approaches.

  1. Heuristically. There are libraries out there that auto-detect language. Presumably some of the same processes can be used to detect whether something is code at all. Example of something that does this: highlight.js

  2. ML. This is actually a pretty decent use case for something like a tensorflow classifier. And we could train it off of the actual operation code logs!

Activity

  1. togakangaroo commented on May 8, 2020

    @togakangaroo
    Author

    I bet if you do it as a standalone bot, other slacks would love something like that. Good OSS project overall

  2. LivingInSyn commented on May 8, 2020

    @LivingInSyn
    Contributor

    Pygments might be a good fit since we're already mostly python:

    https://pygments.org/docs/api/#pygments.lexers.guess_lexer

  3. jasonappah commented on Oct 7, 2020

    @jasonappah

    I'd like to give this a shot!

  4. aaron-junot commented on Oct 7, 2020

    @aaron-junot
    Member

    Go for it @jasonappah! Happy to see what you come up with.

  5. added
    priority: lowThis is an issue that is fine sitting for a while
    and removed on Aug 18, 2021
  6. JudsonStevens commented on Jan 1, 2022

    @JudsonStevens
    Collaborator

    I think this could be an interesting project to add into the rewrite. Looking at this example for Discourse (code here) I think we could translate this over to Python to fit into the bot. Alternatively we could just use the project in Javascript and have it run next to the bot.

    This is really a great opportunity for a Machine Learning project, but unfortunately for our situation I don't think that's the route we want to go. It would entail a good bit more infrastructure setup in order to have the model in production to be queryable - we could do something like train the model and just run it on the machine we use for the bot but even that would require a good bit more processing power/more powerful machine than we are currently using. I think the Regex based approach in the Discourse repository is the place to start.

  7. added
    feedback: discussionActive discussion is happening to scope this issue, set acceptance criteria, or decide to accept it
    project: rewriteThis issue applies to the rewrite of Pybot
    status: awaiting acceptanceIssue has not been accepted - it may need documentation, discussion, or a decision - the ice box
    type: code changeIssue requires changes to the code base
    type: documentationIssue requires a change to the current documentation of the codebase or product
    type: featureIssue involves adding new functionality that doesn't currently exist
    on Jan 1, 2022
  8. JudsonStevens commented on Jan 1, 2022

    @JudsonStevens
    Collaborator

    Also, I tried Pygments and it was failing on some of the simpler examples I gave it, just detecting text - for example, this piece of text: I am using these codes before it .Embed_length = 25 model = Sequential() model.add(Embedding(vocab_size, Embed_length, input_length=1000)) model.add(SpatialDropout1D(0.2)) model.add(LSTM(10, dropout=0.5, recurrent_dropout=0.5)) parsed as <pygments.lexers.TextLexer>. I only tried it a couple times but it definitely seemed to default to text quite often.

  9. changed the title [-]A bot that will auto-reply to anything that looks like unformatted code with guidance on how to format[/-] [+]Auto-Reply Functionality for Unformatted Code[/+] on Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feedback: discussionActive discussion is happening to scope this issue, set acceptance criteria, or decide to accept itpriority: lowThis is an issue that is fine sitting for a whileproject: rewriteThis issue applies to the rewrite of Pybotstatus: awaiting acceptanceIssue has not been accepted - it may need documentation, discussion, or a decision - the ice boxtype: code changeIssue requires changes to the code basetype: documentationIssue requires a change to the current documentation of the codebase or producttype: featureIssue involves adding new functionality that doesn't currently exist

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions