Skip to content

angeloskath/php-sourceclassifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LanguageDetector

LanguageDetector is an implementation of sourceclassifier in PHP using NlpTools.

LanguageDetector detects the programming language of a source code using a Naive Bayes model. The pre trained provided model recognizes C, C#, C++, Clojure, Go, Haskell, Java, Javascript, MATLAB, Pascal, Perl, PHP, Python, Ruby, Scala, Visual Basic.

You can read a blog post about it.

Usage

include ("vendor/autoload.php");

$detector = LanguageDetector::loadFromFile("model");

$lang = $detector->classify(<<<CODE
#include <stdio.h>

int main() {
	printf("Hello world");
}
CODE
);

echo $lang; // C

$lang = $detector->classify(<<<CODE
def hello():
	print "Hello world"
hello()
CODE
);

echo $lang; // Python

About

Classify source code using a Naive Bayes text classifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages