PHPackages                             nlp-tools/lang-detect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. nlp-tools/lang-detect

ActiveLibrary

nlp-tools/lang-detect
=====================

Classify source code using a Naive Bayes text classifier

101394PHP

Since Nov 13Pushed 12y ago2 watchersCompare

[ Source](https://github.com/angeloskath/php-sourceclassifier)[ Packagist](https://packagist.org/packages/nlp-tools/lang-detect)[ RSS](/packages/nlp-tools-lang-detect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

LanguageDetector
================

[](#languagedetector)

LanguageDetector is an implementation of [sourceclassifier](https://github.com/chrislo/sourceclassifier) in PHP using [NlpTools](https://github.com/angeloskath/php-nlp-tools).

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](http://php-nlp-tools.com/posts/programming-language-detection.html) about it.

Usage
-----

[](#usage)

```
include ("vendor/autoload.php");

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

$lang = $detector->classify(
