You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

guesslang-experimental

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

guesslang-experimental

Detect the programming language of a source code


Maintainers
1

Readme

This is NOT A TYPOSQUATTING PACKAGE

It's a fork of the original https://github.com/yoeo/guesslang / pypi package guesslang

Reason of fork - abandoned project. I need a specific patch. Fixing tensorflow dependency myself until https://github.com/yoeo/guesslang/pull/62 is merged

Install:

pip install guesslang-experimental

Guesslang Build Status Documentation Status Pypi version

Guesslang

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 54 programming languages:

Languages
AssemblyBatchfileCC#C++
ClojureCMakeCOBOLCoffeeScriptCSS
CSVDartDMDockerfileElixir
ErlangFortranGoGroovyHaskell
HTMLINIJavaJavaScriptJSON
JuliaKotlinLispLuaMakefile
MarkdownMatlabObjective-COCamlPascal
PerlPHPPowerShellPrologPython
RRubyRustScalaShell
SQLSwiftTeXTOMLTypeScript
VerilogVisual BasicXMLYAML

With a guessing accuracy higher than 90%.

Apps powered by Guesslang

Microsoft Visual Studio Code, automatic language detection

Visual Studio Code detects the programming language of the source code that you paste into the editor using Guesslang machine learning model.

Chameledit

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

Other projects...
  • Pasta, the Slack bot that pretty-pastes source code.
  • GG, a silly guessing game.

Documentation

Installation

  • Python 3.7+ 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 /etc/bashrc configuration file:
guesslang /etc/bashrc

# ⟶ Programming language: 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

# ⟶ Programming language: Scala
  • Show the detection probabilities for a given source code:
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               74.80%
#  Haskell               6.73%
#  CoffeeScript          5.32%
#  Groovy                1.95%
#  Markdown              0.93%
#  ...

Guesslang Python package


from guesslang import Guess


guess = 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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc