Git Product home page Git Product logo

guesslang's Introduction

Guesslang Build Status Documentation Status

Chameledit

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

# Output: The source code is written in Go

Guesslang supports 20 programming languages:

Languages
C C# C++ CSS Erlang
Go HTML Java Javascript Markdown
Objective-C PHP Perl Python Ruby
Rust SQL Scala Shell Swift

With a guessing accuracy higher than 90%.

Apps powered by Guesslang

Chameledit

Chameledit is a simple web-editor that automatically highlights your code.

Pasta

Pasta is a Slack bot that pretty pastes source code.

Watch the demo here

GG

GG is a silly guessing game.

Documentation

Installation

  • Python 3.6+ is required

  • Install the latest stable version:

pip3 install guesslang
  • or install Guesslang from source code:
pip3 install .
  • Windows specific

To run Tensorflow on Microsoft Windows you need to install Visual C++ runtime libraries, available on Microsoft website

Guesslang command line

  • Show all available options
guesslang --help
  • Detect the programming language of /bin/which:
guesslang -i /bin/which

# >>> The source code is written in Shell
  • Detect the programming language of a given text:
echo '
/** Turn command line arguments to uppercase */
object Main {
  def main(args: Array[String]) {
    val res = for (a <- args) yield a.toUpperCase
    println("Arguments: " + res.toString)
  }
}
' | guesslang

# >>> The source code is written in Scala
  • Detect the programming languages of a source code that embeds an other source code (sourcecodeception):
echo '
from __future__ import print_function


def dump_code(code):
  print(code)


if __name__ == "__main__":
    dump_code("""
        #include<stdio.h>

        int main(int argc, char** argv)
        {
          char* command = argv[0];
          printf("%s - %d args\n", command, --argc);
          return 0;
        }
    """
    )

' | guesslang --all

# >>> The source code is written in Python or C

Guesslang Python package

from guesslang import Guess


name = Guess().language_name("""
    % Quick sort

    -module (recursion).
    -export ([qsort/1]).

    qsort([]) -> [];
    qsort([Pivot|T]) ->
          qsort([X || X <- T, X < Pivot])
          ++ [Pivot] ++
          qsort([X || X <- T, X >= Pivot]).
""")

print(name)  # >>> Erlang

License and credits

guesslang's People

Contributors

yoeo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.