Programming Language Detector - When you input code, it detect its language
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
resources
sample_codes
shamanld
tests
.gitignore
.travis.yml
LICENSE
MANIFEST.in
README.md
setup.py
test-requirements.txt

README.md

Shaman

Pypi Build Status

Programming Language Detector
When you input code, Shaman detect its language

Install

$ pip install shamanld

Usage

from shamanld import Shaman

code = """
#include <stdio.h>
int main() {
	printf("Hello world");
}
"""

r = Shaman.default().detect(code)

print(r)
# [('c', 44.54114006995534), ('java', 6.445867604204304), ('c#', 5.015724434781431), ...]

Supporting languages

  • ActionScript
  • ASP
  • Bash
  • C
  • C#
  • CSS
  • HaXe
  • HTML
  • Java
  • JavaScript
  • JSP
  • Objective-c
  • Perl
  • PHP
  • Python
  • Ruby
  • SQL
  • Swift
  • VisualBasic
  • XML

Accuracy

Now 80%
Accuracy

Test shaman

Test single file

$ shaman-tester -f sample1.cpp
c: 99.98%
c#: 0.02%
java: 0.00%
javascript: 0.00%

Test bunch of code

$ shaman-tester -b codes.csv
# CSV format: language, code

Custom trained set

Make custom trained set

$ shaman-trainer code_bunch.csv custom_trained_set.json
# CSV format: language, code

Use custom trained set

from shamanld import Shaman

detector = Shaman(open('custom_trained_set.json'))
detector.detect('some code')