Detect the programming language of a source code
No Data
Guesslang detects the programming language of a given source code:
echo ' package main import "fmt"func main() { fmt.Println("My mascot is a gopher and Google loves me. Who am I?") }
' | guesslang
⟶ Programming language: Go
Guesslang supports
30 programming languages:
| Languages | | | | | |----------------|---------------|--------------------|--------|--------------| |
Batchfile|
C|
C#|
C++|
CSS| |
CoffeeScript|
Erlang|
Go|
HTML|
Haskell| |
Java|
JavaScript|
Jupyter Notebook|
Lua|
Markdown| |
Matlab|
Objective-C|
PHP|
Perl|
PowerShell| |
Python|
R|
Ruby|
Rust|
SQL| |
Scala|
Shell|
Swift|
TeX|
TypeScript|
With a guessing accuracy higher than 90%.
Chameledit is a simple web-editor that automatically highlights your code.
Pasta is a Slack bot that pretty pastes source code.
GG is a silly guessing game.
Guesslang documentation is available at https://guesslang.readthedocs.io/en/latest/
Guesslang language detection explained here https://guesslang.readthedocs.io/en/latest/how.html
Guesslang is based on Tensorflow machine learning framework
Python 3.6+ is required
Install the latest stable version:
pip3 install guesslang
pip3 install .
To run Tensorflow on Microsoft Windows you need to install Visual C++ runtime libraries, available on Microsoft website
guesslang --help
/bin/which:
guesslang /bin/which⟶ Programming language: Shell
echo ' /** Turn command line arguments to uppercase */ object Main { def main(args: Array[String]) { val res = for (a
echo " def qsort(items): if not items: return [] else: pivot = items[0] less = [x for x in items if x < pivot] more = [x for x in items[1:] if x >= pivot] return qsort(less) + [pivot] + qsort(more)if name == 'main': items = [1, 4, 2, 7, 9, 3] print(f'Sorted: {qsort(items)}')
" | guesslang --probabilities
Language name Probability
Python 80.53%
Batchfile 6.16%
CoffeeScript 2.18%
Markdown 1.66%
JavaScript 1.47%
...
from guesslang import Guessguess = Guess()
name = guess.language_name(""" % Quick sort
-module (recursion). -export ([qsort/1]). qsort([]) -> []; qsort([Pivot|T]) -> qsort([X || X = Pivot]).
""")
print(name) # ⟶ Erlang
Gesslang training dataset created with GuesslangTools
Guesslang developped with Tensorflow
Guesslang icon created with AndroidAssetStudio and Eduardo Tunni's Warnes font
Example source codes used here retrieved from Rosetta Code
Guesslang — Copyright (c) 2020 Y. SOMDA, MIT License