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

Auto-Reply Functionality for Unformatted Code #167

Open
togakangaroo opened this issue May 8, 2020 · 6 comments
Open

Auto-Reply Functionality for Unformatted Code #167

togakangaroo opened this issue May 8, 2020 · 6 comments
Labels
feedback: discussion Active discussion is happening to scope this issue, set acceptance criteria, or decide to accept it priority: low This is an issue that is fine sitting for a while project: rewrite This issue applies to the rewrite of Pybot status: awaiting acceptance Issue has not been accepted - it may need documentation, discussion, or a decision - the ice box type: code change Issue requires changes to the code base type: documentation Issue requires a change to the current documentation of the codebase or product type: feature Issue involves adding new functionality that doesn't currently exist

Comments

@togakangaroo
Copy link

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!

@togakangaroo
Copy link
Author

togakangaroo commented May 8, 2020

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

@LivingInSyn
Copy link
Contributor

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

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

@kylemh kylemh added the general: hacktoberfest Issue is a good fit for Hacktoberfest label Oct 1, 2020
@jasonappah
Copy link

I'd like to give this a shot!

@aaron-junot
Copy link
Member

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

@aaron-junot aaron-junot added priority: low This is an issue that is fine sitting for a while and removed general: hacktoberfest Issue is a good fit for Hacktoberfest labels Aug 18, 2021
@JudsonStevens
Copy link
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.

@JudsonStevens JudsonStevens added feedback: discussion Active discussion is happening to scope this issue, set acceptance criteria, or decide to accept it project: rewrite This issue applies to the rewrite of Pybot status: awaiting acceptance Issue has not been accepted - it may need documentation, discussion, or a decision - the ice box type: code change Issue requires changes to the code base type: documentation Issue requires a change to the current documentation of the codebase or product type: feature Issue involves adding new functionality that doesn't currently exist labels Jan 1, 2022
@JudsonStevens
Copy link
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.

@JudsonStevens JudsonStevens 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 Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback: discussion Active discussion is happening to scope this issue, set acceptance criteria, or decide to accept it priority: low This is an issue that is fine sitting for a while project: rewrite This issue applies to the rewrite of Pybot status: awaiting acceptance Issue has not been accepted - it may need documentation, discussion, or a decision - the ice box type: code change Issue requires changes to the code base type: documentation Issue requires a change to the current documentation of the codebase or product type: feature Issue involves adding new functionality that doesn't currently exist
Projects
None yet
Development

No branches or pull requests

6 participants