Re:Show HN: Detecting the Programming Language of Code Using...
by Vraxx on Monday July 18, 2016 @04:02PM
(#12117723)
I get the point of wanting to be able to address scenarios that you haven't seen before, but in this particular instance, is it really that much help to be able to classify a program that isn't technically written in any programming language (ie. it's invalid)?
Re:Show HN: Detecting the Programming Language of Code Using...
by riscy on Monday July 18, 2016 @04:20PM
(#12117820)
> be able to classify a program that isn't technically written in any programming language (ie. it's invalid)?
I wouldn't go so far as saying it's 'invalid'. It's a perfectly reasonable new language that the classifier hasn't encountered, yet whose style is heavily rooted in languages the classifier has been trained on.
If we require that all programs we feed it are a valid program in one of a handful of languages it expects, we could've just run a parser for each language on the given input and call it a day. Trying to classify a weird language like this is where the machine learning aspect of the work really shines.
Re:Show HN: Detecting the Programming Language of Code Using...
by Vraxx on Monday July 18, 2016 @04:34PM
(#12117902)
Ah, yes. That makes a lot more sense than how I was thinking about it. It would still be marginally better than just attempting to validate the code in expected languages because it would probably handle typos and other simple syntax errors, as well as snippet problems (like not declaring a certain variable in the snippet), but I can see where the output on an "invalid" program could be useful now.
Re:Show HN: Detecting the Programming Language of Code Using...
by pprogrammer on Monday July 18, 2016 @04:20PM
(#12117823)
The model does generalize to data it hasn't seen before (and that's validated using a validation set) but not to data that isn't similar to the data set. For example, it would probably not detect the programming language well when only using comments.
That was the goal of the example, because it tests whether you're overfitting to the training data. The point of machine learning is to use the training data to help you make smart decisions in scenarios that you haven't seen before. In this case, I expected it always say it is more C than Python.