SteamedPears / Code-Review

A web app for reviewing code (and other text), written in node.js using redis as the persistent store.
http://review.steamedpears.com
ISC License
1 stars 2 forks source link

Language Auto-detection #37

Open cdelahousse opened 11 years ago

cdelahousse commented 11 years ago

Imported issue by spratt from 2012-07-04T12:27:25Z Originally opened as https://github.com/SteamedPears/CodeReviewClientMaster/issues/18


As the user enters code in the code submission window, we should make a reasonable guess at which language they are using, but still let the user pick their language, and stop trying to auto-detect once they've chosen.

cdelahousse commented 11 years ago

Imported comment by Gankro from 2012-07-14T23:16:56Z *


This doesn't seem tractable, as indicated by the ubiquity of "C-Like". Also if you have a string with another language in it, how would you possibly resolve that? Is this some HTML with javascript, or some javascript with HTML?

cdelahousse commented 11 years ago

Imported comment by spratt from 2012-07-15T01:49:49Z *


Our first idea is a Bayesian classifier. Basically build a score for each language, maybe based on the number of keywords matched, and calculate the probability of each language. When the probability passes a certain threshold, make that guess.

bheesham commented 11 years ago

Don't really want to implement this, unless ACE has the power to do it. I don't think as a reviewing app, we would have to worry about the language, so much as the reviewing part. I would like the ability to change the syntax highlighting though.

So, lets say that someone incorrectly uploads something as Python, but then someone see's and decides to change it to CofeeScript, because the syntax of both confused them.

I think it would be wise to not really enforce one highlighting option. How much resources are we going to use up showing a select box, to re-highlight code? Most of the work would be on the client side, and ACE is pretty fast at that stuff.

psimonyi commented 11 years ago

On Tue, 2013-02-05 at 19:03 -0800, Bheesham Persaud wrote:

I don't think as a reviewing app, we would have to worry about the language, so much as the reviewing part. Well, code readability is a key part of giving a good review.

Having the option to override the poster's highlighting choice seems like a good idea, but good defaults are the hallmark of a good app. Also, this problem has been solved elsewhere, e.g. in vim. We should just look to see who else does language detection.