From f7b617fc914fc4219f96b971689afef6227d0f48 Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Thu, 12 Feb 2015 20:31:34 -0500 Subject: [PATCH 1/9] dataframe started --- .../workbook.ipynb | 1015 +++++++++++++++++ requirements.txt | 3 +- test.csv | 33 - test/1 | 30 - test/10 | 14 - test/11 | 789 ------------- test/12 | 11 - test/13 | 112 -- test/14 | 16 - test/15 | 30 - test/16 | 364 ------ test/17 | 5 - test/18 | 69 -- test/19 | 18 - test/2 | 9 - test/20 | 2 - test/21 | 220 ---- test/22 | 64 -- test/23 | 59 - test/24 | 77 -- test/25 | 48 - test/26 | 35 - test/27 | 20 - test/28 | 209 ---- test/29 | 9 - test/3 | 4 - test/30 | 61 - test/31 | 213 ---- test/32 | 15 - test/4 | 21 - test/5 | 26 - test/6 | 88 -- test/7 | 15 - test/8 | 532 --------- test/9 | 53 - 35 files changed, 1017 insertions(+), 3272 deletions(-) create mode 100644 programming-language-classifier/workbook.ipynb delete mode 100644 test.csv delete mode 100644 test/1 delete mode 100644 test/10 delete mode 100644 test/11 delete mode 100644 test/12 delete mode 100644 test/13 delete mode 100644 test/14 delete mode 100644 test/15 delete mode 100644 test/16 delete mode 100644 test/17 delete mode 100644 test/18 delete mode 100644 test/19 delete mode 100644 test/2 delete mode 100644 test/20 delete mode 100644 test/21 delete mode 100644 test/22 delete mode 100644 test/23 delete mode 100644 test/24 delete mode 100644 test/25 delete mode 100644 test/26 delete mode 100644 test/27 delete mode 100644 test/28 delete mode 100644 test/29 delete mode 100644 test/3 delete mode 100644 test/30 delete mode 100644 test/31 delete mode 100644 test/32 delete mode 100644 test/4 delete mode 100644 test/5 delete mode 100644 test/6 delete mode 100644 test/7 delete mode 100644 test/8 delete mode 100644 test/9 diff --git a/programming-language-classifier/workbook.ipynb b/programming-language-classifier/workbook.ipynb new file mode 100644 index 0000000..234ef19 --- /dev/null +++ b/programming-language-classifier/workbook.ipynb @@ -0,0 +1,1015 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:6b2f7875aa3379877868ef9f69e01701c37edab259ecd180a1d40b11f417ae2b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import pandas as pd" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 27 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "filename_dict = {\".clj\":\"Clojure\",\n", + " \".cljs\": \"Clojure\",\n", + " \".edn\": \"Clojure\",\n", + " \".clojure\": \"Clojure\",\n", + " \".hs\": \"Haskell\",\n", + " \".lhs\": \"Haskell\",\n", + " \".java\": \"Java\",\n", + " \".class\": \"Java\",\n", + " \".jar\": \"Java\",\n", + " \".js\": \"Javascript\",\n", + " \".javascript\": \"Javascript\",\n", + " \".ocaml\": \"OCaml\",\n", + " \".ml\": \"OCaml\",\n", + " \".pl\": \"Perl\",\n", + " \".pm\": \"Perl\",\n", + " \".t\": \"Perl\",\n", + " \".pod\": \"Perl\",\n", + " \".php\": \"PHP\",\n", + " \".perl\": \"Perl\",\n", + " \".phtml\": \"PHP\",\n", + " \".php4\": \"PHP\",\n", + " \".php3\": \"PHP\",\n", + " \".php5\": \"PHP\",\n", + " \".phps\": \"PHP\",\n", + " \".py\": \"Python\",\n", + " \".pyw\": \"Python\",\n", + " \".pyc\": \"Python\",\n", + " \".pyo\": \"Python\",\n", + " \".pyd\": \"Python\",\n", + " \".python3\": \"Python\",\n", + " \".Python2\": \"Python\",\n", + " \".rb\": \"Ruby\",\n", + " \".rbw\": \"Ruby\",\n", + " \".jruby\": \"Ruby\",\n", + " \".scala\": \"Scala\",\n", + " \".scm\": \"Scheme\",\n", + " \".ss\": \"Scheme\",\n", + " \".tcl\": \"Tcl\",\n", + " \".racket\": \"Scheme\",\n", + " \".ghc\": \"Haskell\"}" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def tuple_maker(adict):\n", + " lista = []\n", + " for key in adict:\n", + " lista.append(key)\n", + " tup = tuple(lista)\n", + " return tup" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def function_name():\n", + " codelist = []\n", + " for subdir, dirs, files in os.walk(\"bench/\"):\n", + " for fname in files:\n", + " if fname.endswith(tuple_maker(filename_dict)):\n", + " #print(fname)\n", + " with open(os.path.join(subdir, fname)) as current_file:\n", + " codelist.append(current_file.read()) \n", + " return codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 14 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "codelist = function_name()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 15 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "len(codelist)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 17, + "text": [ + "386" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def type_getter():\n", + " rootDir = 'bench'\n", + " typelist = []\n", + " for subdir, dirs, files in os.walk(rootDir):\n", + " for fname in files:\n", + " #print('\\t%s' % fname)\n", + " name, extension = os.path.splitext(fname)\n", + " if extension in filename_dict:\n", + " print(filename_dict[extension])\n", + " typelist.append(filename_dict[extension])\n", + " return typelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 24 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "typelist = type_getter()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Javascript\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "PHP\n", + "PHP\n", + "PHP\n", + "PHP\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Java\n", + "Ruby\n", + "Scala\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Python\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "PHP\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Javascript\n", + "Javascript\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "Perl\n", + "Perl\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Java\n", + "Perl\n", + "Perl\n", + "PHP\n", + "Python\n", + "Python\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "Perl\n", + "Perl\n", + "PHP\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Javascript\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "Python\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Ruby\n", + "OCaml\n", + "Perl\n", + "PHP\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "Perl\n", + "Perl\n", + "PHP\n", + "PHP\n", + "PHP\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Javascript\n", + "Javascript\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "Perl\n", + "Perl\n", + "PHP\n", + "PHP\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Haskell\n", + "Java\n", + "Java\n", + "Javascript\n", + "Javascript\n", + "Javascript\n", + "Ruby\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "Perl\n", + "Perl\n", + "PHP\n", + "PHP\n", + "Python\n", + "Python\n", + "Python\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scheme\n", + "Scheme\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Scala\n", + "Clojure\n", + "Clojure\n", + "Haskell\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Java\n", + "Ruby\n", + "Ruby\n", + "OCaml\n", + "OCaml\n", + "OCaml\n", + "Perl\n", + "Perl\n", + "Python\n", + "Python\n", + "Scheme\n", + "Scala\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "len(typelist)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 26, + "text": [ + "386" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df = pd.DataFrame(typelist, index=range(386))" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 32 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df.columns = [\"Language\"]\n", + "df[\"Code\"] = codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 35 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
LanguageCode
0 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
1 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
2 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
3 Haskell --\\n-- The Computer Language Benchmarks Game\\n...
4 Haskell --\\n-- The Computer Language Benchmarks Game\\n...
5 Haskell --\\n-- The Computer Language Benchmarks Game\\n...
6 Java /* The Computer Language Benchmarks Game\\n h...
7 Java /* The Computer Language Benchmarks Game\\n h...
8 Java /* The Computer Language Benchmarks Game\\n * h...
9 Javascript /* The Computer Language Benchmarks Game\\n h...
10 Ruby # The Computer Language Shootout Benchmarks\\n#...
11 Ruby # The Computer Language Benchmarks Game\\n# htt...
12 Ruby # The Computer Language Benchmarks Game\\n# htt...
13 Ruby # The Computer Language Benchmarks Game\\n# htt...
14 OCaml (* The Computer Language Benchmarks Game\\n * h...
15 OCaml (* The Computer Language Benchmarks Game\\n * h...
16 OCaml (* The Computer Language Benchmarks Game\\n * h...
17 Perl # The Computer Language Benchmarks Game\\n# htt...
18 Perl # The Computer Language Benchmarks Game\\n# htt...
19 PHP <?php \\n/* The Computer Language Benchmarks Ga...
20 PHP <?php \\n/* The Computer Language Benchmarks Ga...
21 PHP <?php \\n/* The Computer Language Benchmarks Ga...
22 PHP <?php \\n/* The Computer Language Benchmarks Ga...
23 Python # The Computer Language Benchmarks Game\\n# htt...
24 Scheme #lang racket/base\\n\\n;;; The Computer Language...
25 Scheme #lang racket/base\\n\\n;;; The Computer Language...
26 Scheme #lang racket/base\\n\\n;;; The Computer Language...
27 Scala /* The Computer Language Benchmarks Game\\n h...
28 Scala /* The Computer Language Benchmarks Game\\n h...
29 Scala /* The Computer Language Benchmarks Game\\n h...
.........
356 Python # The Computer Language Benchmarks Game\\n# htt...
357 Python # The Computer Language Benchmarks Game\\n# htt...
358 Python # The Computer Language Benchmarks Game\\n# htt...
359 Scheme #lang racket/base\\n\\n;;; The Computer Language...
360 Scheme #lang racket/base\\n\\n;;; The Computer Language...
361 Scheme #lang racket/base\\n;; The Computer Language Be...
362 Scala /* The Computer Language Benchmarks Game\\n h...
363 Scala /* The Computer Language Benchmarks Game\\n h...
364 Scala /* The Computer Language Benchmarks Game\\n h...
365 Scala /* The Computer Language Benchmarks Game\\n h...
366 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
367 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
368 Haskell -- The Computer Language Benchmarks Game\\n-- h...
369 Java /**\\n * The Computer Language Benchmarks Game\\...
370 Java /**\\n * The Computer Language Benchmarks Game\\...
371 Java /**\\n * The Computer Language Benchmarks Game\\...
372 Java /**\\n * The Computer Language Benchmarks Game\\...
373 Java /**\\n * The Computer Language Benchmarks Game\\...
374 Java /**\\n * The Computer Language Benchmarks Game\\...
375 Ruby # The Computer Language Benchmarks Game\\n# htt...
376 Ruby # The Computer Language Benchmarks Game\\n# htt...
377 OCaml (* The Computer Language Benchmarks Game\\n * h...
378 OCaml (* The Computer Language Benchmarks Game\\n * h...
379 OCaml (* The Computer Language Benchmarks Game\\n * h...
380 Perl # The Computer Language Benchmarks Game\\n# htt...
381 Perl # The Computer Language Benchmarks Game\\n# htt...
382 Python # The Computer Language Benchmarks Game\\n# htt...
383 Python # The Computer Language Benchmarks Game\\n# htt...
384 Scheme #lang racket/base\\n\\n;;; The Computer Language...
385 Scala /* The Computer Language Benchmarks Game\\n h...
\n", + "

386 rows \u00d7 2 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 36, + "text": [ + " Language Code\n", + "0 Clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", + "1 Clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", + "2 Clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", + "3 Haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", + "4 Haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", + "5 Haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", + "6 Java /* The Computer Language Benchmarks Game\\n h...\n", + "7 Java /* The Computer Language Benchmarks Game\\n h...\n", + "8 Java /* The Computer Language Benchmarks Game\\n * h...\n", + "9 Javascript /* The Computer Language Benchmarks Game\\n h...\n", + "10 Ruby # The Computer Language Shootout Benchmarks\\n#...\n", + "11 Ruby # The Computer Language Benchmarks Game\\n# htt...\n", + "12 Ruby # The Computer Language Benchmarks Game\\n# htt...\n", + "13 Ruby # The Computer Language Benchmarks Game\\n# htt...\n", + "14 OCaml (* The Computer Language Benchmarks Game\\n * h...\n", + "15 OCaml (* The Computer Language Benchmarks Game\\n * h...\n", + "16 OCaml (* The Computer Language Benchmarks Game\\n * h...\n", + "17 Perl # The Computer Language Benchmarks Game\\n# htt...\n", + "18 Perl # The Computer Language Benchmarks Game\\n# htt...\n", + "19 PHP 0 - }) - } - return el - } - - el.off = function(events, fn) { - if (events == '*') callbacks = {} - else if (fn) { - var arr = callbacks[events] - for (var i = 0, cb; (cb = arr && arr[i]); ++i) { - if (cb == fn) { arr.splice(i, 1); i-- } - } - } else { - events.replace(/\S+/g, function(name) { - callbacks[name] = [] - }) - } - return el - } - - // only single event supported - el.one = function(name, fn) { - if (fn) fn.one = 1 - return el.on(name, fn) - } - - el.trigger = function(name) { - var args = [].slice.call(arguments, 1), - fns = callbacks[name] || [] - - for (var i = 0, fn; (fn = fns[i]); ++i) { - if (!fn.busy) { - fn.busy = 1 - fn.apply(el, fn.typed ? [name].concat(args) : args) - if (fn.one) { fns.splice(i, 1); i-- } - else if (fns[i] !== fn) { i-- } // Makes self-removal possible during iteration - fn.busy = 0 - } - } - - return el - } - - return el - -} -;(function(riot, evt) { - - // browsers only - if (!this.top) return - - var loc = location, - fns = riot.observable(), - current = hash(), - win = window - - function hash() { - return loc.hash.slice(1) - } - - function parser(path) { - return path.split('/') - } - - function emit(path) { - if (path.type) path = hash() - - if (path != current) { - fns.trigger.apply(null, ['H'].concat(parser(path))) - current = path - } - } - - var r = riot.route = function(arg) { - // string - if (arg[0]) { - loc.hash = arg - emit(arg) - - // function - } else { - fns.on('H', arg) - } - } - - r.exec = function(fn) { - fn.apply(null, parser(hash())) - } - - r.parser = function(fn) { - parser = fn - } - - win.addEventListener ? win.addEventListener(evt, emit, false) : win.attachEvent('on' + evt, emit) - -})(riot, 'hashchange') -/* - -//// How it works? - - -Three ways: - -1. Expressions: tmpl('{ value }', data). - Returns the result of evaluated expression as a raw object. - -2. Templates: tmpl('Hi { name } { surname }', data). - Returns a string with evaluated expressions. - -3. Filters: tmpl('{ show: !done, highlight: active }', data). - Returns a space separated list of trueish keys (mainly - used for setting html classes), e.g. "show highlight". - - -// Template examples - -tmpl('{ title || "Untitled" }', data) -tmpl('Results are { results ? "ready" : "loading" }', data) -tmpl('Today is { new Date() }', data) -tmpl('{ message.length > 140 && "Message is too long" }', data) -tmpl('This item got { Math.round(rating) } stars', data) -tmpl('

{ title }

{ body }', data) - - -// Falsy expressions in templates - -In templates (as opposed to single expressions) all falsy values -except zero (undefined/null/false) will default to empty string: - -tmpl('{ undefined } - { false } - { null } - { 0 }', {}) -// will return: " - - - 0" - - -// Customizable brackets - - riot.settings.brackets = '[ ]' - riot.settings.brackets = '<% %>' - -*/ - -var tmpl = (function() { - - var cache = {}, - brackets, - re_expr, - re_vars = /("|').+?[^\\]\1|\.\w*|\w*:|\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\b|function *\()|([a-z_]\w*)/gi - // [ 1 ][ 2 ][ 3 ][ 4 ][ 5 ] - // find variable names: - // 1. skip quoted strings: "a b", 'a b', 'a \'b\'' - // 2. skip object properties: .name - // 3. skip object literals: name: - // 4. skip javascript keywords - // 5. match var name - - return function(str, data) { - - // make sure we use current brackets setting - var b = riot.settings.brackets || '{ }' - if(b != brackets){ - brackets = b.split(' ') - re_expr = re(/({[\s\S]*?})/) - } - - // build a template (or get it from cache), render with data - // (or just test if string has expression when called w/o data) - return data - ? str && (cache[str] = cache[str] || tmpl(str))(data) - : re_expr.test(str) - - } - - - // create a template instance - - function tmpl(s, p) { - - // default template string to {} - p = (s || brackets.join('')) - - // temporarily convert \{ and \} to a non-character - .replace(re(/\\{/), '\uFFF0') - .replace(re(/\\}/), '\uFFF1') - - // split string to expression and non-expresion parts - .split(re_expr) - - return new Function('d', 'return ' + ( - - // is it a single expression or a template? i.e. {x} or {x} - !p[0] && !p[2] && !p[3] - - // if expression, evaluate it - ? expr(p[1]) - - // if template, evaluate all expressions in it - : '[' + p.map(function(s, i) { - - // is it an expression or a string (every second part is an expression) - return i % 2 - - // evaluate the expressions - ? expr(s, 1) - - // process string parts of the template: - : '"' + s - - // preserve new lines - .replace(/\n/g, '\\n') - - // escape quotes - .replace(/"/g, '\\"') - - + '"' - - }).join(',') + '].join("")' - ) - - // bring escaped { and } back - .replace(/\uFFF0/g, brackets[0]) - .replace(/\uFFF1/g, brackets[1]) - - ) - - } - - - // parse { ... } expression - - function expr(s, n) { - s = s - - // convert new lines to spaces - .replace(/\n/g, ' ') - - // trim whitespace, curly brackets, strip comments - .replace(re(/^[{ ]+|[ }]+$|\/\*.+?\*\//g), '') - - // is it an object literal? i.e. { key : value } - return /^\s*[\w-"']+ *:/.test(s) - - // if object literal, return trueish keys - // e.g.: { show: isOpen(), done: item.done } -> "show done" - ? '[' + s.replace(/\W*([\w-]+)\W*:([^,]+)/g, function(_, k, v) { - - // safely execute vars to prevent undefined value errors - return v.replace(/\w[^,|& ]*/g, function(v) { return wrap(v, n) }) + '?"' + k + '":"",' - - }) + '].join(" ")' - - // if js expression, evaluate as javascript - : wrap(s, n) - - } - - - // execute js w/o breaking on errors or undefined vars - - function wrap(s, nonull) { - return '(function(v){try{v=' - - // prefix vars (name => data.name) - + (s.replace(re_vars, function(s, _, v) { return v ? '(d.'+v+'===undefined?window.'+v+':d.'+v+')' : s }) - - // break the expression if its empty (resulting in undefined value) - || 'x') - - + '}finally{return ' - - // default to empty string for falsy values except zero - + (nonull ? '!v&&v!==0?"":v' : 'v') - - + '}}).call(d)' - } - - - // change regexp to use custom brackets - - function re(r) { - return RegExp(r.source - .split('{').join('\\'+brackets[0]) - .split('}').join('\\'+brackets[1]), - r.global ? 'g' : '') - } - -})() -// { key, i in items} -> { key, i, items } -function loopKeys(expr) { - var ret = { val: expr }, - els = expr.split(/\s+in\s+/) - - if (els[1]) { - ret.val = '{ ' + els[1] - els = els[0].slice(1).trim().split(/,\s*/) - ret.key = els[0] - ret.pos = els[1] - } - return ret -} - -function _each(dom, parent, expr) { - - remAttr(dom, 'each') - - var template = dom.outerHTML, - prev = dom.previousSibling, - root = dom.parentNode, - rendered = [], - tags = [], - checksum - - expr = loopKeys(expr) - - // clean template code after update (and let walk finish it's parse) - parent.one('update', function() { - root.removeChild(dom) - - }).one('mount', function() { - if (!hasParent(root)) root = parent.root - - }).on('update', function() { - - var items = tmpl(expr.val, parent) - if (!items) return - - // object loop. any changes cause full redraw - if (!Array.isArray(items)) { - var testsum = JSON.stringify(items) - if (testsum == checksum) return - checksum = testsum - - // clear old items - tags.map(function(tag) { - tag.unmount() - }) - - tags = rendered = [] - - items = Object.keys(items).map(function(key, i) { - var obj = {} - obj[expr.key] = key - obj[expr.pos] = items[key] - return obj - }) - - } - - // unmount redundant - arrDiff(rendered, items).map(function(item) { - var pos = rendered.indexOf(item), - tag = tags[pos] - - if (tag) { - tag.unmount() - rendered.splice(pos, 1) - tags.splice(pos, 1) - } - }) - - // mount new - var nodes = root.childNodes, - prev_index = Array.prototype.indexOf.call(nodes, prev) - - arrDiff(items, rendered).map(function(item, i) { - - var pos = items.indexOf(item) - - if (!checksum && expr.key) { - var obj = {} - obj[expr.key] = item - obj[expr.pos] = pos - item = obj - } - - var tag = new Tag({ tmpl: template }, { - before: nodes[prev_index + 1 + pos], - parent: parent, - root: root, - loop: true, - item: item - }) - - tags.splice(pos, 0, tag) - - }) - - rendered = items.slice() - - }) - -} -function parseNamedElements(root, tag, expressions) { - walk(root, function(dom) { - if (dom.nodeType != 1) return - - each(dom.attributes, function(attr) { - if (/^(name|id)$/.test(attr.name)) tag[attr.value] = dom - }) - }) -} - -function parseLayout(root, tag, expressions) { - - function addExpr(dom, value, data) { - if (tmpl(value) || data) { - var expr = { dom: dom, expr: value } - expressions.push(extend(expr, data || {})) - } - } - - walk(root, function(dom) { - - var type = dom.nodeType - - // text node - if (type == 3 && dom.parentNode.tagName != 'STYLE') addExpr(dom, dom.nodeValue) - if (type != 1) return - - /* element */ - - // loop - var attr = dom.getAttribute('each') - if (attr) { _each(dom, tag, attr); return false } - - // child tag - var impl = tag_impl[dom.tagName.toLowerCase()] - if (impl) { - impl = new Tag(impl, { root: dom, parent: tag }) - return false - } - - // attributes - each(dom.attributes, function(attr) { - var name = attr.name, - value = attr.value - - // expressions - var bool = name.split('__')[1] - addExpr(dom, value, { attr: bool || name, bool: bool }) - - if (bool) { - remAttr(dom, name) - return false - } - - }) - - }) - -} -function Tag(impl, conf) { - - var self = riot.observable(this), - expressions = [], - attributes = {}, - parent = conf.parent, - is_loop = conf.loop, - root = conf.root, - opts = conf.opts, - item = conf.item - - // cannot initialize twice on the same root element - if (!is_loop && root.riot) return - root.riot = 1 - - opts = opts || {} - - extend(this, { parent: parent, root: root, opts: opts, children: [] }) - extend(this, item) - - - // attributes - each(root.attributes, function(attr) { - var name = attr.name, - val = attr.value - - attributes[name] = val - - // remove dynamic attributes from node - if (val.indexOf('{') >= 0) { - remAttr(root, name) - return false - } - }) - - // options - function updateOpts() { - Object.keys(attributes).map(function(name) { - opts[name] = tmpl(attributes[name], parent || self) - }) - } - - updateOpts() - - // child - parent && parent.children.push(this) - - var dom = mkdom(impl.tmpl), - loop_dom - - // named elements - parseNamedElements(dom, this) - - this.update = function(data, init) { - extend(self, data) - extend(self, item) - self.trigger('update') - updateOpts() - update(expressions, self, item) - self.trigger('updated') - } - - this.unmount = function() { - - if (is_loop) { - root.removeChild(loop_dom) - - } else { - var p = root.parentNode - p && p.removeChild(root) - } - - // splice from parent.children[] - if (parent) { - var els = parent.children - els.splice(els.indexOf(self), 1) - } - - self.trigger('unmount') - - // cleanup - parent && parent.off('update', self.update) - mounted = false - } - - function mount() { - while (dom.firstChild) { - if (is_loop) { - loop_dom = dom.firstChild - root.insertBefore(dom.firstChild, conf.before || null) // null needed for IE8 - - } else { - root.appendChild(dom.firstChild) - } - } - - if (!hasParent(root)) self.root = root = parent.root - - self.trigger('mount') - - // one way data flow: propagate updates and unmounts downwards from parent to children - parent && parent.on('update', self.update).one('unmount', self.unmount) - - } - - // initialize - if (impl.fn) impl.fn.call(this, opts) - - // layout - parseLayout(dom, this, expressions) - - this.update() - mount() - -} - - -function setEventHandler(name, handler, dom, tag, item) { - - dom[name] = function(e) { - - // cross browser event fix - e = e || window.event - e.which = e.which || e.charCode || e.keyCode - e.target = e.target || e.srcElement - e.currentTarget = dom - e.item = item - - // prevent default behaviour (by default) - if (handler.call(tag, e) !== true) { - e.preventDefault && e.preventDefault() - e.returnValue = false - } - - tag.update() - } - -} - -function insertTo(root, node, before) { - if (root) { - root.insertBefore(before, node) - root.removeChild(node) - } -} - -// item = currently looped item -function update(expressions, tag, item) { - - each(expressions, function(expr) { - var dom = expr.dom, - attr_name = expr.attr, - value = tmpl(expr.expr, tag) - - if (value == null) value = '' - - // no change - if (expr.value === value) return - expr.value = value - - // text node - if (!attr_name) return dom.nodeValue = value - - // remove attribute - if (!value && expr.bool || /obj|func/.test(typeof value)) remAttr(dom, attr_name) - - // event handler - if (typeof value == 'function') { - setEventHandler(attr_name, value, dom, tag, item) - - // if- conditional - } else if (attr_name == 'if') { - - remAttr(dom, attr_name) - - var stub = expr.stub - - // add to DOM - if (value) { - stub && insertTo(stub.parentNode, stub, dom) - - // remove from DOM - } else { - stub = expr.stub = stub || document.createTextNode('') - insertTo(dom.parentNode, dom, stub) - } - - // show / hide - } else if (/^(show|hide)$/.test(attr_name)) { - remAttr(dom, attr_name) - if (attr_name == 'hide') value = !value - dom.style.display = value ? '' : 'none' - - // normal attribute - } else { - if (expr.bool) { - dom[attr_name] = value - if (!value) return - value = attr_name - } - - dom.setAttribute(attr_name, value) - } - - }) - -} -function each(nodes, fn) { - for (var i = 0; i < (nodes || []).length; i++) { - if (fn(nodes[i], i) === false) i-- - } -} - -function remAttr(dom, name) { - dom.removeAttribute(name) -} - -function extend(obj, from) { - from && Object.keys(from).map(function(key) { - obj[key] = from[key] - }) - return obj -} - -function mkdom(template) { - var tag_name = template.trim().slice(1, 3).toLowerCase(), - root_tag = /td|th/.test(tag_name) ? 'tr' : tag_name == 'tr' ? 'tbody' : 'div' - el = document.createElement(root_tag) - - el.stub = true - el.innerHTML = template - return el -} - -function walk(dom, fn) { - dom = fn(dom) === false ? dom.nextSibling : dom.firstChild - - while (dom) { - walk(dom, fn) - dom = dom.nextSibling - } -} - -function arrDiff(arr1, arr2) { - return arr1.filter(function(el) { - return arr2.indexOf(el) < 0 - }) -} - -// HTMLDocument == IE8 thing -function hasParent(el) { - var p = el.parentNode, - doc = window.HTMLDocument - - return p && !(doc && p instanceof doc) -} - -/* - Virtual dom is an array of custom tags on the document. - Each tag stores an array of child tags. - Updates and unmounts propagate downwards from parent to children. -*/ - -var virtual_dom = [], - tag_impl = {} - -riot.tag = function(name, html, fn) { - tag_impl[name] = { name: name, tmpl: html, fn: fn } -} - -var mountTo = riot.mountTo = function(root, tagName, opts) { - var impl = tag_impl[tagName], tag - - if (impl) tag = new Tag(impl, { root: root, opts: opts }) - - if (tag) { - virtual_dom.push(tag) - return tag.on('unmount', function() { - virtual_dom.splice(virtual_dom.indexOf(tag), 1) - }) - } -} - -riot.mount = function(selector, opts) { - if (selector == '*') selector = Object.keys(tag_impl).join(', ') - - var tags = [] - - each(document.querySelectorAll(selector), function(root) { - - var tagName = root.tagName.toLowerCase(), - tag = mountTo(root, tagName, opts) - - if (tag) tags.push(tag) - }) - - return tags -} - -// update everything -riot.update = function() { - virtual_dom.map(function(tag) { - tag.update() - }) - return virtual_dom -} - - -// support CommonJS -if (typeof exports === 'object') - module.exports = riot - -// support AMD -else if (typeof define === 'function' && define.amd) - define(function() { return riot }) - -// support browser -else - this.riot = riot - -})(); \ No newline at end of file diff --git a/test/12 b/test/12 deleted file mode 100644 index 126a430..0000000 --- a/test/12 +++ /dev/null @@ -1,11 +0,0 @@ - var r = riot.route = function(arg) { - // string - if (arg[0]) { - loc.hash = arg - emit(arg) - - // function - } else { - fns.on('H', arg) - } - } \ No newline at end of file diff --git a/test/13 b/test/13 deleted file mode 100644 index ea5c97f..0000000 --- a/test/13 +++ /dev/null @@ -1,112 +0,0 @@ -module ActiveJob - module Core - extend ActiveSupport::Concern - - included do - # Job arguments - attr_accessor :arguments - attr_writer :serialized_arguments - - # Timestamp when the job should be performed - attr_accessor :scheduled_at - - # Job Identifier - attr_accessor :job_id - - # Queue in which the job will reside. - attr_writer :queue_name - end - - # These methods will be included into any Active Job object, adding - # helpers for de/serialization and creation of job instances. - module ClassMethods - # Creates a new job instance from a hash created with +serialize+ - def deserialize(job_data) - job = job_data['job_class'].constantize.new - job.deserialize(job_data) - job - end - - # Creates a job preconfigured with the given options. You can call - # perform_later with the job arguments to enqueue the job with the - # preconfigured options - # - # ==== Options - # * :wait - Enqueues the job with the specified delay - # * :wait_until - Enqueues the job at the time specified - # * :queue - Enqueues the job on the specified queue - # - # ==== Examples - # - # VideoJob.set(queue: :some_queue).perform_later(Video.last) - # VideoJob.set(wait: 5.minutes).perform_later(Video.last) - # VideoJob.set(wait_until: Time.now.tomorrow).perform_later(Video.last) - # VideoJob.set(queue: :some_queue, wait: 5.minutes).perform_later(Video.last) - # VideoJob.set(queue: :some_queue, wait_until: Time.now.tomorrow).perform_later(Video.last) - def set(options={}) - ConfiguredJob.new(self, options) - end - end - - # Creates a new job instance. Takes the arguments that will be - # passed to the perform method. - def initialize(*arguments) - @arguments = arguments - @job_id = SecureRandom.uuid - @queue_name = self.class.queue_name - end - - # Returns a hash with the job data that can safely be passed to the - # queueing adapter. - def serialize - { - 'job_class' => self.class.name, - 'job_id' => job_id, - 'queue_name' => queue_name, - 'arguments' => serialize_arguments(arguments) - } - end - - # Attaches the stored job data to the current instance. Receives a hash - # returned from +serialize+ - # - # ==== Examples - # - # class DeliverWebhookJob < ActiveJob::Base - # def serialize - # super.merge('attempt_number' => (@attempt_number || 0) + 1) - # end - # - # def deserialize(job_data) - # super - # @attempt_number = job_data['attempt_number'] - # end - # - # rescue_from(TimeoutError) do |exception| - # raise exception if @attempt_number > 5 - # retry_job(wait: 10) - # end - # end - def deserialize(job_data) - self.job_id = job_data['job_id'] - self.queue_name = job_data['queue_name'] - self.serialized_arguments = job_data['arguments'] - end - - private - def deserialize_arguments_if_needed - if defined?(@serialized_arguments) && @serialized_arguments.present? - @arguments = deserialize_arguments(@serialized_arguments) - @serialized_arguments = nil - end - end - - def serialize_arguments(serialized_args) - Arguments.serialize(serialized_args) - end - - def deserialize_arguments(serialized_args) - Arguments.deserialize(serialized_args) - end - end -end \ No newline at end of file diff --git a/test/14 b/test/14 deleted file mode 100644 index 40fa40d..0000000 --- a/test/14 +++ /dev/null @@ -1,16 +0,0 @@ -require 'formula' - -class A52dec < Formula - homepage 'http://liba52.sourceforge.net/' - url 'http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz' - sha1 '79b33bd8d89dad7436f85b9154ad35667aa37321' - - def install - system "./configure", "--disable-debug", - "--disable-dependency-tracking", - "--prefix=#{prefix}", - "--enable-shared", - "--mandir=#{man}" - system "make install" - end -end \ No newline at end of file diff --git a/test/15 b/test/15 deleted file mode 100644 index f9936b4..0000000 --- a/test/15 +++ /dev/null @@ -1,30 +0,0 @@ -module Fluent - class Input - include Configurable - include PluginId - include PluginLoggerMixin - - attr_accessor :router - - def initialize - super - end - - def configure(conf) - super - - if label_name = conf['@label'] - label = Engine.root_agent.find_label(label_name) - @router = label.event_router - elsif @router.nil? - @router = Engine.root_agent.event_router - end - end - - def start - end - - def shutdown - end - end -end \ No newline at end of file diff --git a/test/16 b/test/16 deleted file mode 100644 index 9e0b446..0000000 --- a/test/16 +++ /dev/null @@ -1,364 +0,0 @@ -{-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-} -{- -Copyright (C) 2006-2014 John MacFarlane - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --} - -{- | - Module : Text.Pandoc - Copyright : Copyright (C) 2006-2014 John MacFarlane - License : GNU GPL, version 2 or above - - Maintainer : John MacFarlane - Stability : alpha - Portability : portable - -This helper module exports the main writers, readers, and data -structure definitions from the Pandoc libraries. - -A typical application will chain together a reader and a writer -to convert strings from one format to another. For example, the -following simple program will act as a filter converting markdown -fragments to reStructuredText, using reference-style links instead of -inline links: - -> module Main where -> import Text.Pandoc -> -> markdownToRST :: String -> String -> markdownToRST = -> (writeRST def {writerReferenceLinks = True}) . readMarkdown def -> -> main = getContents >>= putStrLn . markdownToRST - -Note: all of the readers assume that the input text has @'\n'@ -line endings. So if you get your input text from a web form, -you should remove @'\r'@ characters using @filter (/='\r')@. - --} - -module Text.Pandoc - ( - -- * Definitions - module Text.Pandoc.Definition - -- * Generics - , module Text.Pandoc.Generic - -- * Options - , module Text.Pandoc.Options - -- * Lists of readers and writers - , readers - , writers - -- * Readers: converting /to/ Pandoc format - , Reader (..) - , mkStringReader - , readDocx - , readMarkdown - , readMediaWiki - , readRST - , readOrg - , readLaTeX - , readHtml - , readTextile - , readDocBook - , readOPML - , readHaddock - , readNative - , readJSON - , readTWiki - , readTxt2Tags - , readTxt2TagsNoMacros - , readEPUB - -- * Writers: converting /from/ Pandoc format - , Writer (..) - , writeNative - , writeJSON - , writeMarkdown - , writePlain - , writeRST - , writeLaTeX - , writeConTeXt - , writeTexinfo - , writeHtml - , writeHtmlString - , writeICML - , writeDocbook - , writeOPML - , writeOpenDocument - , writeMan - , writeMediaWiki - , writeDokuWiki - , writeTextile - , writeRTF - , writeODT - , writeDocx - , writeEPUB - , writeFB2 - , writeOrg - , writeAsciiDoc - , writeHaddock - , writeCustom - -- * Rendering templates and default templates - , module Text.Pandoc.Templates - -- * Version - , pandocVersion - -- * Miscellaneous - , getReader - , getWriter - , ToJsonFilter(..) - ) where - -import Text.Pandoc.Definition -import Text.Pandoc.Generic -import Text.Pandoc.JSON -import Text.Pandoc.Readers.Markdown -import Text.Pandoc.Readers.MediaWiki -import Text.Pandoc.Readers.RST -import Text.Pandoc.Readers.Org -import Text.Pandoc.Readers.DocBook -import Text.Pandoc.Readers.OPML -import Text.Pandoc.Readers.LaTeX -import Text.Pandoc.Readers.HTML -import Text.Pandoc.Readers.Textile -import Text.Pandoc.Readers.Native -import Text.Pandoc.Readers.Haddock -import Text.Pandoc.Readers.TWiki -import Text.Pandoc.Readers.Docx -import Text.Pandoc.Readers.Txt2Tags -import Text.Pandoc.Readers.EPUB -import Text.Pandoc.Writers.Native -import Text.Pandoc.Writers.Markdown -import Text.Pandoc.Writers.RST -import Text.Pandoc.Writers.LaTeX -import Text.Pandoc.Writers.ConTeXt -import Text.Pandoc.Writers.Texinfo -import Text.Pandoc.Writers.HTML -import Text.Pandoc.Writers.ODT -import Text.Pandoc.Writers.Docx -import Text.Pandoc.Writers.EPUB -import Text.Pandoc.Writers.FB2 -import Text.Pandoc.Writers.ICML -import Text.Pandoc.Writers.Docbook -import Text.Pandoc.Writers.OPML -import Text.Pandoc.Writers.OpenDocument -import Text.Pandoc.Writers.Man -import Text.Pandoc.Writers.RTF -import Text.Pandoc.Writers.MediaWiki -import Text.Pandoc.Writers.DokuWiki -import Text.Pandoc.Writers.Textile -import Text.Pandoc.Writers.Org -import Text.Pandoc.Writers.AsciiDoc -import Text.Pandoc.Writers.Haddock -import Text.Pandoc.Writers.Custom -import Text.Pandoc.Templates -import Text.Pandoc.Options -import Text.Pandoc.Shared (safeRead, warn) -import Text.Pandoc.MediaBag (MediaBag) -import Data.Aeson -import qualified Data.ByteString.Lazy as BL -import Data.List (intercalate) -import Data.Version (showVersion) -import Data.Set (Set) -import qualified Data.Set as Set -import Text.Parsec -import Text.Parsec.Error -import qualified Text.Pandoc.UTF8 as UTF8 -import Paths_pandoc (version) - --- | Version number of pandoc library. -pandocVersion :: String -pandocVersion = showVersion version - -parseFormatSpec :: String - -> Either ParseError (String, Set Extension -> Set Extension) -parseFormatSpec = parse formatSpec "" - where formatSpec = do - name <- formatName - extMods <- many extMod - return (name, foldl (.) id extMods) - formatName = many1 $ noneOf "-+" - extMod = do - polarity <- oneOf "-+" - name <- many $ noneOf "-+" - ext <- case safeRead ("Ext_" ++ name) of - Just n -> return n - Nothing - | name == "lhs" -> return Ext_literate_haskell - | otherwise -> fail $ "Unknown extension: " ++ name - return $ case polarity of - '-' -> Set.delete ext - _ -> Set.insert ext - -data Reader = StringReader (ReaderOptions -> String -> IO Pandoc) - | ByteStringReader (ReaderOptions -> BL.ByteString -> IO (Pandoc, MediaBag)) - -mkStringReader :: (ReaderOptions -> String -> Pandoc) -> Reader -mkStringReader r = StringReader (\o s -> return $ r o s) - -mkStringReaderWithWarnings :: (ReaderOptions -> String -> (Pandoc, [String])) -> Reader -mkStringReaderWithWarnings r = StringReader $ \o s -> do - let (doc, warnings) = r o s - mapM_ warn warnings - return doc - -mkBSReader :: (ReaderOptions -> BL.ByteString -> (Pandoc, MediaBag)) -> Reader -mkBSReader r = ByteStringReader (\o s -> return $ r o s) - --- | Association list of formats and readers. -readers :: [(String, Reader)] -readers = [ ("native" , StringReader $ \_ s -> return $ readNative s) - ,("json" , mkStringReader readJSON ) - ,("markdown" , mkStringReaderWithWarnings readMarkdownWithWarnings) - ,("markdown_strict" , mkStringReaderWithWarnings readMarkdownWithWarnings) - ,("markdown_phpextra" , mkStringReaderWithWarnings readMarkdownWithWarnings) - ,("markdown_github" , mkStringReaderWithWarnings readMarkdownWithWarnings) - ,("markdown_mmd", mkStringReaderWithWarnings readMarkdownWithWarnings) - ,("rst" , mkStringReaderWithWarnings readRSTWithWarnings ) - ,("mediawiki" , mkStringReader readMediaWiki) - ,("docbook" , mkStringReader readDocBook) - ,("opml" , mkStringReader readOPML) - ,("org" , mkStringReader readOrg) - ,("textile" , mkStringReader readTextile) -- TODO : textile+lhs - ,("html" , mkStringReader readHtml) - ,("latex" , mkStringReader readLaTeX) - ,("haddock" , mkStringReader readHaddock) - ,("twiki" , mkStringReader readTWiki) - ,("docx" , mkBSReader readDocx) - ,("t2t" , mkStringReader readTxt2TagsNoMacros) - ,("epub" , mkBSReader readEPUB) - ] - -data Writer = PureStringWriter (WriterOptions -> Pandoc -> String) - | IOStringWriter (WriterOptions -> Pandoc -> IO String) - | IOByteStringWriter (WriterOptions -> Pandoc -> IO BL.ByteString) - --- | Association list of formats and writers. -writers :: [ ( String, Writer ) ] -writers = [ - ("native" , PureStringWriter writeNative) - ,("json" , PureStringWriter writeJSON) - ,("docx" , IOByteStringWriter writeDocx) - ,("odt" , IOByteStringWriter writeODT) - ,("epub" , IOByteStringWriter $ \o -> - writeEPUB o{ writerEpubVersion = Just EPUB2 }) - ,("epub3" , IOByteStringWriter $ \o -> - writeEPUB o{ writerEpubVersion = Just EPUB3 }) - ,("fb2" , IOStringWriter writeFB2) - ,("html" , PureStringWriter writeHtmlString) - ,("html5" , PureStringWriter $ \o -> - writeHtmlString o{ writerHtml5 = True }) - ,("icml" , PureStringWriter writeICML) - ,("s5" , PureStringWriter $ \o -> - writeHtmlString o{ writerSlideVariant = S5Slides - , writerTableOfContents = False }) - ,("slidy" , PureStringWriter $ \o -> - writeHtmlString o{ writerSlideVariant = SlidySlides }) - ,("slideous" , PureStringWriter $ \o -> - writeHtmlString o{ writerSlideVariant = SlideousSlides }) - ,("dzslides" , PureStringWriter $ \o -> - writeHtmlString o{ writerSlideVariant = DZSlides - , writerHtml5 = True }) - ,("revealjs" , PureStringWriter $ \o -> - writeHtmlString o{ writerSlideVariant = RevealJsSlides - , writerHtml5 = True }) - ,("docbook" , PureStringWriter writeDocbook) - ,("opml" , PureStringWriter writeOPML) - ,("opendocument" , PureStringWriter writeOpenDocument) - ,("latex" , PureStringWriter writeLaTeX) - ,("beamer" , PureStringWriter $ \o -> - writeLaTeX o{ writerBeamer = True }) - ,("context" , PureStringWriter writeConTeXt) - ,("texinfo" , PureStringWriter writeTexinfo) - ,("man" , PureStringWriter writeMan) - ,("markdown" , PureStringWriter writeMarkdown) - ,("markdown_strict" , PureStringWriter writeMarkdown) - ,("markdown_phpextra" , PureStringWriter writeMarkdown) - ,("markdown_github" , PureStringWriter writeMarkdown) - ,("markdown_mmd" , PureStringWriter writeMarkdown) - ,("plain" , PureStringWriter writePlain) - ,("rst" , PureStringWriter writeRST) - ,("mediawiki" , PureStringWriter writeMediaWiki) - ,("dokuwiki" , PureStringWriter writeDokuWiki) - ,("textile" , PureStringWriter writeTextile) - ,("rtf" , IOStringWriter writeRTFWithEmbeddedImages) - ,("org" , PureStringWriter writeOrg) - ,("asciidoc" , PureStringWriter writeAsciiDoc) - ,("haddock" , PureStringWriter writeHaddock) - ] - -getDefaultExtensions :: String -> Set Extension -getDefaultExtensions "markdown_strict" = strictExtensions -getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions -getDefaultExtensions "markdown_mmd" = multimarkdownExtensions -getDefaultExtensions "markdown_github" = githubMarkdownExtensions -getDefaultExtensions "markdown" = pandocExtensions -getDefaultExtensions "plain" = pandocExtensions -getDefaultExtensions "org" = Set.fromList [Ext_citations] -getDefaultExtensions "textile" = Set.fromList [Ext_auto_identifiers] -getDefaultExtensions "html" = Set.fromList [Ext_auto_identifiers, - Ext_native_divs, - Ext_native_spans] -getDefaultExtensions "html5" = getDefaultExtensions "html" -getDefaultExtensions "epub" = Set.fromList [Ext_auto_identifiers, - Ext_raw_html, - Ext_native_divs, - Ext_native_spans, - Ext_epub_html_exts] -getDefaultExtensions _ = Set.fromList [Ext_auto_identifiers] - --- | Retrieve reader based on formatSpec (format+extensions). -getReader :: String -> Either String Reader -getReader s = - case parseFormatSpec s of - Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e] - Right (readerName, setExts) -> - case lookup readerName readers of - Nothing -> Left $ "Unknown reader: " ++ readerName - Just (StringReader r) -> Right $ StringReader $ \o -> - r o{ readerExtensions = setExts $ - getDefaultExtensions readerName } - Just (ByteStringReader r) -> Right $ ByteStringReader $ \o -> - r o{ readerExtensions = setExts $ - getDefaultExtensions readerName } - --- | Retrieve writer based on formatSpec (format+extensions). -getWriter :: String -> Either String Writer -getWriter s - = case parseFormatSpec s of - Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e] - Right (writerName, setExts) -> - case lookup writerName writers of - Nothing -> Left $ "Unknown writer: " ++ writerName - Just (PureStringWriter r) -> Right $ PureStringWriter $ - \o -> r o{ writerExtensions = setExts $ - getDefaultExtensions writerName } - Just (IOStringWriter r) -> Right $ IOStringWriter $ - \o -> r o{ writerExtensions = setExts $ - getDefaultExtensions writerName } - Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $ - \o -> r o{ writerExtensions = setExts $ - getDefaultExtensions writerName } - -{-# DEPRECATED toJsonFilter "Use 'toJSONFilter' from 'Text.Pandoc.JSON' instead" #-} --- | Deprecated. Use @toJSONFilter@ from @Text.Pandoc.JSON@ instead. -class ToJSONFilter a => ToJsonFilter a - where toJsonFilter :: a -> IO () - toJsonFilter = toJSONFilter - -readJSON :: ReaderOptions -> String -> Pandoc -readJSON _ = either error id . eitherDecode' . UTF8.fromStringLazy - -writeJSON :: WriterOptions -> Pandoc -> String -writeJSON _ = UTF8.toStringLazy . encode \ No newline at end of file diff --git a/test/17 b/test/17 deleted file mode 100644 index 6b0eb12..0000000 --- a/test/17 +++ /dev/null @@ -1,5 +0,0 @@ -reverseDependencies :: ModuleGraph -> M.Map ModuleName [ModuleName] -reverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ] - where - combine :: (Ord a) => [(a, b)] -> M.Map a [b] - combine = M.fromList . map ((fst . head) &&& map snd) . groupBy ((==) `on` fst) . sortBy (compare `on` fst) \ No newline at end of file diff --git a/test/18 b/test/18 deleted file mode 100644 index 14cec7c..0000000 --- a/test/18 +++ /dev/null @@ -1,69 +0,0 @@ -{- git-annex extra config files - - - - Copyright 2012 Joey Hess - - - - Licensed under the GNU GPL version 3 or higher. - -} - -module Config.Files where - -import Common -import Utility.Tmp -import Utility.FreeDesktop - -{- ~/.config/git-annex/file -} -userConfigFile :: FilePath -> IO FilePath -userConfigFile file = do - dir <- userConfigDir - return $ dir "git-annex" file - -autoStartFile :: IO FilePath -autoStartFile = userConfigFile "autostart" - -{- Returns anything listed in the autostart file (which may not exist). -} -readAutoStartFile :: IO [FilePath] -readAutoStartFile = do - f <- autoStartFile - nub . map dropTrailingPathSeparator . lines - <$> catchDefaultIO "" (readFile f) - -modifyAutoStartFile :: ([FilePath] -> [FilePath]) -> IO () -modifyAutoStartFile func = do - dirs <- readAutoStartFile - let dirs' = nubBy equalFilePath $ func dirs - when (dirs' /= dirs) $ do - f <- autoStartFile - createDirectoryIfMissing True (parentDir f) - viaTmp writeFile f $ unlines dirs' - -{- Adds a directory to the autostart file. If the directory is already - - present, it's moved to the top, so it will be used as the default - - when opening the webapp. -} -addAutoStartFile :: FilePath -> IO () -addAutoStartFile path = modifyAutoStartFile $ (:) path - -{- Removes a directory from the autostart file. -} -removeAutoStartFile :: FilePath -> IO () -removeAutoStartFile path = modifyAutoStartFile $ - filter (not . equalFilePath path) - -{- The path to git-annex is written here; which is useful when cabal - - has installed it to some awful non-PATH location. -} -programFile :: IO FilePath -programFile = userConfigFile "program" - -{- Returns a command to run for git-annex. -} -readProgramFile :: IO FilePath -readProgramFile = do - programfile <- programFile - p <- catchDefaultIO cmd $ - fromMaybe cmd . headMaybe . lines <$> readFile programfile - ifM (inPath p) - ( return p - , ifM (inPath cmd) - ( return cmd - , error $ "cannot find git-annex program in PATH or in the location listed in " ++ programfile - ) - ) - where - cmd = "git-annex" \ No newline at end of file diff --git a/test/19 b/test/19 deleted file mode 100644 index 5ec4ae6..0000000 --- a/test/19 +++ /dev/null @@ -1,18 +0,0 @@ -(define subst-f - (lambda (new old l) - (cond - ((null? l) '()) - ((eq? (car l) old) - (cons new (cdr l))) - (else - (cons (car l) (subst new old (cdr l))))))) - -; The seqS function is what subst does that neither insertL nor insertR do -; -(define seqS - (lambda (new old l) - (cons new l))) - -; subst is now just (insret-g seqS) -; -(define subst (insert-g seqS)) \ No newline at end of file diff --git a/test/2 b/test/2 deleted file mode 100644 index 113faf7..0000000 --- a/test/2 +++ /dev/null @@ -1,9 +0,0 @@ -(ns my-cli.core) - -(defn -main [& args] - (println "My CLI received arguments:" args)) - -(defn add-main [& args] - (->> (map #(Integer/parseInt %) args) - (reduce + 0) - (println "The sum is:"))) \ No newline at end of file diff --git a/test/20 b/test/20 deleted file mode 100644 index 1b9aceb..0000000 --- a/test/20 +++ /dev/null @@ -1,2 +0,0 @@ -(define add1 - (lambda (n) (+ n 1))) \ No newline at end of file diff --git a/test/21 b/test/21 deleted file mode 100644 index 53d22a0..0000000 --- a/test/21 +++ /dev/null @@ -1,220 +0,0 @@ -(define-lib-primitive (length lst) - (if (null? lst) - 0 - (fxadd1 (length (cdr lst))))) - -(define-lib-primitive (fill args setop) - (letrec ([rec (lambda (index args) - (unless (null? args) - (setop index (car args)) - (rec (fxadd1 index) (cdr args))))]) - (rec 0 args))) - -(define-lib-primitive (vector . args) - (let ([v (make-vector (length args))]) - (fill args (lambda (index arg) (vector-set! v index arg))) - v)) - -(define-lib-primitive (string . args) - (let ([s (make-string (length args))]) - (fill args (lambda (index arg) (string-set! s index arg))) - s)) - -(define-lib-primitive (list . args) - args) - -(define-lib-primitive (make_cell value) - (cons value '())) - -(define-lib-primitive (cell_get cell) - (car cell)) - -(define-lib-primitive (cell_set cell value) - (set-car! cell value)) - -(define-lib-primitive __symbols__ - (make_cell '())) - -(define-lib-primitive (string=? s1 s2) - (letrec ([rec (lambda (index) - (or (fx= index (string-length s1)) - (and (char= (string-ref s1 index) (string-ref s2 index)) - (rec (fxadd1 index)))))]) - (and (string? s1) (string? s2) (fx= (string-length s1) (string-length s2)) (rec 0)))) - -(define-lib-primitive (__find_symbol__ str) - (letrec ([rec (lambda (symbols) - (cond - [(null? symbols) #f] - [(string=? str (string-symbol (car symbols))) (car symbols)] - [else (rec (cdr symbols))]))]) - (rec (cell_get __symbols__)))) - -(define-lib-primitive (string->symbol str) - (or (__find_symbol__ str) - (let ([symbol (make-symbol str)]) - (cell_set __symbols__ (cons symbol (cell_get __symbols__))) - symbol))) - -(define-lib-primitive (error . args) - (foreign-call "ik_error" args)) - -(define-lib-primitive (log msg) - (foreign-call "ik_log" msg)) - -(define-lib-primitive (string-set! s i c) - (cond - [(not (string? s)) (error)] - [(not (fixnum? i)) (error)] - [(not (char? c)) (error)] - [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)] - [else ($string-set! s i c)])) - -(define-lib-primitive (string-ref s i) - (cond - [(not (string? s)) (error)] - [(not (fixnum? i)) (error)] - [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)] - [else ($string-ref s i)])) - -(define-lib-primitive (vector-set! v i e) - (cond - [(not (vector? v)) (error)] - [(not (fixnum? i)) (error)] - [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)] - [else ($vector-set! v i e)])) - -(define-lib-primitive (vector-ref v i) - (cond - [(not (vector? v)) (error)] - [(not (fixnum? i)) (error)] - [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)] - [else ($vector-ref v i)])) - -(define-lib-primitive (liftneg f a b) - (cond - [(and (fx< a 0) (fx>= b 0)) - (fx- 0 (f (fx- 0 a) b))] - [(and (fx>= a 0) (fx< b 0)) - (fx- 0 (f a (fx- 0 b)))] - [(and (fx< a 0) (fx< b 0)) - (f (fx- 0 a) (fx- 0 b))] - [else - (f a b)])) - -(define-lib-primitive (liftneg1 f a b) - (cond - [(and (fx< a 0) (fx>= b 0)) - (fx- 0 (f (fx- 0 a) b))] - [(and (fx>= a 0) (fx< b 0)) - (f a (fx- 0 b))] - [(and (fx< a 0) (fx< b 0)) - (fx- 0 (f (fx- 0 a) (fx- 0 b)))] - [else - (f a b)])) - -(define-lib-primitive (fxquotient a b) - (liftneg (lambda (a b) ($fxquotient a b)) a b)) - -(define-lib-primitive (fxremainder a b) - (liftneg1 (lambda (a b) ($fxremainder a b)) a b)) - -(define-lib-primitive (exit . args) - (let ([status (if (null? args) 0 (car args))]) - (foreign-call "exit" status))) - -(define-lib-primitive (s_write fd str len) - (foreign-call "s_write" fd str len)) - -(define-lib-primitive stdout - (make-output-port "" 1)) - -(define-lib-primitive (current-output-port) - stdout) - -(define-lib-primitive BUFFER_SIZE 4096) - -(define-lib-primitive (open-output-file fname . args) - (let ([fd (foreign-call "s_open_write" fname)]) - (make-output-port fname fd))) - -(define-lib-primitive (make-output-port fname fd) - (vector 'output-port fname fd (make-string BUFFER_SIZE) 0 BUFFER_SIZE)) - -(define-lib-primitive (output-port-fname port) - (vector-ref port 1)) - -(define-lib-primitive (output-port-fd port) - (vector-ref port 2)) - -(define-lib-primitive (output-port-buffer port) - (vector-ref port 3)) - -(define-lib-primitive (output-port-buffer-index port) - (vector-ref port 4)) - -(define-lib-primitive (output-port-buffer-size port) - (vector-ref port 5)) - -(define-lib-primitive (set-output-port-buffer-index! port index) - (vector-set! port 4 index)) - -(define-lib-primitive (inc-output-port-buffer-index! port) - (set-output-port-buffer-index! port (fxadd1 (output-port-buffer-index port)))) - -(define-lib-primitive (write-char c (port (current-output-port))) - (string-set! (output-port-buffer port) (output-port-buffer-index port) c) - (inc-output-port-buffer-index! port) - (when (fx= (output-port-buffer-index port) (output-port-buffer-size port)) - (output-port-write-buffer port))) - -(define-lib-primitive (output-port? x) - (and (vector? x) (fx= (vector-length x) 6) (eq? 'output-port (vector-ref x 0)))) - -(define-lib-primitive (output-port-write-buffer port) - (s_write (output-port-fd port) - (output-port-buffer port) - (output-port-buffer-index port)) - (set-output-port-buffer-index! port 0)) - -(define-lib-primitive (flush-output-port (port (current-output-port))) - (output-port-write-buffer port) - (foreign-call "s_fflush" (output-port-fd port))) - -(define-lib-primitive (close-output-port port) - (flush-output-port port) - (unless (string=? "" (output-port-fname port)) - (foreign-call "s_close" (output-port-fd port)))) - -(define-lib-primitive (write x (port (current-output-port))) - (flush-output-port port) - ;; This is cheating... should write it in Scheme. - (foreign-call "scheme_write" (output-port-fd port) x 0) - (flush-output-port port)) - -(define-lib-primitive (display x (port (current-output-port))) - (flush-output-port port) - (foreign-call "scheme_write" (output-port-fd port) x 2) - (flush-output-port port)) - -(define-lib-primitive (open-input-file fname . args) - (let ([fd (foreign-call "s_open_read" fname)]) - (make-input-port fname fd))) - -(define-lib-primitive (make-input-port fname fd) - (vector 'input-port fname fd)) - -(define-lib-primitive (input-port-fname port) - (vector-ref port 1)) - -(define-lib-primitive (input-port-fd port) - (vector-ref port 2)) - -(define-lib-primitive (input-port? x) - (and (vector? x) (fx= (vector-length x) 3) (eq? 'input-port (vector-ref x 0)))) - -(define-lib-primitive (read-char port) - (foreign-call "s_read_char" (input-port-fd port))) - -(define-lib-primitive (close-input-port port) - (foreign-call "s_close" (input-port-fd port))) \ No newline at end of file diff --git a/test/22 b/test/22 deleted file mode 100644 index 8dedd41..0000000 --- a/test/22 +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Interface to represent a persistence store for archives - * - * @author James Kojo - * @author Vasanth Asokan - */ -public interface ArchiveRepository { - /** - * Get the ID of this repository - * @return the id string. - */ - public String getRepositoryId(); - - /** - * Get the default view into this repository. - * @return the default repository view. - */ - public RepositoryView getDefaultView(); - - /** - * Get a specific named view into this repository. - * - * @param view the name of the view. - * @return a {@link RepositoryView} that matches the given name or null if - * one wasn't found. - * @throws UnsupportedOperationException - * if this repository does not support named views. - */ - public RepositoryView getView(String view); - - /** - * Insert a Jar into the repository - * @param jarScriptArchive script archive which describes the jar and - * the ModuleSpec which should be inserted - */ - public void insertArchive(JarScriptArchive jarScriptArchive) - throws IOException; - - /** - * Insert a Jar into the repository - * @param jarScriptArchive script archive which describes the jar and - * the ModuleSpec which should be inserted - * @param initialDeploySpecs a set of initial deployment specs. - * @throws UnsupportedOperationException if this repository does not support - * adding deploy specs to a module. - */ - public void insertArchive(JarScriptArchive jarScriptArchive, Map initialDeploySpecs) - throws IOException; - - /** - * Get all of the {@link ScriptArchive}s for the given set of moduleIds. - * - * @param moduleIds keys to search for - * @return set of ScriptArchives retrieved from the database - */ - public Set getScriptArchives(Set moduleIds) throws IOException; - - /** - * Delete an archive by ID - * @param moduleId module id to delete - * @throws IOException - */ - public void deleteArchive(ModuleId moduleId) throws IOException; -} \ No newline at end of file diff --git a/test/23 b/test/23 deleted file mode 100644 index ec2333d..0000000 --- a/test/23 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2002-2008 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.core; - -/** - * Common interface for managing aliases. Serves as super-interface for - * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}. - * - * @author Juergen Hoeller - * @since 2.5.2 - */ -public interface AliasRegistry { - - /** - * Given a name, register an alias for it. - * @param name the canonical name - * @param alias the alias to be registered - * @throws IllegalStateException if the alias is already in use - * and may not be overridden - */ - void registerAlias(String name, String alias); - - /** - * Remove the specified alias from this registry. - * @param alias the alias to remove - * @throws IllegalStateException if no such alias was found - */ - void removeAlias(String alias); - - /** - * Determine whether this given name is defines as an alias - * (as opposed to the name of an actually registered component). - * @param beanName the bean name to check - * @return whether the given name is an alias - */ - boolean isAlias(String beanName); - - /** - * Return the aliases for the given name, if defined. - * @param name the name to check for aliases - * @return the aliases, or an empty array if none - */ - String[] getAliases(String name); - -} \ No newline at end of file diff --git a/test/24 b/test/24 deleted file mode 100644 index ffed0c6..0000000 --- a/test/24 +++ /dev/null @@ -1,77 +0,0 @@ -package com.github.pathikrit - -import scala.annotation.StaticAnnotation - -class MetaRest extends StaticAnnotation { - def macroTransform(annottees: Any*): Any = macro MetaRest.impl -} - -object MetaRest { - sealed trait MethodAnnotations extends StaticAnnotation - class get extends MethodAnnotations - class put extends MethodAnnotations - class post extends MethodAnnotations - class patch extends MethodAnnotations - object MethodAnnotations { - val values = List("get", "post", "put", "patch") //TODO: use some enum/sealed trait macro to do this automatically - } - - def impl(c: macros.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - - def withCompileError[A](msg: String)(block: => A): A = try { - block - } catch { - case _: MatchError => c.abort(c.enclosingPosition, s"@MetaRest: $msg") - } - - def generateModels(fields: List[ValDef]) = { - val fieldsWithAnnotations = fields.map(_.mods.annotations).zip(fields) - val newFields = fieldsWithAnnotations flatMap { case (annotations, field) => - annotations.map(_ -> field) collect { - case (q"new patch", q"$accessor val $vname: $tpe") => "patch" -> q"$accessor val $vname: Option[$tpe] = None" - case (q"new $annotation", f) if MethodAnnotations.values contains annotation.toString => annotation.toString -> f.duplicate - } - } - newFields.groupBy(_._1) map { case (annotation, values) => - val (className, classFields) = (macros.toTypeName(c)(annotation.capitalize), values.map(_._2)) - q"@com.kifi.macros.json case class $className(..$classFields)" //TODO: Switch back to jsonstrict once this is fixed: https://github.com/kifi/json-annotation/issues/7 - } - } - - def modifiedDeclaration(classDecl: ClassDef, compDeclOpt: Option[ModuleDef] = None) = { - val (className, fields) = withCompileError("must annotate a case class") { - val q"case class $className(..$fields) extends ..$bases { ..$body }" = classDecl - (className, fields) - } - - val compDecl = compDeclOpt map { compDecl => - val q"object $obj extends ..$bases { ..$body }" = compDecl - q""" - object $obj extends ..$bases { - ..$body - ..${generateModels(fields)} - } - """ - } getOrElse { - q""" - object ${className.toTermName} { - ..${generateModels(fields)} - } - """ - } - - c.Expr(q""" - $classDecl - $compDecl - """) - } - - withCompileError("must annotate a class") { - annottees.map(_.tree) match { - case (classDecl: ClassDef) :: Nil => modifiedDeclaration(classDecl) - case (classDecl: ClassDef) :: (compDecl: ModuleDef) :: Nil => modifiedDeclaration(classDecl, Some(compDecl)) - } - } - } -} \ No newline at end of file diff --git a/test/25 b/test/25 deleted file mode 100644 index 42e4a35..0000000 --- a/test/25 +++ /dev/null @@ -1,48 +0,0 @@ -/* sbt -- Simple Build Tool - * Copyright 2010, 2011 Mark Harrah - */ -package object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtra with sbt.impl.DependencyBuilders - with sbt.PathExtra with sbt.ProjectExtra with sbt.DependencyFilterExtra with sbt.BuildExtra with sbt.TaskMacroExtra - with sbt.ScopeFilter.Make { - type Setting[T] = Def.Setting[T] - type ScopedKey[T] = Def.ScopedKey[T] - type SettingsDefinition = Def.SettingsDefinition - type File = java.io.File - type URI = java.net.URI - type URL = java.net.URL - - object CompileOrder { - val JavaThenScala = xsbti.compile.CompileOrder.JavaThenScala - val ScalaThenJava = xsbti.compile.CompileOrder.ScalaThenJava - val Mixed = xsbti.compile.CompileOrder.Mixed - } - type CompileOrder = xsbti.compile.CompileOrder - - implicit def maybeToOption[S](m: xsbti.Maybe[S]): Option[S] = - if (m.isDefined) Some(m.get) else None - def uri(s: String): URI = new URI(s) - def file(s: String): File = new File(s) - def url(s: String): URL = new URL(s) - - final val ThisScope = Scope.ThisScope - final val GlobalScope = Scope.GlobalScope - - import sbt.{ Configurations => C } - final val Compile = C.Compile - final val Test = C.Test - final val Runtime = C.Runtime - final val IntegrationTest = C.IntegrationTest - final val Default = C.Default - final val Docs = C.Docs - final val Sources = C.Sources - final val Provided = C.Provided - // java.lang.System is more important, so don't alias this one - // final val System = C.System - final val Optional = C.Optional - def config(s: String): Configuration = Configurations.config(s) - - import language.experimental.macros - def settingKey[T](description: String): SettingKey[T] = macro std.KeyMacro.settingKeyImpl[T] - def taskKey[T](description: String): TaskKey[T] = macro std.KeyMacro.taskKeyImpl[T] - def inputKey[T](description: String): InputKey[T] = macro std.KeyMacro.inputKeyImpl[T] -} \ No newline at end of file diff --git a/test/26 b/test/26 deleted file mode 100644 index 182f919..0000000 --- a/test/26 +++ /dev/null @@ -1,35 +0,0 @@ -proc isaac::mix {a b c d e f g h} { - set a [expr {($a ^ ($b << 11)) & 0xffffffff}] - set d [expr {($d + $a) & 0xffffffff}] - set b [expr {($b + $c) & 0xffffffff}] - - set b [expr {($b ^ ($c >> 2)) & 0xffffffff}] - set e [expr {($e + $b) & 0xffffffff}] - set c [expr {($c + $d) & 0xffffffff}] - - set c [expr {($c ^ ($d << 8)) & 0xffffffff}] - set f [expr {($f + $c) & 0xffffffff}] - set d [expr {($d + $e) & 0xffffffff}] - - set d [expr {($d ^ ($e >> 16)) & 0xffffffff}] - set g [expr {($g + $d) & 0xffffffff}] - set e [expr {($e + $f) & 0xffffffff}] - - set e [expr {($e ^ ($f << 10)) & 0xffffffff}] - set h [expr {($h + $e) & 0xffffffff}] - set f [expr {($f + $g) & 0xffffffff}] - - set f [expr {($f ^ ($g >> 4)) & 0xffffffff}] - set a [expr {($a + $f) & 0xffffffff}] - set g [expr {($g + $h) & 0xffffffff}] - - set g [expr {($g ^ ($h << 8)) & 0xffffffff}] - set b [expr {($b + $g) & 0xffffffff}] - set h [expr {($h + $a) & 0xffffffff}] - - set h [expr {($h ^ ($a >> 9)) & 0xffffffff}] - set c [expr {($c + $h) & 0xffffffff}] - set a [expr {($a + $b) & 0xffffffff}] - - return [list $a $b $c $d $e $f $g $h] -} diff --git a/test/27 b/test/27 deleted file mode 100644 index 902ec5c..0000000 --- a/test/27 +++ /dev/null @@ -1,20 +0,0 @@ -proc twitter::follow {nick uhost hand chan argv} { - if {![channel get $chan twitter]} { return } - - if {[string length $argv] < 1} { - $twitter::output_cmd "PRIVMSG $chan :Usage: !follow " - return - } - - if {[catch {::twitlib::query $::twitlib::follow_url [list screen_name $argv]} result]} { - $twitter::output_cmd "PRIVMSG $chan :Twitter failed or already friends with $argv!" - return - } - - if {[dict exists $result error]} { - twitter::output $chan "Follow failed ($argv): [dict get $result error]" - return - } - - twitter::output $chan "Now following [dict get $result screen_name]!" -} \ No newline at end of file diff --git a/test/28 b/test/28 deleted file mode 100644 index 3cc77a3..0000000 --- a/test/28 +++ /dev/null @@ -1,209 +0,0 @@ -class View -{ - /** - * Data available to the view templates - * @var \Slim\Helper\Set - */ - protected $data; - /** - * Path to templates base directory (without trailing slash) - * @var string - */ - protected $templatesDirectory; - /** - * Constructor - */ - public function __construct() - { - $this->data = new \Slim\Helper\Set(); - } - /******************************************************************************** - * Data methods - *******************************************************************************/ - /** - * Does view data have value with key? - * @param string $key - * @return boolean - */ - public function has($key) - { - return $this->data->has($key); - } - /** - * Return view data value with key - * @param string $key - * @return mixed - */ - public function get($key) - { - return $this->data->get($key); - } - /** - * Set view data value with key - * @param string $key - * @param mixed $value - */ - public function set($key, $value) - { - $this->data->set($key, $value); - } - /** - * Set view data value as Closure with key - * @param string $key - * @param mixed $value - */ - public function keep($key, \Closure $value) - { - $this->data->keep($key, $value); - } - /** - * Return view data - * @return array - */ - public function all() - { - return $this->data->all(); - } - /** - * Replace view data - * @param array $data - */ - public function replace(array $data) - { - $this->data->replace($data); - } - /** - * Clear view data - */ - public function clear() - { - $this->data->clear(); - } - /******************************************************************************** - * Legacy data methods - *******************************************************************************/ - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Get data from view - */ - public function getData($key = null) - { - if (!is_null($key)) { - return isset($this->data[$key]) ? $this->data[$key] : null; - } else { - return $this->data->all(); - } - } - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Set data for view - */ - public function setData() - { - $args = func_get_args(); - if (count($args) === 1 && is_array($args[0])) { - $this->data->replace($args[0]); - } elseif (count($args) === 2) { - // Ensure original behavior is maintained. DO NOT invoke stored Closures. - if (is_object($args[1]) && method_exists($args[1], '__invoke')) { - $this->data->set($args[0], $this->data->protect($args[1])); - } else { - $this->data->set($args[0], $args[1]); - } - } else { - throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`'); - } - } - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Append data to view - * @param array $data - */ - public function appendData($data) - { - if (!is_array($data)) { - throw new \InvalidArgumentException('Cannot append view data. Expected array argument.'); - } - $this->data->replace($data); - } - /******************************************************************************** - * Resolve template paths - *******************************************************************************/ - /** - * Set the base directory that contains view templates - * @param string $directory - * @throws \InvalidArgumentException If directory is not a directory - */ - public function setTemplatesDirectory($directory) - { - $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR); - } - /** - * Get templates base directory - * @return string - */ - public function getTemplatesDirectory() - { - return $this->templatesDirectory; - } - /** - * Get fully qualified path to template file using templates base directory - * @param string $file The template file pathname relative to templates base directory - * @return string - */ - public function getTemplatePathname($file) - { - return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR); - } - /******************************************************************************** - * Rendering - *******************************************************************************/ - /** - * Display template - * - * This method echoes the rendered template to the current output buffer - * - * @param string $template Pathname of template file relative to templates directory - * @param array $data Any additonal data to be passed to the template. - */ - public function display($template, $data = null) - { - echo $this->fetch($template, $data); - } - /** - * Return the contents of a rendered template file - * - * @param string $template The template pathname, relative to the template base directory - * @param array $data Any additonal data to be passed to the template. - * @return string The rendered template - */ - public function fetch($template, $data = null) - { - return $this->render($template, $data); - } - /** - * Render a template file - * - * NOTE: This method should be overridden by custom view subclasses - * - * @param string $template The template pathname, relative to the template base directory - * @param array $data Any additonal data to be passed to the template. - * @return string The rendered template - * @throws \RuntimeException If resolved template pathname is not a valid file - */ - protected function render($template, $data = null) - { - $templatePathname = $this->getTemplatePathname($template); - if (!is_file($templatePathname)) { - throw new \RuntimeException("View cannot render `$template` because the template does not exist"); - } - $data = array_merge($this->data->all(), (array) $data); - extract($data); - ob_start(); - require $templatePathname; - return ob_get_clean(); - } -} \ No newline at end of file diff --git a/test/29 b/test/29 deleted file mode 100644 index 1af6e83..0000000 --- a/test/29 +++ /dev/null @@ -1,9 +0,0 @@ - public function formatLocalized($format) - { - // Check for Windows to find and replace the %e - // modifier correctly - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { - $format = preg_replace('#(?getContainer(); - /** - * Controllers - */ - $container->registerService('LostController', function(SimpleContainer $c) { - return new LostController( - $c->query('AppName'), - $c->query('Request'), - $c->query('URLGenerator'), - $c->query('UserManager'), - $c->query('Defaults'), - $c->query('L10N'), - $c->query('Config'), - $c->query('SecureRandom'), - $c->query('DefaultEmailAddress'), - $c->query('IsEncryptionEnabled') - ); - }); - $container->registerService('UserController', function(SimpleContainer $c) { - return new UserController( - $c->query('AppName'), - $c->query('Request'), - $c->query('UserManager'), - $c->query('Defaults') - ); - }); - /** - * Core class wrappers - */ - $container->registerService('IsEncryptionEnabled', function() { - return \OC_App::isEnabled('files_encryption'); - }); - $container->registerService('URLGenerator', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getURLGenerator(); - }); - $container->registerService('UserManager', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getUserManager(); - }); - $container->registerService('Config', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getConfig(); - }); - $container->registerService('L10N', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getL10N('core'); - }); - $container->registerService('SecureRandom', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getSecureRandom(); - }); - $container->registerService('Defaults', function() { - return new \OC_Defaults; - }); - $container->registerService('DefaultEmailAddress', function() { - return Util::getDefaultEmailAddress('lostpassword-noreply'); - }); - } -} \ No newline at end of file diff --git a/test/31 b/test/31 deleted file mode 100644 index 77b507c..0000000 --- a/test/31 +++ /dev/null @@ -1,213 +0,0 @@ -type name = string - -let compare_label label1 label2 = - let compare_length = compare (String.length label1) (String.length label2) in - if compare_length = 0 then - String.compare label1 label2 - else compare_length - - -module LabelMap = Map.Make( - struct - type t = name - let compare = compare_label - end) - -type expr = - | Var of name (* variable *) - | Call of expr * expr list (* application *) - | Fun of name list * expr (* abstraction *) - | Let of name * expr * expr (* let *) - | RecordSelect of expr * name (* selecting value of label: `r.a` *) - | RecordExtend of (expr list) LabelMap.t * expr (* extending a record: `{a = 1, b = 2 | r}` *) - | RecordRestrict of expr * name (* deleting a label: `{r - a}` *) - | RecordEmpty (* empty record: `{}` *) - | Variant of name * expr (* new variant value: `:X a` *) - | Case of expr * (name * name * expr) list * (name * expr) option - (* a pattern-matching case expression: - match e { - :X a -> expr1 - | :Y b -> expr2 - ... - | z -> default_expr (optional) - } - *) - -type id = int -type level = int - -type ty = - | TConst of name (* type constant: `int` or `bool` *) - | TApp of ty * ty list (* type application: `list[int]` *) - | TArrow of ty list * ty (* function type: `(int, int) -> int` *) - | TVar of tvar ref (* type variable *) - | TRecord of row (* record type: `{...}` *) - | TVariant of row (* variant type: `[...]` *) - | TRowEmpty (* empty row: `<>` *) - | TRowExtend of (ty list) LabelMap.t * row (* row extension: `` *) - -and row = ty (* the kind of rows - empty row, row variable, or row extension *) - -and tvar = - | Unbound of id * level - | Link of ty - | Generic of id - - -let rec real_ty = function - | TVar {contents = Link ty} -> real_ty ty - | ty -> ty - -let merge_label_maps label_map1 label_map2 = - LabelMap.merge - (fun label maybe_ty_list1 maybe_ty_list2 -> - match maybe_ty_list1, maybe_ty_list2 with - | None, None -> assert false - | None, (Some ty_list2) -> Some ty_list2 - | (Some ty_list1), None -> Some ty_list1 - | (Some ty_list1), (Some ty_list2) -> Some (ty_list1 @ ty_list2)) - label_map1 label_map2 - -(* Returns a label map with all field types and the type of the "rest", - which is either a type var or an empty row. *) -let rec match_row_ty = function - | TRowExtend(label_ty_map, rest_ty) -> begin - match match_row_ty rest_ty with - | (rest_label_ty_map, rest_ty) when LabelMap.is_empty rest_label_ty_map -> - (label_ty_map, rest_ty) - | (rest_label_ty_map, rest_ty) -> - (merge_label_maps label_ty_map rest_label_ty_map, rest_ty) - end - | TVar {contents = Link ty} -> match_row_ty ty - | TVar _ as var -> (LabelMap.empty, var) - | TRowEmpty -> (LabelMap.empty, TRowEmpty) - | ty -> raise (Failure "not a row") - -(* Adds new bindings to a label map. Assumes all bindings (both - new and existing) are distinct. *) -let add_distinct_labels label_el_map label_el_list = - List.fold_left - (fun label_el_map (label, el) -> - assert (not (LabelMap.mem label label_el_map)) ; - LabelMap.add label el label_el_map) - label_el_map label_el_list - -let label_map_from_list label_el_list = - add_distinct_labels LabelMap.empty label_el_list - - - -let string_of_expr expr : string = - let rec f is_simple = function - | Var name -> name - | Call(fn_expr, arg_list) -> - f true fn_expr ^ "(" ^ String.concat ", " (List.map (f false) arg_list) ^ ")" - | Fun(param_list, body_expr) -> - let fun_str = - "fun " ^ String.concat " " param_list ^ " -> " ^ f false body_expr - in - if is_simple then "(" ^ fun_str ^ ")" else fun_str - | Let(var_name, value_expr, body_expr) -> - let let_str = - "let " ^ var_name ^ " = " ^ f false value_expr ^ " in " ^ f false body_expr - in - if is_simple then "(" ^ let_str ^ ")" else let_str - | RecordEmpty -> "{}" - | RecordSelect(record_expr, label) -> f true record_expr ^ "." ^ label - | RecordRestrict(record_expr, label) -> "{" ^ f false record_expr ^ " - " ^ label ^ "}" - | RecordExtend(label_expr_map, rest_expr) -> - let label_expr_str = - String.concat ", " - (List.map - (fun (label, expr_list) -> - String.concat ", " - (List.map (fun expr -> label ^ " = " ^ f false expr) expr_list)) - (LabelMap.bindings label_expr_map)) - in - let rest_expr_str = match rest_expr with - | RecordEmpty -> "" - | expr -> " | " ^ f false expr - in - "{" ^ label_expr_str ^ rest_expr_str ^ "}" - | Variant(label, value) -> - let variant_str = ":" ^ label ^ " " ^ f true value in - if is_simple then "(" ^ variant_str ^ ")" else variant_str - | Case(expr, cases, maybe_default_case) -> - let cases_str_list = List.map - (fun (label, var_name, expr) -> - "| :" ^ label ^ " " ^ var_name ^ " -> " ^ f false expr) - cases - in - let all_cases_str = match (cases_str_list, maybe_default_case) with - | ([], Some (var_name, expr)) -> var_name ^ " -> " ^ f false expr - | (cases_str_list, None) -> String.concat "" cases_str_list - | (cases_str_list, Some (var_name, expr)) -> - String.concat "" cases_str_list ^ " | " ^ var_name ^ " -> " ^ f false expr - in - "match " ^ f false expr ^ " { " ^ all_cases_str ^ " } " - in - f false expr - -let string_of_ty ty : string = - let id_name_map = Hashtbl.create 10 in - let count = ref 0 in - let next_name () = - let i = !count in - incr count ; - let name = String.make 1 (Char.chr (97 + i mod 26)) ^ - if i >= 26 then string_of_int (i / 26) else "" - in - name - in - let rec f is_simple = function - | TConst name -> name - | TApp(ty, ty_arg_list) -> - f true ty ^ "[" ^ String.concat ", " (List.map (f false) ty_arg_list) ^ "]" - | TArrow(param_ty_list, return_ty) -> - let arrow_ty_str = match param_ty_list with - | [param_ty] -> - let param_ty_str = f true param_ty in - let return_ty_str = f false return_ty in - param_ty_str ^ " -> " ^ return_ty_str - | _ -> - let param_ty_list_str = String.concat ", " (List.map (f false) param_ty_list) in - let return_ty_str = f false return_ty in - "(" ^ param_ty_list_str ^ ") -> " ^ return_ty_str - in - if is_simple then "(" ^ arrow_ty_str ^ ")" else arrow_ty_str - | TVar {contents = Generic id} -> begin - try - Hashtbl.find id_name_map id - with Not_found -> - let name = next_name () in - Hashtbl.add id_name_map id name ; - name - end - | TVar {contents = Unbound(id, _)} -> "_" ^ string_of_int id - | TVar {contents = Link ty} -> f is_simple ty - | TRecord row_ty -> "{" ^ f false row_ty ^ "}" - | TVariant row_ty -> "[" ^ f false row_ty ^ "]" - | TRowEmpty -> "" - | TRowExtend _ as row_ty -> - let (label_ty_map, rest_ty) = match_row_ty row_ty in - let label_ty_str = - String.concat ", " - (List.map - (fun (label, ty_list) -> - String.concat ", " - (List.map (fun ty -> label ^ " : " ^ f false ty) ty_list)) - (LabelMap.bindings label_ty_map)) - in - let rest_ty_str = match real_ty rest_ty with - | TRowEmpty -> "" - | TRowExtend _ -> assert false - | other_ty -> " | " ^ f false other_ty - in - label_ty_str ^ rest_ty_str - in - let ty_str = f false ty in - if !count > 0 then - let var_names = Hashtbl.fold (fun _ value acc -> value :: acc) id_name_map [] in - "forall[" ^ String.concat " " (List.sort String.compare var_names) ^ "] " ^ ty_str - else - ty_str \ No newline at end of file diff --git a/test/32 b/test/32 deleted file mode 100644 index baf55ef..0000000 --- a/test/32 +++ /dev/null @@ -1,15 +0,0 @@ -let search_compiler_libs () = - prerr_endline "I: Searching for OCaml compiler libraries"; - let stdlib = BaseEnv.var_get "standard_library" in - let ( / ) = Filename.concat in - try - List.find (fun path -> Sys.file_exists (path / "types.cmi") || Sys.file_exists (path / "typing" / "types.cmi")) [ - stdlib; - stdlib / "compiler-libs"; - stdlib / "compiler-lib"; - stdlib / ".." / "compiler-libs"; - stdlib / ".." / "compiler-lib"; - ] - with Not_found -> - prerr_endline "E: Cannot find compiler libraries! See the README for details."; - exit 1 \ No newline at end of file diff --git a/test/4 b/test/4 deleted file mode 100644 index 2b01695..0000000 --- a/test/4 +++ /dev/null @@ -1,21 +0,0 @@ -(require '[overtone.live :as overtone]) - -(defn note [timing pitch] {:time timing :pitch pitch}) - -(def melody - (let [pitches - [0 0 0 1 2 - ; Row, row, row your boat, - 2 1 2 3 4 - ; Gently down the stream, - 7 7 7 4 4 4 2 2 2 0 0 0 - ; (take 4 (repeat "merrily")) - 4 3 2 1 0] - ; Life is but a dream! - durations - [1 1 2/3 1/3 1 - 2/3 1/3 2/3 1/3 2 - 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 - 2/3 1/3 2/3 1/3 2] - times (reductions + 0 durations)] - (map note times pitches))) \ No newline at end of file diff --git a/test/5 b/test/5 deleted file mode 100644 index f091c5f..0000000 --- a/test/5 +++ /dev/null @@ -1,26 +0,0 @@ -from pkgutil import iter_modules -from subprocess import call - -dependencies = { - "Crypto": "crypto", - "dpkt": "dpkt", - "IPy": "ipy", - "pcap": "pypcap" -} - -installed, missing_pkgs = [pkg[1] for pkg in iter_modules()], [] - -for module, pkg in dependencies.items(): - if module not in installed: - print("dshell requires {}".format(module)) - missing_pkgs.append("python-{}".format(pkg)) - else: - print("{} is installed".format(module)) - -if missing_pkgs: - cmd = ["sudo", "apt-get", "install"] + missing_pkgs - - print(" ".join(cmd)) - call(cmd) - -call(["make", "all"]) \ No newline at end of file diff --git a/test/6 b/test/6 deleted file mode 100644 index 233a6b9..0000000 --- a/test/6 +++ /dev/null @@ -1,88 +0,0 @@ -import re -import subprocess - -def cmd_keymap_table(): - return subprocess.Popen( - ['xmodmap','-pk'], stdout=subprocess.PIPE).communicate()[0] - -def cmd_modifier_map(): - return subprocess.Popen( - ['xmodmap','-pm'], stdout=subprocess.PIPE).communicate()[0] - -def get_keymap_table(): - keymap = {} - - keymap_table = cmd_keymap_table() - - re_line = re.compile(r'0x\w+') - for line in keymap_table.split('\n')[1:]: - if len(line) > 0: - keycode = re.search(r'\s+(\d+).*', line) - if keycode: - new_keysyms = [] - keycode = int(keycode.group(1)) - keysyms = re_line.findall(line) - # When you press only one key - unicode_char = '' - try: - unicode_char = unichr(int(keysyms[0], 16)) - except: - unicode_char = '' - if unicode_char == u'\x00': - unicode_char = '' - new_keysyms.append(unicode_char) - - # When you press a key plus Shift key - unicode_char = '' - try: - unicode_char = unichr(int(keysyms[1], 16)) - except: - unicode_char = '' - if unicode_char == u'\x00': - unicode_char = '' - new_keysyms.append(unicode_char) - - # When you press a key plus meta (dead keys) - unicode_char = '' - try: - unicode_char = unichr(int(keysyms[4], 16)) - except: - unicode_char = '' - if unicode_char == u'\x00': - unicode_char = '' - new_keysyms.append(unicode_char) - - # When you press a key plus meta plus Shift key - unicode_char = '' - try: - unicode_char = unichr(int(keysyms[5], 16)) - except: - unicode_char = '' - if unicode_char == u'\x00': - unicode_char = '' - new_keysyms.append(unicode_char) - - #keymap[keycode-8] = new_keysyms - keymap[keycode] = new_keysyms - - return keymap - -def get_modifier_map(): - modifiers = {} - - modifier_map = cmd_modifier_map() - - re_line = re.compile(r'(0x\w+)') - for line in modifier_map.split('\n')[1:]: - if len(line) > 0: - mod_name = re.match(r'(\w+).*', line) - if mod_name: - mod_name = mod_name.group(1) - keycodes = re_line.findall(line) - # Convert key codes from hex to dec for use them - # with the keymap table - keycodes =[ int(kc, 16) for kc in keycodes] - - modifiers[mod_name] = keycodes - - return modifiers \ No newline at end of file diff --git a/test/7 b/test/7 deleted file mode 100644 index f709879..0000000 --- a/test/7 +++ /dev/null @@ -1,15 +0,0 @@ -class NoSuchService(Exception): - def __init__(self, name): - self.name = name - self.msg = "No such service: %s" % self.name - - def __str__(self): - return self.msg - - -class ConfigurationError(Exception): - def __init__(self, msg): - self.msg = msg - - def __str__(self): - return self.msg \ No newline at end of file diff --git a/test/8 b/test/8 deleted file mode 100644 index 95f2402..0000000 --- a/test/8 +++ /dev/null @@ -1,532 +0,0 @@ -from collections import namedtuple -import functools -import heapq -import itertools -import logging -import Queue -import random -import threading - -# data types -Proposal = namedtuple('Proposal', ['caller', 'client_id', 'input']) -Ballot = namedtuple('Ballot', ['n', 'leader']) - -# message types -Accepted = namedtuple('Accepted', ['slot', 'ballot_num']) -Accept = namedtuple('Accept', ['slot', 'ballot_num', 'proposal']) -Decision = namedtuple('Decision', ['slot', 'proposal']) -Invoked = namedtuple('Invoked', ['client_id', 'output']) -Invoke = namedtuple('Invoke', ['caller', 'client_id', 'input_value']) -Join = namedtuple('Join', []) -Active = namedtuple('Active', []) -Prepare = namedtuple('Prepare', ['ballot_num']) -Promise = namedtuple('Promise', ['ballot_num', 'accepted_proposals']) -Propose = namedtuple('Propose', ['slot', 'proposal']) -Welcome = namedtuple('Welcome', ['state', 'slot', 'decisions']) -Decided = namedtuple('Decided', ['slot']) -Preempted = namedtuple('Preempted', ['slot', 'preempted_by']) -Adopted = namedtuple('Adopted', ['ballot_num', 'accepted_proposals']) -Accepting = namedtuple('Accepting', ['leader']) - -# constants - these times should really be in terms of average round-trip time -JOIN_RETRANSMIT = 0.7 -CATCHUP_INTERVAL = 0.6 -ACCEPT_RETRANSMIT = 1.0 -PREPARE_RETRANSMIT = 1.0 -INVOKE_RETRANSMIT = 0.5 -LEADER_TIMEOUT = 1.0 -NULL_BALLOT = Ballot(-1, -1) # sorts before all real ballots -NOOP_PROPOSAL = Proposal(None, None, None) # no-op to fill otherwise empty slots - -class Node(object): - unique_ids = itertools.count() - - def __init__(self, network, address): - self.network = network - self.address = address or 'N%d' % self.unique_ids.next() - self.logger = SimTimeLogger(logging.getLogger(self.address), {'network': self.network}) - self.logger.info('starting') - self.roles = [] - self.send = functools.partial(self.network.send, self) - - def register(self, roles): - self.roles.append(roles) - - def unregister(self, roles): - self.roles.remove(roles) - - def receive(self, sender, message): - handler_name = 'do_%s' % type(message).__name__ - - for comp in self.roles[:]: - if not hasattr(comp, handler_name): - continue - comp.logger.debug("received %s from %s", message, sender) - fn = getattr(comp, handler_name) - fn(sender=sender, **message._asdict()) - -class Timer(object): - - def __init__(self, expires, address, callback): - self.expires = expires - self.address = address - self.callback = callback - self.cancelled = False - - def __cmp__(self, other): - return cmp(self.expires, other.expires) - - def cancel(self): - self.cancelled = True - -class Network(object): - PROP_DELAY = 0.03 - PROP_JITTER = 0.02 - DROP_PROB = 0.05 - - def __init__(self, seed): - self.nodes = {} - self.rnd = random.Random(seed) - self.timers = [] - self.now = 1000.0 - - def new_node(self, address=None): - node = Node(self, address=address) - self.nodes[node.address] = node - return node - - def run(self): - while self.timers: - next_timer = self.timers[0] - if next_timer.expires > self.now: - self.now = next_timer.expires - heapq.heappop(self.timers) - if next_timer.cancelled: - continue - if not next_timer.address or next_timer.address in self.nodes: - next_timer.callback() - - def stop(self): - self.timers = [] - - def set_timer(self, address, seconds, callback): - timer = Timer(self.now + seconds, address, callback) - heapq.heappush(self.timers, timer) - return timer - - def send(self, sender, destinations, message): - sender.logger.debug("sending %s to %s", message, destinations) - for dest in (d for d in destinations if d in self.nodes): - if dest == sender.address: - # reliably deliver local messages with no delay - self.set_timer(sender.address, 0, lambda: sender.receive(sender.address, message)) - elif self.rnd.uniform(0, 1.0) > self.DROP_PROB: - delay = self.PROP_DELAY + self.rnd.uniform(-self.PROP_JITTER, self.PROP_JITTER) - self.set_timer(dest, delay, functools.partial(self.nodes[dest].receive, - sender.address, message)) - -class SimTimeLogger(logging.LoggerAdapter): - - def process(self, msg, kwargs): - return "T=%.3f %s" % (self.extra['network'].now, msg), kwargs - - def getChild(self, name): - return self.__class__(self.logger.getChild(name), - {'network': self.extra['network']}) - -class Role(object): - - def __init__(self, node): - self.node = node - self.node.register(self) - self.running = True - self.logger = node.logger.getChild(type(self).__name__) - - def set_timer(self, seconds, callback): - return self.node.network.set_timer(self.node.address, seconds, - lambda: self.running and callback()) - - def stop(self): - self.running = False - self.node.unregister(self) - -class Acceptor(Role): - - def __init__(self, node): - super(Acceptor, self).__init__(node) - self.ballot_num = NULL_BALLOT - self.accepted_proposals = {} # {slot: (ballot_num, proposal)} - - def do_Prepare(self, sender, ballot_num): - if ballot_num > self.ballot_num: - self.ballot_num = ballot_num - # we've heard from a scout, so it might be the next leader - self.node.send([self.node.address], Accepting(leader=sender)) - - self.node.send([sender], Promise(ballot_num=self.ballot_num, accepted_proposals=self.accepted_proposals)) - - def do_Accept(self, sender, ballot_num, slot, proposal): - if ballot_num >= self.ballot_num: - self.ballot_num = ballot_num - acc = self.accepted_proposals - if slot not in acc or acc[slot][0] < ballot_num: - acc[slot] = (ballot_num, proposal) - - self.node.send([sender], Accepted( - slot=slot, ballot_num=self.ballot_num)) - -class Replica(Role): - - def __init__(self, node, execute_fn, state, slot, decisions, peers): - super(Replica, self).__init__(node) - self.execute_fn = execute_fn - self.state = state - self.slot = slot - self.decisions = decisions.copy() - self.peers = peers - self.proposals = {} - # next slot num for a proposal (may lead slot) - self.next_slot = slot - self.latest_leader = None - self.latest_leader_timeout = None - - # making proposals - - def do_Invoke(self, sender, caller, client_id, input_value): - proposal = Proposal(caller, client_id, input_value) - slot = next((s for s, p in self.proposals.iteritems() if p == proposal), None) - # propose, or re-propose if this proposal already has a slot - self.propose(proposal, slot) - - def propose(self, proposal, slot=None): - """Send (or resend, if slot is specified) a proposal to the leader""" - if not slot: - slot, self.next_slot = self.next_slot, self.next_slot + 1 - self.proposals[slot] = proposal - # find a leader we think is working - either the latest we know of, or - # ourselves (which may trigger a scout to make us the leader) - leader = self.latest_leader or self.node.address - self.logger.info("proposing %s at slot %d to leader %s" % (proposal, slot, leader)) - self.node.send([leader], Propose(slot=slot, proposal=proposal)) - - # handling decided proposals - - def do_Decision(self, sender, slot, proposal): - assert not self.decisions.get(self.slot, None), \ - "next slot to commit is already decided" - if slot in self.decisions: - assert self.decisions[slot] == proposal, \ - "slot %d already decided with %r!" % (slot, self.decisions[slot]) - return - self.decisions[slot] = proposal - self.next_slot = max(self.next_slot, slot + 1) - - # re-propose our proposal in a new slot if it lost its slot and wasn't a no-op - our_proposal = self.proposals.get(slot) - if our_proposal is not None and our_proposal != proposal and our_proposal.caller: - self.propose(our_proposal) - - # execute any pending, decided proposals - while True: - commit_proposal = self.decisions.get(self.slot) - if not commit_proposal: - break # not decided yet - commit_slot, self.slot = self.slot, self.slot + 1 - - self.commit(commit_slot, commit_proposal) - - def commit(self, slot, proposal): - """Actually commit a proposal that is decided and in sequence""" - decided_proposals = [p for s, p in self.decisions.iteritems() if s < slot] - if proposal in decided_proposals: - self.logger.info("not committing duplicate proposal %r at slot %d", proposal, slot) - return # duplicate - - self.logger.info("committing %r at slot %d" % (proposal, slot)) - if proposal.caller is not None: - # perform a client operation - self.state, output = self.execute_fn(self.state, proposal.input) - self.node.send([proposal.caller], Invoked(client_id=proposal.client_id, output=output)) - - # tracking the leader - - def do_Adopted(self, sender, ballot_num, accepted_proposals): - self.latest_leader = self.node.address - self.leader_alive() - - def do_Accepting(self, sender, leader): - self.latest_leader = leader - self.leader_alive() - - def do_Active(self, sender): - if sender != self.latest_leader: - return - self.leader_alive() - - def leader_alive(self): - if self.latest_leader_timeout: - self.latest_leader_timeout.cancel() - - def reset_leader(): - idx = self.peers.index(self.latest_leader) - self.latest_leader = self.peers[(idx + 1) % len(self.peers)] - self.logger.debug("leader timed out; tring the next one, %s", self.latest_leader) - self.latest_leader_timeout = self.set_timer(LEADER_TIMEOUT, reset_leader) - - # adding new cluster members - - def do_Join(self, sender): - if sender in self.peers: - self.node.send([sender], Welcome( - state=self.state, slot=self.slot, decisions=self.decisions)) - -class Commander(Role): - - def __init__(self, node, ballot_num, slot, proposal, peers): - super(Commander, self).__init__(node) - self.ballot_num = ballot_num - self.slot = slot - self.proposal = proposal - self.acceptors = set([]) - self.peers = peers - self.quorum = len(peers) / 2 + 1 - - def start(self): - self.node.send(set(self.peers) - self.acceptors, Accept( - slot=self.slot, ballot_num=self.ballot_num, proposal=self.proposal)) - self.set_timer(ACCEPT_RETRANSMIT, self.start) - - def finished(self, ballot_num, preempted): - if preempted: - self.node.send([self.node.address], Preempted(slot=self.slot, preempted_by=ballot_num)) - else: - self.node.send([self.node.address], Decided(slot=self.slot)) - self.stop() - - def do_Accepted(self, sender, slot, ballot_num): - if slot != self.slot: - return - if ballot_num == self.ballot_num: - self.acceptors.add(sender) - if len(self.acceptors) < self.quorum: - return - self.node.send(self.peers, Decision(slot=self.slot, proposal=self.proposal)) - self.finished(ballot_num, False) - else: - self.finished(ballot_num, True) - -class Scout(Role): - - def __init__(self, node, ballot_num, peers): - super(Scout, self).__init__(node) - self.ballot_num = ballot_num - self.accepted_proposals = {} - self.acceptors = set([]) - self.peers = peers - self.quorum = len(peers) / 2 + 1 - self.retransmit_timer = None - - def start(self): - self.logger.info("scout starting") - self.send_prepare() - - def send_prepare(self): - self.node.send(self.peers, Prepare(ballot_num=self.ballot_num)) - self.retransmit_timer = self.set_timer(PREPARE_RETRANSMIT, self.send_prepare) - - def update_accepted(self, accepted_proposals): - acc = self.accepted_proposals - for slot, (ballot_num, proposal) in accepted_proposals.iteritems(): - if slot not in acc or acc[slot][0] < ballot_num: - acc[slot] = (ballot_num, proposal) - - def do_Promise(self, sender, ballot_num, accepted_proposals): - if ballot_num == self.ballot_num: - self.logger.info("got matching promise; need %d" % self.quorum) - self.update_accepted(accepted_proposals) - self.acceptors.add(sender) - if len(self.acceptors) >= self.quorum: - # strip the ballot numbers from self.accepted_proposals, now that it - # represents a majority - accepted_proposals = dict((s, p) for s, (b, p) in self.accepted_proposals.iteritems()) - # We're adopted; note that this does *not* mean that no other leader is active. - # Any such conflicts will be handled by the commanders. - self.node.send([self.node.address], - Adopted(ballot_num=ballot_num, accepted_proposals=accepted_proposals)) - self.stop() - else: - # this acceptor has promised another leader a higher ballot number, so we've lost - self.node.send([self.node.address], Preempted(slot=None, preempted_by=ballot_num)) - self.stop() - -class Leader(Role): - - def __init__(self, node, peers, commander_cls=Commander, scout_cls=Scout): - super(Leader, self).__init__(node) - self.ballot_num = Ballot(0, node.address) - self.active = False - self.proposals = {} - self.commander_cls = commander_cls - self.scout_cls = scout_cls - self.scouting = False - self.peers = peers - - def start(self): - # reminder others we're active before LEADER_TIMEOUT expires - def active(): - if self.active: - self.node.send(self.peers, Active()) - self.set_timer(LEADER_TIMEOUT / 2.0, active) - active() - - def spawn_scout(self): - assert not self.scouting - self.scouting = True - self.scout_cls(self.node, self.ballot_num, self.peers).start() - - def do_Adopted(self, sender, ballot_num, accepted_proposals): - self.scouting = False - self.proposals.update(accepted_proposals) - # note that we don't re-spawn commanders here; if there are undecided - # proposals, the replicas will re-propose - self.logger.info("leader becoming active") - self.active = True - - def spawn_commander(self, ballot_num, slot): - proposal = self.proposals[slot] - self.commander_cls(self.node, ballot_num, slot, proposal, self.peers).start() - - def do_Preempted(self, sender, slot, preempted_by): - if not slot: # from the scout - self.scouting = False - self.logger.info("leader preempted by %s", preempted_by.leader) - self.active = False - self.ballot_num = Ballot((preempted_by or self.ballot_num).n + 1, self.ballot_num.leader) - - def do_Propose(self, sender, slot, proposal): - if slot not in self.proposals: - if self.active: - self.proposals[slot] = proposal - self.logger.info("spawning commander for slot %d" % (slot,)) - self.spawn_commander(self.ballot_num, slot) - else: - if not self.scouting: - self.logger.info("got PROPOSE when not active - scouting") - self.spawn_scout() - else: - self.logger.info("got PROPOSE while scouting; ignored") - else: - self.logger.info("got PROPOSE for a slot already being proposed") - -class Bootstrap(Role): - - def __init__(self, node, peers, execute_fn, - replica_cls=Replica, acceptor_cls=Acceptor, leader_cls=Leader, - commander_cls=Commander, scout_cls=Scout): - super(Bootstrap, self).__init__(node) - self.execute_fn = execute_fn - self.peers = peers - self.peers_cycle = itertools.cycle(peers) - self.replica_cls = replica_cls - self.acceptor_cls = acceptor_cls - self.leader_cls = leader_cls - self.commander_cls = commander_cls - self.scout_cls = scout_cls - - def start(self): - self.join() - - def join(self): - self.node.send([next(self.peers_cycle)], Join()) - self.set_timer(JOIN_RETRANSMIT, self.join) - - def do_Welcome(self, sender, state, slot, decisions): - self.acceptor_cls(self.node) - self.replica_cls(self.node, execute_fn=self.execute_fn, peers=self.peers, - state=state, slot=slot, decisions=decisions) - self.leader_cls(self.node, peers=self.peers, commander_cls=self.commander_cls, - scout_cls=self.scout_cls).start() - self.stop() - -class Seed(Role): - - def __init__(self, node, initial_state, execute_fn, peers, bootstrap_cls=Bootstrap): - super(Seed, self).__init__(node) - self.initial_state = initial_state - self.execute_fn = execute_fn - self.peers = peers - self.bootstrap_cls = bootstrap_cls - self.seen_peers = set([]) - self.exit_timer = None - - def do_Join(self, sender): - self.seen_peers.add(sender) - if len(self.seen_peers) <= len(self.peers) / 2: - return - - # cluster is ready - welcome everyone - self.node.send(list(self.seen_peers), Welcome( - state=self.initial_state, slot=1, decisions={})) - - # stick around for long enough that we don't hear any new JOINs from - # the newly formed cluster - if self.exit_timer: - self.exit_timer.cancel() - self.exit_timer = self.set_timer(JOIN_RETRANSMIT * 2, self.finish) - - def finish(self): - # bootstrap this node into the cluster we just seeded - bs = self.bootstrap_cls(self.node, peers=self.peers, execute_fn=self.execute_fn) - bs.start() - self.stop() - -class Requester(Role): - - client_ids = itertools.count(start=100000) - - def __init__(self, node, n, callback): - super(Requester, self).__init__(node) - self.client_id = self.client_ids.next() - self.n = n - self.output = None - self.callback = callback - - def start(self): - self.node.send([self.node.address], Invoke(caller=self.node.address, - client_id=self.client_id, input_value=self.n)) - self.invoke_timer = self.set_timer(INVOKE_RETRANSMIT, self.start) - - def do_Invoked(self, sender, client_id, output): - if client_id != self.client_id: - return - self.logger.debug("received output %r" % (output,)) - self.invoke_timer.cancel() - self.callback(output) - self.stop() - -class Member(object): - - def __init__(self, state_machine, network, peers, seed=None, - seed_cls=Seed, bootstrap_cls=Bootstrap): - self.network = network - self.node = network.new_node() - if seed is not None: - self.startup_role = seed_cls(self.node, initial_state=seed, peers=peers, - execute_fn=state_machine) - else: - self.startup_role = bootstrap_cls(self.node, execute_fn=state_machine, peers=peers) - self.requester = None - - def start(self): - self.startup_role.start() - self.thread = threading.Thread(target=self.network.run) - self.thread.start() - - def invoke(self, input_value, request_cls=Requester): - assert self.requester is None - q = Queue.Queue() - self.requester = request_cls(self.node, input_value, q.put) - self.requester.start() - output = q.get() - self.requester = None - return output \ No newline at end of file diff --git a/test/9 b/test/9 deleted file mode 100644 index 02061e2..0000000 --- a/test/9 +++ /dev/null @@ -1,53 +0,0 @@ -function errorHandler(context) { - return function(error) { - trace('Failure in ' + context + ': ' + error.toString); - } -} - -function successHandler(context) { - return function() { - trace('Success in ' + context); - } -} - -function noAction() { -} - - -function VideoPipe(stream, handler) { - var servers = null; - var pc1 = new RTCPeerConnection(servers); - var pc2 = new RTCPeerConnection(servers); - - pc1.addStream(stream); - pc1.onicecandidate = function(event) { - if (event.candidate) { - pc2.addIceCandidate(new RTCIceCandidate(event.candidate), - noAction, errorHandler('AddIceCandidate')); - } - } - pc2.onicecandidate = function(event) { - if (event.candidate) { - pc1.addIceCandidate(new RTCIceCandidate(event.candidate), - noAction, errorHandler('AddIceCandidate')); - } - } - pc2.onaddstream = function(e) { - handler(e.stream); - } - pc1.createOffer(function(desc) { - pc1.setLocalDescription(desc); - pc2.setRemoteDescription(desc); - pc2.createAnswer(function(desc2) { - pc2.setLocalDescription(desc2); - pc1.setRemoteDescription(desc2); - }, errorHandler('pc2.createAnswer')); - }, errorHandler('pc1.createOffer')); - this.pc1 = pc1; - this.pc2 = pc2; -} - -VideoPipe.prototype.close = function() { - this.pc1.close(); - this.pc2.close(); -} \ No newline at end of file From 0dc9bdcf4576fecdcfe935ea900856e91ce5ea55 Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Fri, 13 Feb 2015 16:33:26 -0500 Subject: [PATCH 2/9] Friday's work --- plc/data_load.py | 80 + plc/features.py | 20 + plc/tests/test_features.py | 21 + plc/workbook.ipynb | 3959 +++++++++++++++++ .../workbook.ipynb | 1015 ----- 5 files changed, 4080 insertions(+), 1015 deletions(-) create mode 100644 plc/data_load.py create mode 100644 plc/features.py create mode 100644 plc/tests/test_features.py create mode 100644 plc/workbook.ipynb delete mode 100644 programming-language-classifier/workbook.ipynb diff --git a/plc/data_load.py b/plc/data_load.py new file mode 100644 index 0000000..e68c016 --- /dev/null +++ b/plc/data_load.py @@ -0,0 +1,80 @@ +import os +import pandas as pd + +filename_dict = {".clj":"Clojure", + ".cljs": "Clojure", + ".edn": "Clojure", + ".clojure": "Clojure", + ".hs": "Haskell", + ".lhs": "Haskell", + ".java": "Java", + ".class": "Java", + ".jar": "Java", + ".js": "Javascript", + ".javascript": "Javascript", + ".ocaml": "OCaml", + ".ml": "OCaml", + ".pl": "Perl", + ".pm": "Perl", + ".t": "Perl", + ".pod": "Perl", + ".php": "PHP", + ".perl": "Perl", + ".phtml": "PHP", + ".php4": "PHP", + ".php3": "PHP", + ".php5": "PHP", + ".phps": "PHP", + ".py": "Python", + ".pyw": "Python", + ".pyc": "Python", + ".pyo": "Python", + ".pyd": "Python", + ".python3": "Python", + ".Python2": "Python", + ".rb": "Ruby", + ".rbw": "Ruby", + ".jruby": "Ruby", + ".scala": "Scala", + ".scm": "Scheme", + ".ss": "Scheme", + ".tcl": "Tcl", + ".racket": "Scheme", + ".ghc": "Haskell"} + +def tuple_maker(adict): + lista = [] + for key in adict: + lista.append(key) + tup = tuple(lista) + return tup + +def code_sucker(): + codelist = [] + for subdir, dirs, files in os.walk("bench/"): + for fname in files: + if fname.endswith(tuple_maker(filename_dict)): + #print(fname) + with open(os.path.join(subdir, fname)) as current_file: + codelist.append(current_file.read()) + return codelist + +def type_getter(): + rootDir = 'bench' + typelist = [] + for subdir, dirs, files in os.walk(rootDir): + for fname in files: + #print('\t%s' % fname) + name, extension = os.path.splitext(fname) + if extension in filename_dict: + #print(filename_dict[extension]) + typelist.append(filename_dict[extension]) + return typelist + +def tcode_sucker(): + codelist = [] + for subdir, dirs, files in os.walk("test/"): + for fname in files: + with open(os.path.join(subdir, fname)) as current_file: + codelist.append(current_file.read()) + return codelist diff --git a/plc/features.py b/plc/features.py new file mode 100644 index 0000000..b8b2620 --- /dev/null +++ b/plc/features.py @@ -0,0 +1,20 @@ +import re + +def character_counter(code, char): + counter = 0 + for _ in code: + if _ == char: + counter+=1 + return counter + +def character_ratio(code, char): + value = character_counter(code, char)/len(code) + return value + +def string_finder(string, code): + value = len(re.findall(string, code)) + return value + +def string_ratio(string, code): + value = string_ratio(string, code)/len(code) + return value diff --git a/plc/tests/test_features.py b/plc/tests/test_features.py new file mode 100644 index 0000000..f8de69d --- /dev/null +++ b/plc/tests/test_features.py @@ -0,0 +1,21 @@ +from plc.features import* + +def test_character_counter(): + testcode = "This is a string with some funky characters !@*!@*(#^&!)" + assert character_counter(testcode, 's') == 5 + assert character_counter(testcode, '!') == 3 + assert character_counter(testcode, ' ') == 8 + assert character_counter(testcode, '(') == 1 + +# testcode length is 56 + +def test_character_ratio(): + testcode = "This is a string with some funky characters !@*!@*(#^&!)" + assert character_ratio(testcode, ' ') == 8/56 + +def test_string_finder(): + test2code = ("""let min_depth = 4 let n = if Array.length + Sys.argv <> 2 then 0 else int_of_string Sys.argv.(1)let + max_depth = max (min_depth + 2) nlet stretch_depth = + max_depth + 1""") + assert string_finder("let", test2code) == 4 diff --git a/plc/workbook.ipynb b/plc/workbook.ipynb new file mode 100644 index 0000000..c974277 --- /dev/null +++ b/plc/workbook.ipynb @@ -0,0 +1,3959 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:30544480392234b3bde3c304b51b9ee0b41e65f8c2b482bbce68de6060e3ab15" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import pandas as pd\n", + "import re" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 119 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "filename_dict = {\".clj\":\"Clojure\",\n", + " \".cljs\": \"Clojure\",\n", + " \".edn\": \"Clojure\",\n", + " \".clojure\": \"Clojure\",\n", + " \".hs\": \"Haskell\",\n", + " \".lhs\": \"Haskell\",\n", + " \".java\": \"Java\",\n", + " \".class\": \"Java\",\n", + " \".jar\": \"Java\",\n", + " \".js\": \"Javascript\",\n", + " \".javascript\": \"Javascript\",\n", + " \".ocaml\": \"OCaml\",\n", + " \".ml\": \"OCaml\",\n", + " \".pl\": \"Perl\",\n", + " \".pm\": \"Perl\",\n", + " \".t\": \"Perl\",\n", + " \".pod\": \"Perl\",\n", + " \".php\": \"PHP\",\n", + " \".perl\": \"Perl\",\n", + " \".phtml\": \"PHP\",\n", + " \".php4\": \"PHP\",\n", + " \".php3\": \"PHP\",\n", + " \".php5\": \"PHP\",\n", + " \".phps\": \"PHP\",\n", + " \".py\": \"Python\",\n", + " \".pyw\": \"Python\",\n", + " \".pyc\": \"Python\",\n", + " \".pyo\": \"Python\",\n", + " \".pyd\": \"Python\",\n", + " \".python3\": \"Python\",\n", + " \".Python2\": \"Python\",\n", + " \".rb\": \"Ruby\",\n", + " \".rbw\": \"Ruby\",\n", + " \".jruby\": \"Ruby\",\n", + " \".scala\": \"Scala\",\n", + " \".scm\": \"Scheme\",\n", + " \".ss\": \"Scheme\",\n", + " \".tcl\": \"Tcl\",\n", + " \".racket\": \"Scheme\",\n", + " \".ghc\": \"Haskell\"}" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 20 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def tuple_maker(adict):\n", + " lista = []\n", + " for key in adict:\n", + " lista.append(key)\n", + " tup = tuple(lista)\n", + " return tup" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 21 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def code_sucker():\n", + " codelist = []\n", + " for subdir, dirs, files in os.walk(\"bench/\"):\n", + " for fname in files:\n", + " if fname.endswith(tuple_maker(filename_dict)):\n", + " #print(fname)\n", + " with open(os.path.join(subdir, fname)) as current_file:\n", + " codelist.append(current_file.read()) \n", + " return codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 22 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "codelist = code_sucker()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 23 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "len(codelist)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 24, + "text": [ + "386" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def type_getter():\n", + " rootDir = 'bench'\n", + " typelist = []\n", + " for subdir, dirs, files in os.walk(rootDir):\n", + " for fname in files:\n", + " #print('\\t%s' % fname)\n", + " name, extension = os.path.splitext(fname)\n", + " if extension in filename_dict:\n", + " #print(filename_dict[extension])\n", + " typelist.append(filename_dict[extension])\n", + " return typelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 25 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "typelist = type_getter()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 26 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "len(typelist)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 27, + "text": [ + "386" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df = pd.DataFrame(typelist, index=range(386))" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 28 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df.columns = [\"Language\"]\n", + "df[\"Code\"] = codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 29 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df['Language'] = df.Language.apply(lambda x:x.lower())" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 30 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
LanguageCode
0 clojure ;; The Computer Language Benchmarks Game\\n;; h...
1 clojure ;; The Computer Language Benchmarks Game\\n;; h...
2 clojure ;; The Computer Language Benchmarks Game\\n;; h...
3 haskell --\\n-- The Computer Language Benchmarks Game\\n...
4 haskell --\\n-- The Computer Language Benchmarks Game\\n...
5 haskell --\\n-- The Computer Language Benchmarks Game\\n...
6 java /* The Computer Language Benchmarks Game\\n h...
7 java /* The Computer Language Benchmarks Game\\n h...
8 java /* The Computer Language Benchmarks Game\\n * h...
9 javascript /* The Computer Language Benchmarks Game\\n h...
10 ruby # The Computer Language Shootout Benchmarks\\n#...
11 ruby # The Computer Language Benchmarks Game\\n# htt...
12 ruby # The Computer Language Benchmarks Game\\n# htt...
13 ruby # The Computer Language Benchmarks Game\\n# htt...
14 ocaml (* The Computer Language Benchmarks Game\\n * h...
15 ocaml (* The Computer Language Benchmarks Game\\n * h...
16 ocaml (* The Computer Language Benchmarks Game\\n * h...
17 perl # The Computer Language Benchmarks Game\\n# htt...
18 perl # The Computer Language Benchmarks Game\\n# htt...
19 php <?php \\n/* The Computer Language Benchmarks Ga...
20 php <?php \\n/* The Computer Language Benchmarks Ga...
21 php <?php \\n/* The Computer Language Benchmarks Ga...
22 php <?php \\n/* The Computer Language Benchmarks Ga...
23 python # The Computer Language Benchmarks Game\\n# htt...
24 scheme #lang racket/base\\n\\n;;; The Computer Language...
25 scheme #lang racket/base\\n\\n;;; The Computer Language...
26 scheme #lang racket/base\\n\\n;;; The Computer Language...
27 scala /* The Computer Language Benchmarks Game\\n h...
28 scala /* The Computer Language Benchmarks Game\\n h...
29 scala /* The Computer Language Benchmarks Game\\n h...
.........
356 python # The Computer Language Benchmarks Game\\n# htt...
357 python # The Computer Language Benchmarks Game\\n# htt...
358 python # The Computer Language Benchmarks Game\\n# htt...
359 scheme #lang racket/base\\n\\n;;; The Computer Language...
360 scheme #lang racket/base\\n\\n;;; The Computer Language...
361 scheme #lang racket/base\\n;; The Computer Language Be...
362 scala /* The Computer Language Benchmarks Game\\n h...
363 scala /* The Computer Language Benchmarks Game\\n h...
364 scala /* The Computer Language Benchmarks Game\\n h...
365 scala /* The Computer Language Benchmarks Game\\n h...
366 clojure ;; The Computer Language Benchmarks Game\\n;; h...
367 clojure ;; The Computer Language Benchmarks Game\\n;; h...
368 haskell -- The Computer Language Benchmarks Game\\n-- h...
369 java /**\\n * The Computer Language Benchmarks Game\\...
370 java /**\\n * The Computer Language Benchmarks Game\\...
371 java /**\\n * The Computer Language Benchmarks Game\\...
372 java /**\\n * The Computer Language Benchmarks Game\\...
373 java /**\\n * The Computer Language Benchmarks Game\\...
374 java /**\\n * The Computer Language Benchmarks Game\\...
375 ruby # The Computer Language Benchmarks Game\\n# htt...
376 ruby # The Computer Language Benchmarks Game\\n# htt...
377 ocaml (* The Computer Language Benchmarks Game\\n * h...
378 ocaml (* The Computer Language Benchmarks Game\\n * h...
379 ocaml (* The Computer Language Benchmarks Game\\n * h...
380 perl # The Computer Language Benchmarks Game\\n# htt...
381 perl # The Computer Language Benchmarks Game\\n# htt...
382 python # The Computer Language Benchmarks Game\\n# htt...
383 python # The Computer Language Benchmarks Game\\n# htt...
384 scheme #lang racket/base\\n\\n;;; The Computer Language...
385 scala /* The Computer Language Benchmarks Game\\n h...
\n", + "

386 rows \u00d7 2 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 31, + "text": [ + " Language Code\n", + "0 clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", + "1 clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", + "2 clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", + "3 haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", + "4 haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", + "5 haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", + "6 java /* The Computer Language Benchmarks Game\\n h...\n", + "7 java /* The Computer Language Benchmarks Game\\n h...\n", + "8 java /* The Computer Language Benchmarks Game\\n * h...\n", + "9 javascript /* The Computer Language Benchmarks Game\\n h...\n", + "10 ruby # The Computer Language Shootout Benchmarks\\n#...\n", + "11 ruby # The Computer Language Benchmarks Game\\n# htt...\n", + "12 ruby # The Computer Language Benchmarks Game\\n# htt...\n", + "13 ruby # The Computer Language Benchmarks Game\\n# htt...\n", + "14 ocaml (* The Computer Language Benchmarks Game\\n * h...\n", + "15 ocaml (* The Computer Language Benchmarks Game\\n * h...\n", + "16 ocaml (* The Computer Language Benchmarks Game\\n * h...\n", + "17 perl # The Computer Language Benchmarks Game\\n# htt...\n", + "18 perl # The Computer Language Benchmarks Game\\n# htt...\n", + "19 php >= readIO . head\\n let maxN = max (minN + 2) n\\n stretchN = maxN + 1\\n\\n -- stretch memory tree\\n let c = check (make 0 stretchN)\\n io \"stretch tree\" stretchN c\\n\\n -- allocate a long lived tree\\n let !long = make 0 maxN\\n\\n -- allocate, walk, and deallocate many bottom-up binary trees\\n let vs = depth minN maxN\\n mapM_ (\\\\((m,d,i)) -> io (show m ++ \"\\\\t trees\") d i) vs\\n\\n -- confirm the the long-lived binary tree still exists\\n io \"long lived tree\" maxN (check long)\\n\\n-- generate many trees\\ndepth :: Int -> Int -> [(Int,Int,Int)]\\ndepth d m\\n | d <= m = (2*n,d,sumT d n 0) : depth (d+2) m\\n | otherwise = []\\n where n = 1 `shiftL` (m - d + minN)\\n\\n-- allocate and check lots of trees\\nsumT :: Int -> Int -> Int -> Int\\nsumT d 0 t = t\\nsumT d i t = sumT d (i-1) (t + a + b)\\n where a = check (make i d)\\n b = check (make (-i) d)\\n\\n-- traverse the tree, counting up the nodes\\ncheck :: Tree -> Int\\ncheck Nil = 0\\ncheck (Node i l r) = i + check l - check r\\n\\n-- build a tree\\nmake :: Int -> Int -> Tree\\nmake i 0 = Node i Nil Nil\\nmake i d = Node i (make (i2-1) d2) (make i2 d2)\\n where i2 = 2*i; d2 = d-1\\n'" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def length_getter(code):\n", + " return len(code)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 33 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def character_counter(code, char):\n", + " counter = 0\n", + " for _ in code:\n", + " if _ == char:\n", + " counter+=1\n", + " return counter\n", + "\n", + "def character_ratio(code, char):\n", + " value = character_counter(code, char)/len(code)\n", + " return value\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 67 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def comma_counter(code):\n", + " counter = 0\n", + " for _ in code:\n", + " if _ == ',':\n", + " counter+=1\n", + " return counter\n", + "\n", + "def semicolon_counter(code):\n", + " counter = 0\n", + " for _ in code:\n", + " if _ == ';':\n", + " counter+=1\n", + " return counter" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 78 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def string_finder(string, code):\n", + " value = len(re.findall(string, code))\n", + " return value\n", + "\n", + "def string_ratio(string, code):\n", + " value = string_finder(string, code)/len(code)\n", + " return value" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 116 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df['code length'] = df.Code.apply(length_getter)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 34 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df['^'] = df.Code.apply(carat)\n", + "df[';'] = df.Code.apply(semicolon)\n", + "df[','] = df.Code.apply(comma)\n", + "df['&'] = df.Code.apply(carat)\n", + "df['!'] = df.Code.apply(semicolon)\n", + "df['|'] = df.Code.apply(comma)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 103 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def carat(code):\n", + " x =character_ratio(code, '^')\n", + " return x\n", + "\n", + "def comma(code):\n", + " x =character_ratio(code, ',')\n", + " return x\n", + "\n", + "def semicolon(code):\n", + " x =character_ratio(code, ';')\n", + " return x\n", + "\n", + "def ampersand(code):\n", + " x =character_ratio(code, '&')\n", + " return x\n", + "\n", + "def exclamation(code):\n", + " x =character_ratio(code, '!')\n", + " return x\n", + "\n", + "def pipe(code):\n", + " x =character_ratio(code, '|')\n", + " return x" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 102 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def let_ratio(code):\n", + " return string_ratio('let', code)\n", + "\n", + "def end_ratio(code):\n", + " return string_ratio('end', code)\n", + "\n", + "def fun_ratio(code):\n", + " return string_ratio('fun', code)\n", + "\n", + "def defn_ratio(code):\n", + " return string_ratio('defn', code)\n", + "\n", + "def def_ratio(code):\n", + " return string_ratio('def', code)\n", + "\n", + "def function_ratio(code):\n", + " return string_ratio('function', code)\n", + "\n", + "def return_ratio(code):\n", + " return string_ratio('return', code)\n", + "\n", + "def define_ratio(code):\n", + " return string_ratio('define', code)\n", + "\n", + "def doublecolon_ratio(code):\n", + " return string_ratio('::', code)\n", + "\n", + "def check_ratio(code):\n", + " return string_ratio('check', code)\n", + "\n", + "def make_ratio(code):\n", + " return string_ratio('make', code)\n", + "\n", + "def format_ratio(code):\n", + " return string_ratio('.format', code)\n", + "\n", + "def arrow_ratio(code):\n", + " return string_ratio('->', code)\n", + "\n", + "def dollar_ratio(code):\n", + " return string_ratio('$', code)\n", + "\n", + "def printf_ratio(code):\n", + " return string_ratio('printf', code)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 188 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df['let'] = df.Code.apply(let_ratio)\n", + "df['end'] = df.Code.apply(end_ratio)\n", + "df['fun'] = df.Code.apply(fun_ratio)\n", + "df['defn'] = df.Code.apply(defn_ratio)\n", + "df['def'] = df.Code.apply(def_ratio)\n", + "df['function'] = df.Code.apply(function_ratio)\n", + "df['return'] = df.Code.apply(return_ratio)\n", + "df['define'] = df.Code.apply(define_ratio)\n", + "df['doublecolon'] = df.Code.apply(doublecolon_ratio)\n", + "df['check'] = df.Code.apply(check_ratio)\n", + "df['make'] = df.Code.apply(make_ratio)\n", + "df['.format'] = df.Code.apply(format_ratio)\n", + "df['->'] = df.Code.apply(arrow_ratio)\n", + "df['$'] = df.Code.apply(dollar_ratio)\n", + "df['printf'] = df.Code.apply(printf_ratio)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 187 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
LanguageCodecode length^;,&!|let...fundefndeffunctionslicereturndefinedoublecoloncheckmake
0 clojure ;; The Computer Language Benchmarks Game\\n;; h... 2420 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826 0.002066... 0.000000 0.002066 0.004545 0.000000 0 0.000000 0.000000 0.000000 0.005372 0.000000
1 clojure ;; The Computer Language Benchmarks Game\\n;; h... 2594 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771 0.002699... 0.000000 0.001928 0.003470 0.000000 0 0.000000 0.000000 0.000000 0.005012 0.002699
2 clojure ;; The Computer Language Benchmarks Game\\n;; h... 2969 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347 0.002695... 0.000000 0.002021 0.003705 0.000000 0 0.000000 0.000000 0.000000 0.009094 0.000000
3 haskell --\\n-- The Computer Language Benchmarks Game\\n... 1619 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177 0.002471... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002471 0.006794 0.005559
4 haskell --\\n-- The Computer Language Benchmarks Game\\n... 1889 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294 0.002647... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002118 0.006882 0.004764
5 haskell --\\n-- The Computer Language Benchmarks Game\\n... 1745 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158 0.002865... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002292 0.007450 0.005158
6 java /* The Computer Language Benchmarks Game\\n h... 4072 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000737 0.000000 0.000000 0.002947 0.000000
7 java /* The Computer Language Benchmarks Game\\n h... 2112 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.001894 0.000000 0.000000 0.004261 0.000000
8 java /* The Computer Language Benchmarks Game\\n * h... 2157 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.001391 0.000000 0.000000 0.006027 0.000000
9 javascript /* The Computer Language Benchmarks Game\\n h... 1368 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234 0.000000... 0.002193 0.000000 0.000000 0.002193 0 0.002924 0.000000 0.000000 0.006579 0.000000
10 ruby # The Computer Language Shootout Benchmarks\\n#... 1246 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236 0.000000... 0.000000 0.000000 0.001605 0.000000 0 0.001605 0.000000 0.000000 0.011236 0.000000
11 ruby # The Computer Language Benchmarks Game\\n# htt... 1426 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921 0.000000... 0.000000 0.000000 0.001403 0.000000 0 0.001403 0.000000 0.000000 0.009818 0.000000
12 ruby # The Computer Language Benchmarks Game\\n# htt... 1263 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876 0.000000... 0.000000 0.000000 0.001584 0.000000 0 0.000000 0.000000 0.000000 0.011085 0.000000
13 ruby # The Computer Language Benchmarks Game\\n# htt... 4592 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324 0.000000... 0.000000 0.000000 0.002395 0.000000 0 0.000000 0.000000 0.000000 0.005444 0.000000
14 ocaml (* The Computer Language Benchmarks Game\\n * h... 1627 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459 0.012293... 0.001229 0.000000 0.000000 0.001229 0 0.000000 0.000000 0.000000 0.006146 0.004302
15 ocaml (* The Computer Language Benchmarks Game\\n * h... 2251 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887 0.009773... 0.002665 0.000000 0.000000 0.000888 0 0.000000 0.000000 0.000000 0.004442 0.003110
16 ocaml (* The Computer Language Benchmarks Game\\n * h... 1373 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370 0.010925... 0.000728 0.000000 0.000000 0.000728 0 0.000000 0.000000 0.000000 0.007283 0.005098
17 perl # The Computer Language Benchmarks Game\\n# htt... 1341 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423 0.000000... 0.000000 0.000000 0.000746 0.000000 0 0.000746 0.000000 0.000000 0.010440 0.000000
18 perl # The Computer Language Benchmarks Game\\n# htt... 2099 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293 0.000000... 0.000000 0.000000 0.000476 0.000000 0 0.001906 0.000000 0.000953 0.007623 0.000000
19 php <?php \\n/* The Computer Language Benchmarks Ga... 1578 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506 0.000000... 0.001267 0.000000 0.000000 0.001267 0 0.001901 0.000000 0.000000 0.004436 0.000000
20 php <?php \\n/* The Computer Language Benchmarks Ga... 1442 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709 0.000000... 0.001387 0.000000 0.000000 0.001387 0 0.000693 0.000000 0.000000 0.009015 0.000000
21 php <?php \\n/* The Computer Language Benchmarks Ga... 1476 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873 0.000000... 0.001355 0.000000 0.000000 0.001355 0 0.002033 0.000000 0.000000 0.004743 0.000000
22 php <?php \\n/* The Computer Language Benchmarks Ga... 3880 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206 0.000000... 0.000515 0.000000 0.000000 0.000515 0 0.001289 0.000000 0.000000 0.003866 0.000000
23 python # The Computer Language Benchmarks Game\\n# htt... 1796 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261 0.000000... 0.000557 0.000000 0.002784 0.000557 0 0.002784 0.000000 0.000000 0.007238 0.005568
24 scheme #lang racket/base\\n\\n;;; The Computer Language... 1716 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 0.002914... 0.000000 0.000000 0.004079 0.000000 0 0.000000 0.004079 0.000000 0.005828 0.004079
25 scheme #lang racket/base\\n\\n;;; The Computer Language... 2071 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000 0.003380... 0.000000 0.000000 0.005311 0.000000 0 0.000000 0.005311 0.000000 0.003863 0.005311
26 scheme #lang racket/base\\n\\n;;; The Computer Language... 2711 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000 0.001107... 0.000000 0.000000 0.009222 0.000000 0 0.000000 0.009222 0.000000 0.002951 0.004795
27 scala /* The Computer Language Benchmarks Game\\n h... 1554 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018 0.000000... 0.000000 0.000000 0.004505 0.000000 0 0.000000 0.000000 0.000000 0.001931 0.000000
28 scala /* The Computer Language Benchmarks Game\\n h... 1645 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805 0.000000... 0.000000 0.000000 0.003647 0.000000 0 0.000000 0.000000 0.000000 0.003040 0.000000
29 scala /* The Computer Language Benchmarks Game\\n h... 1310 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794 0.000000... 0.000000 0.000000 0.003053 0.000000 0 0.000000 0.000000 0.000000 0.002290 0.000000
..................................................................
356 python # The Computer Language Benchmarks Game\\n# htt... 1444 0.000000 0.000000 0.009003 0.000000 0.000000 0.009003 0.000000... 0.000000 0.000000 0.004848 0.000000 0 0.004155 0.000000 0.000000 0.000000 0.000000
357 python # The Computer Language Benchmarks Game\\n# htt... 1264 0.000000 0.000000 0.005538 0.000000 0.000000 0.005538 0.000000... 0.000000 0.000000 0.003956 0.000000 0 0.003165 0.000000 0.000000 0.000000 0.000000
358 python # The Computer Language Benchmarks Game\\n# htt... 1666 0.000000 0.000000 0.011405 0.000000 0.000000 0.011405 0.000000... 0.000000 0.000000 0.003001 0.000000 0 0.000600 0.000000 0.000000 0.000000 0.000000
359 scheme #lang racket/base\\n\\n;;; The Computer Language... 1842 0.000000 0.014115 0.000543 0.000000 0.014115 0.000543 0.002172... 0.000000 0.000000 0.002714 0.000000 0 0.000543 0.002714 0.000000 0.000000 0.001629
360 scheme #lang racket/base\\n\\n;;; The Computer Language... 2104 0.000000 0.013308 0.000475 0.000000 0.013308 0.000475 0.001901... 0.000000 0.000000 0.002376 0.000000 0 0.000475 0.002376 0.000000 0.000000 0.001901
361 scheme #lang racket/base\\n;; The Computer Language Be... 2071 0.000000 0.004829 0.000000 0.000000 0.004829 0.000000 0.003863... 0.000000 0.000000 0.005311 0.000000 0 0.000000 0.005311 0.000000 0.000000 0.001931
362 scala /* The Computer Language Benchmarks Game\\n h... 1196 0.000000 0.000836 0.015050 0.000000 0.000836 0.015050 0.000000... 0.000000 0.000000 0.002508 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
363 scala /* The Computer Language Benchmarks Game\\n h... 2433 0.000000 0.000000 0.009453 0.000000 0.000000 0.009453 0.000000... 0.000000 0.000000 0.002877 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
364 scala /* The Computer Language Benchmarks Game\\n h... 4040 0.000000 0.000000 0.009406 0.000000 0.000000 0.009406 0.000248... 0.000248 0.000000 0.002475 0.000248 0 0.000248 0.000000 0.000495 0.000000 0.000000
365 scala /* The Computer Language Benchmarks Game\\n h... 4364 0.000000 0.000000 0.008249 0.000000 0.000000 0.008249 0.000458... 0.000229 0.000000 0.002521 0.000229 0 0.000229 0.000000 0.000687 0.000000 0.000000
366 clojure ;; The Computer Language Benchmarks Game\\n;; h... 1115 0.002691 0.008969 0.000897 0.002691 0.008969 0.000897 0.001794... 0.000000 0.002691 0.002691 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
367 clojure ;; The Computer Language Benchmarks Game\\n;; h... 951 0.000000 0.011567 0.000000 0.000000 0.011567 0.000000 0.000000... 0.001052 0.003155 0.004206 0.001052 0 0.001052 0.000000 0.000000 0.000000 0.000000
368 haskell -- The Computer Language Benchmarks Game\\n-- h... 870 0.000000 0.000000 0.001149 0.000000 0.000000 0.001149 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.001149 0.000000 0.001149 0.000000 0.001149
369 java /**\\n * The Computer Language Benchmarks Game\\... 2229 0.000000 0.018394 0.000897 0.000000 0.018394 0.000897 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000897 0.000000 0.000000 0.000000 0.000000
370 java /**\\n * The Computer Language Benchmarks Game\\... 1666 0.000000 0.017407 0.001801 0.000000 0.017407 0.001801 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000600 0.000000 0.000000 0.000000 0.000000
371 java /**\\n * The Computer Language Benchmarks Game\\... 3934 0.000000 0.014743 0.002542 0.000000 0.014743 0.002542 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000508 0.000000 0.000000 0.000000 0.000000
372 java /**\\n * The Computer Language Benchmarks Game\\... 1330 0.000000 0.015038 0.000000 0.000000 0.015038 0.000000 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
373 java /**\\n * The Computer Language Benchmarks Game\\... 2536 0.000000 0.011435 0.001577 0.000000 0.011435 0.001577 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
374 java /**\\n * The Computer Language Benchmarks Game\\... 1598 0.000000 0.019399 0.000000 0.000000 0.019399 0.000000 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
375 ruby # The Computer Language Benchmarks Game\\n# htt... 919 0.000000 0.000000 0.001088 0.000000 0.000000 0.001088 0.000000... 0.000000 0.000000 0.004353 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
376 ruby # The Computer Language Benchmarks Game\\n# htt... 592 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
377 ocaml (* The Computer Language Benchmarks Game\\n * h... 689 0.000000 0.005806 0.000000 0.000000 0.005806 0.000000 0.011611... 0.002903 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
378 ocaml (* The Computer Language Benchmarks Game\\n * h... 848 0.000000 0.014151 0.002358 0.000000 0.014151 0.002358 0.010613... 0.000000 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
379 ocaml (* The Computer Language Benchmarks Game\\n * h... 733 0.000000 0.012278 0.002729 0.000000 0.012278 0.002729 0.010914... 0.001364 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
380 perl # The Computer Language Benchmarks Game\\n# htt... 940 0.000000 0.029787 0.001064 0.000000 0.029787 0.001064 0.000000... 0.002128 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.004255 0.000000 0.000000
381 perl # The Computer Language Benchmarks Game\\n# htt... 2381 0.000000 0.012180 0.004200 0.000000 0.012180 0.004200 0.000420... 0.000000 0.000000 0.000840 0.000000 0 0.000000 0.000420 0.001260 0.000000 0.000420
382 python # The Computer Language Benchmarks Game\\n# htt... 957 0.000000 0.000000 0.006270 0.000000 0.000000 0.006270 0.000000... 0.002090 0.000000 0.001045 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
383 python # The Computer Language Benchmarks Game\\n# htt... 821 0.000000 0.000000 0.003654 0.000000 0.000000 0.003654 0.000000... 0.001218 0.000000 0.002436 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
384 scheme #lang racket/base\\n\\n;;; The Computer Language... 767 0.000000 0.027379 0.000000 0.000000 0.027379 0.000000 0.003911... 0.000000 0.000000 0.001304 0.000000 0 0.000000 0.001304 0.000000 0.000000 0.000000
385 scala /* The Computer Language Benchmarks Game\\n h... 707 0.000000 0.001414 0.000000 0.000000 0.001414 0.000000 0.000000... 0.000000 0.000000 0.002829 0.000000 0 0.000000 0.000000 0.000000 0.000000 0.000000
\n", + "

386 rows \u00d7 21 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 159, + "text": [ + " Language Code \\\n", + "0 clojure ;; The Computer Language Benchmarks Game\\n;; h... \n", + "1 clojure ;; The Computer Language Benchmarks Game\\n;; h... \n", + "2 clojure ;; The Computer Language Benchmarks Game\\n;; h... \n", + "3 haskell --\\n-- The Computer Language Benchmarks Game\\n... \n", + "4 haskell --\\n-- The Computer Language Benchmarks Game\\n... \n", + "5 haskell --\\n-- The Computer Language Benchmarks Game\\n... \n", + "6 java /* The Computer Language Benchmarks Game\\n h... \n", + "7 java /* The Computer Language Benchmarks Game\\n h... \n", + "8 java /* The Computer Language Benchmarks Game\\n * h... \n", + "9 javascript /* The Computer Language Benchmarks Game\\n h... \n", + "10 ruby # The Computer Language Shootout Benchmarks\\n#... \n", + "11 ruby # The Computer Language Benchmarks Game\\n# htt... \n", + "12 ruby # The Computer Language Benchmarks Game\\n# htt... \n", + "13 ruby # The Computer Language Benchmarks Game\\n# htt... \n", + "14 ocaml (* The Computer Language Benchmarks Game\\n * h... \n", + "15 ocaml (* The Computer Language Benchmarks Game\\n * h... \n", + "16 ocaml (* The Computer Language Benchmarks Game\\n * h... \n", + "17 perl # The Computer Language Benchmarks Game\\n# htt... \n", + "18 perl # The Computer Language Benchmarks Game\\n# htt... \n", + "19 php item = $item;\n", + " if (!$depth) return $node;\n", + " $item2 = $item + $item;\n", + " $depth--;\n", + " $node->l = bottomUpTree($item2-1,$depth);\n", + " $node->r = bottomUpTree($item2,$depth);\n", + " return $node;\n", + "}\n", + "\n", + "function itemCheck($treeNode) { \n", + " return $treeNode->item\n", + " + ($treeNode->l->l === null ? itemCheck($treeNode->l) : $treeNode->l->item)\n", + " - ($treeNode->r->l === null ? itemCheck($treeNode->r) : $treeNode->r->item);\n", + "}\n", + "\n", + "$minDepth = 4;\n", + "\n", + "$n = ($argc == 2) ? $argv[1] : 1;\n", + "$maxDepth = max($minDepth + 2, $n);\n", + "$stretchDepth = $maxDepth + 1;\n", + "\n", + "$stretchTree = bottomUpTree(0, $stretchDepth);\n", + "printf(\"stretch tree of depth %d\\t check: %d\\n\", $stretchDepth, itemCheck($stretchTree));\n", + "unset($stretchTree);\n", + "\n", + "$longLivedTree = bottomUpTree(0, $maxDepth);\n", + "\n", + "$iterations = 1 << ($maxDepth);\n", + "do\n", + "{\n", + " $check = 0;\n", + " for($i = 1; $i <= $iterations; ++$i)\n", + " {\n", + " $t = bottomUpTree($i, $minDepth);\n", + " $check += itemCheck($t);\n", + " unset($t);\n", + " $t = bottomUpTree(-$i, $minDepth);\n", + " $check += itemCheck($t);\n", + " unset($t);\n", + " }\n", + " \n", + " printf(\"%d\\t trees of depth %d\\t check: %d\\n\", $iterations<<1, $minDepth, $check);\n", + " \n", + " $minDepth += 2;\n", + " $iterations >>= 2;\n", + "}\n", + "while($minDepth <= $maxDepth);\n", + "\n", + "printf(\"long lived tree of depth %d\\t check: %d\\n\",\n", + "$maxDepth, itemCheck($longLivedTree));\n", + "\n", + "\n" + ] + } + ], + "prompt_number": 184 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def tcode_sucker():\n", + " codelist = []\n", + " for subdir, dirs, files in os.walk(\"test/\"):\n", + " for fname in files:\n", + " with open(os.path.join(subdir, fname)) as current_file:\n", + " codelist.append(current_file.read()) \n", + " return codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 39 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_codelist = tcode_sucker()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 40 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df = pd.read_csv(\"test.csv\")" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 41 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df[\"Testcode\"] = test_codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 42 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df['code length'] = test_df.Testcode.apply(length_getter)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 59 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df['^'] = df.Code.apply(carat)\n", + "test_df[';'] = df.Code.apply(semicolon)\n", + "test_df[','] = df.Code.apply(comma)\n", + "test_df['&'] = df.Code.apply(carat)\n", + "test_df['!'] = df.Code.apply(semicolon)\n", + "test_df['|'] = df.Code.apply(comma)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 105 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df['let'] = df.Code.apply(let_ratio)\n", + "test_df['end'] = df.Code.apply(end_ratio)\n", + "test_df['fun'] = df.Code.apply(fun_ratio)\n", + "test_df['defn'] = df.Code.apply(defn_ratio)\n", + "test_df['def'] = df.Code.apply(def_ratio)\n", + "test_df['function'] = df.Code.apply(function_ratio)\n", + "test_df['slice'] = df.Code.apply(slice_ratio)\n", + "test_df['return'] = df.Code.apply(return_ratio)\n", + "test_df['define'] = df.Code.apply(define_ratio)\n", + "test_df['doublecolon'] = df.Code.apply(doublecolon_ratio)\n", + "test_df['check'] = df.Code.apply(check_ratio)\n", + "test_df['make'] = df.Code.apply(make_ratio)\n", + "test_df['.format'] = df.Code.apply(format_ratio)\n", + "test_df['->'] = df.Code.apply(arrow_ratio)\n", + "test_df['$'] = df.Code.apply(dollar_ratio)\n", + "test_df['printf'] = df.Code.apply(printf_ratio)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 189 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
FilenameLanguageTestcodecode length^;,&!|...defndeffunctionslicereturndefinedoublecoloncheckmake.format
0 1 clojure (defn cf-settings\\n \"Setup settings for campf... 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826... 0.002066 0.004545 0.000000 0 0.000000 0.000000 0.000000 0.005372 0.000000 0.001240
1 2 clojure var _ = require('lodash'),\\n fs = require('... 349 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771... 0.001928 0.003470 0.000000 0 0.000000 0.000000 0.000000 0.005012 0.002699 0.001157
2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... 17362 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347... 0.002021 0.003705 0.000000 0 0.000000 0.000000 0.000000 0.009094 0.000000 0.001010
3 4 clojure var r = riot.route = function(arg) {\\n //... 170 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002471 0.006794 0.005559 0.000000
4 5 python module ActiveJob\\n module Core\\n extend Ac... 3565 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002118 0.006882 0.004764 0.000000
5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... 491 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002292 0.007450 0.005158 0.000000
6 7 python module Fluent\\n class Input\\n include Conf... 490 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719... 0.000000 0.000000 0.000000 0 0.000737 0.000000 0.000000 0.002947 0.000000 0.000000
7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... 15305 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682... 0.000000 0.000000 0.000000 0 0.001894 0.000000 0.000000 0.004261 0.000000 0.000000
8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... 310 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636... 0.000000 0.000000 0.000000 0 0.001391 0.000000 0.000000 0.006027 0.000000 0.000000
9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... 2036 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234... 0.000000 0.000000 0.002193 0 0.002924 0.000000 0.000000 0.006579 0.000000 0.000000
10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... 386 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236... 0.000000 0.001605 0.000000 0 0.001605 0.000000 0.000000 0.011236 0.000000 0.000000
11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... 203 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921... 0.000000 0.001403 0.000000 0 0.001403 0.000000 0.000000 0.009818 0.000000 0.000000
12 13 ruby (define add1\\n (lambda (n) (+ n 1))) 36 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876... 0.000000 0.001584 0.000000 0 0.000000 0.000000 0.000000 0.011085 0.000000 0.000000
13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... 6712 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324... 0.000000 0.002395 0.000000 0 0.000000 0.000000 0.000000 0.005444 0.000000 0.000000
14 15 ruby /**\\n * Interface to represent a persistence s... 2107 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459... 0.000000 0.000000 0.001229 0 0.000000 0.000000 0.000000 0.006146 0.004302 0.000000
15 16 haskell /*\\n * Copyright 2002-2008 the original author... 1826 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887... 0.000000 0.000000 0.000888 0 0.000000 0.000000 0.000000 0.004442 0.003110 0.000000
16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... 2796 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370... 0.000000 0.000000 0.000728 0 0.000000 0.000000 0.000000 0.007283 0.005098 0.000000
17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... 1917 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423... 0.000000 0.000746 0.000000 0 0.000746 0.000000 0.000000 0.010440 0.000000 0.000000
18 19 scheme class View\\n{\\n /**\\n * Data available ... 6648 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293... 0.000000 0.000476 0.000000 0 0.001906 0.000000 0.000953 0.007623 0.000000 0.000000
19 20 scheme public function formatLocalized($format)\\n... 339 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506... 0.000000 0.000000 0.001267 0 0.001901 0.000000 0.000000 0.004436 0.000000 0.000000
20 21 scheme (extend-type String\\n Person\\n (first-name [... 143 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709... 0.000000 0.000000 0.001387 0 0.000693 0.000000 0.000000 0.009015 0.000000 0.000000
21 22 java class Application extends App {\\n\\t/**\\n\\t * @... 1954 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873... 0.000000 0.000000 0.001355 0 0.002033 0.000000 0.000000 0.004743 0.000000 0.000000
22 23 java type name = string\\n\\nlet compare_label label1... 7562 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206... 0.000000 0.000000 0.000515 0 0.001289 0.000000 0.000000 0.003866 0.000000 0.000000
23 24 scala let search_compiler_libs () =\\n prerr_endline... 575 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261... 0.000000 0.002784 0.000557 0 0.002784 0.000000 0.000000 0.007238 0.005568 0.001670
24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... 597 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000... 0.000000 0.004079 0.000000 0 0.000000 0.004079 0.000000 0.005828 0.004079 0.000000
25 28 php from pkgutil import iter_modules\\nfrom subproc... 602 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000... 0.000000 0.005311 0.000000 0 0.000000 0.005311 0.000000 0.003863 0.005311 0.000000
26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... 2852 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000... 0.000000 0.009222 0.000000 0 0.000000 0.009222 0.000000 0.002951 0.004795 0.000000
27 30 php class NoSuchService(Exception):\\n def __ini... 326 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018... 0.000000 0.004505 0.000000 0 0.000000 0.000000 0.000000 0.001931 0.000000 0.000000
28 31 ocaml from collections import namedtuple\\nimport fun... 20265 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805... 0.000000 0.003647 0.000000 0 0.000000 0.000000 0.000000 0.003040 0.000000 0.000000
29 32 ocaml function errorHandler(context) {\\n return fun... 1336 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794... 0.000000 0.003053 0.000000 0 0.000000 0.000000 0.000000 0.002290 0.000000 0.000000
\n", + "

30 rows \u00d7 23 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 173, + "text": [ + " Filename Language Testcode \\\n", + "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", + "1 2 clojure var _ = require('lodash'),\\n fs = require('... \n", + "2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", + "3 4 clojure var r = riot.route = function(arg) {\\n //... \n", + "4 5 python module ActiveJob\\n module Core\\n extend Ac... \n", + "5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", + "6 7 python module Fluent\\n class Input\\n include Conf... \n", + "7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", + "8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... \n", + "9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... \n", + "10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... \n", + "11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", + "12 13 ruby (define add1\\n (lambda (n) (+ n 1))) \n", + "13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... \n", + "14 15 ruby /**\\n * Interface to represent a persistence s... \n", + "15 16 haskell /*\\n * Copyright 2002-2008 the original author... \n", + "16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... \n", + "17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", + "18 19 scheme class View\\n{\\n /**\\n * Data available ... \n", + "19 20 scheme public function formatLocalized($format)\\n... \n", + "20 21 scheme (extend-type String\\n Person\\n (first-name [... \n", + "21 22 java class Application extends App {\\n\\t/**\\n\\t * @... \n", + "22 23 java type name = string\\n\\nlet compare_label label1... \n", + "23 24 scala let search_compiler_libs () =\\n prerr_endline... \n", + "24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... \n", + "25 28 php from pkgutil import iter_modules\\nfrom subproc... \n", + "26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", + "27 30 php class NoSuchService(Exception):\\n def __ini... \n", + "28 31 ocaml from collections import namedtuple\\nimport fun... \n", + "29 32 ocaml function errorHandler(context) {\\n return fun... \n", + "\n", + " code length ^ ; , & ! | \\\n", + "0 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826 \n", + "1 349 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771 \n", + "2 17362 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347 \n", + "3 170 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177 \n", + "4 3565 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294 \n", + "5 491 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158 \n", + "6 490 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719 \n", + "7 15305 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682 \n", + "8 310 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636 \n", + "9 2036 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234 \n", + "10 386 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236 \n", + "11 203 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921 \n", + "12 36 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876 \n", + "13 6712 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324 \n", + "14 2107 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459 \n", + "15 1826 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887 \n", + "16 2796 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370 \n", + "17 1917 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423 \n", + "18 6648 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293 \n", + "19 339 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506 \n", + "20 143 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709 \n", + "21 1954 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873 \n", + "22 7562 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206 \n", + "23 575 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261 \n", + "24 597 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 \n", + "25 602 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000 \n", + "26 2852 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000 \n", + "27 326 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018 \n", + "28 20265 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805 \n", + "29 1336 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794 \n", + "\n", + " ... defn def function slice return define \\\n", + "0 ... 0.002066 0.004545 0.000000 0 0.000000 0.000000 \n", + "1 ... 0.001928 0.003470 0.000000 0 0.000000 0.000000 \n", + "2 ... 0.002021 0.003705 0.000000 0 0.000000 0.000000 \n", + "3 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", + "4 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", + "5 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", + "6 ... 0.000000 0.000000 0.000000 0 0.000737 0.000000 \n", + "7 ... 0.000000 0.000000 0.000000 0 0.001894 0.000000 \n", + "8 ... 0.000000 0.000000 0.000000 0 0.001391 0.000000 \n", + "9 ... 0.000000 0.000000 0.002193 0 0.002924 0.000000 \n", + "10 ... 0.000000 0.001605 0.000000 0 0.001605 0.000000 \n", + "11 ... 0.000000 0.001403 0.000000 0 0.001403 0.000000 \n", + "12 ... 0.000000 0.001584 0.000000 0 0.000000 0.000000 \n", + "13 ... 0.000000 0.002395 0.000000 0 0.000000 0.000000 \n", + "14 ... 0.000000 0.000000 0.001229 0 0.000000 0.000000 \n", + "15 ... 0.000000 0.000000 0.000888 0 0.000000 0.000000 \n", + "16 ... 0.000000 0.000000 0.000728 0 0.000000 0.000000 \n", + "17 ... 0.000000 0.000746 0.000000 0 0.000746 0.000000 \n", + "18 ... 0.000000 0.000476 0.000000 0 0.001906 0.000000 \n", + "19 ... 0.000000 0.000000 0.001267 0 0.001901 0.000000 \n", + "20 ... 0.000000 0.000000 0.001387 0 0.000693 0.000000 \n", + "21 ... 0.000000 0.000000 0.001355 0 0.002033 0.000000 \n", + "22 ... 0.000000 0.000000 0.000515 0 0.001289 0.000000 \n", + "23 ... 0.000000 0.002784 0.000557 0 0.002784 0.000000 \n", + "24 ... 0.000000 0.004079 0.000000 0 0.000000 0.004079 \n", + "25 ... 0.000000 0.005311 0.000000 0 0.000000 0.005311 \n", + "26 ... 0.000000 0.009222 0.000000 0 0.000000 0.009222 \n", + "27 ... 0.000000 0.004505 0.000000 0 0.000000 0.000000 \n", + "28 ... 0.000000 0.003647 0.000000 0 0.000000 0.000000 \n", + "29 ... 0.000000 0.003053 0.000000 0 0.000000 0.000000 \n", + "\n", + " doublecolon check make .format \n", + "0 0.000000 0.005372 0.000000 0.001240 \n", + "1 0.000000 0.005012 0.002699 0.001157 \n", + "2 0.000000 0.009094 0.000000 0.001010 \n", + "3 0.002471 0.006794 0.005559 0.000000 \n", + "4 0.002118 0.006882 0.004764 0.000000 \n", + "5 0.002292 0.007450 0.005158 0.000000 \n", + "6 0.000000 0.002947 0.000000 0.000000 \n", + "7 0.000000 0.004261 0.000000 0.000000 \n", + "8 0.000000 0.006027 0.000000 0.000000 \n", + "9 0.000000 0.006579 0.000000 0.000000 \n", + "10 0.000000 0.011236 0.000000 0.000000 \n", + "11 0.000000 0.009818 0.000000 0.000000 \n", + "12 0.000000 0.011085 0.000000 0.000000 \n", + "13 0.000000 0.005444 0.000000 0.000000 \n", + "14 0.000000 0.006146 0.004302 0.000000 \n", + "15 0.000000 0.004442 0.003110 0.000000 \n", + "16 0.000000 0.007283 0.005098 0.000000 \n", + "17 0.000000 0.010440 0.000000 0.000000 \n", + "18 0.000953 0.007623 0.000000 0.000000 \n", + "19 0.000000 0.004436 0.000000 0.000000 \n", + "20 0.000000 0.009015 0.000000 0.000000 \n", + "21 0.000000 0.004743 0.000000 0.000000 \n", + "22 0.000000 0.003866 0.000000 0.000000 \n", + "23 0.000000 0.007238 0.005568 0.001670 \n", + "24 0.000000 0.005828 0.004079 0.000000 \n", + "25 0.000000 0.003863 0.005311 0.000000 \n", + "26 0.000000 0.002951 0.004795 0.000000 \n", + "27 0.000000 0.001931 0.000000 0.000000 \n", + "28 0.000000 0.003040 0.000000 0.000000 \n", + "29 0.000000 0.002290 0.000000 0.000000 \n", + "\n", + "[30 rows x 23 columns]" + ] + } + ], + "prompt_number": 173 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn import metrics" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 44 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 44 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train = df.loc[:,\"^\":]\n", + "x_test = test_df.loc[:, \"^\":]\n", + "y_train = df.Language\n", + "y_test = test_df.Language" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 190 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 166 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def run_classifier(clf, x_train, x_test, y_train, y_test):\n", + " clf.fit(x_train, y_train)\n", + " predicted = clf.predict(x_test)\n", + " print(metrics.classification_report(y_test, predicted))\n", + " print(metrics.confusion_matrix(y_test, predicted))\n", + " print(metrics.f1_score(y_test, predicted))" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 142 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn.cross_validation import cross_val_score\n", + "from sklearn.naive_bayes import GaussianNB\n", + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.ensemble import RandomForestClassifier" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 143 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "tree = DecisionTreeClassifier()\n", + "run_classifier(tree, x_train, x_test, y_train, y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " precision recall f1-score support\n", + "\n", + " clojure 1.00 0.75 0.86 4\n", + " haskell 0.00 0.00 0.00 3\n", + " java 0.00 0.00 0.00 2\n", + " javascript 1.00 0.25 0.40 4\n", + " ocaml 0.00 0.00 0.00 2\n", + " perl 0.00 0.00 0.00 0\n", + " php 0.00 0.00 0.00 3\n", + " python 0.00 0.00 0.00 4\n", + " ruby 0.50 0.67 0.57 3\n", + " scala 0.00 0.00 0.00 2\n", + " scheme 0.00 0.00 0.00 3\n", + "\n", + "avg / total 0.32 0.20 0.22 30\n", + "\n", + "[[3 1 0 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 2 1 0 0 0 0 0]\n", + " [0 0 0 0 0 0 2 0 0 0 0]\n", + " [0 0 1 1 0 0 0 0 2 0 0]\n", + " [0 0 0 0 0 0 0 0 0 2 0]\n", + " [0 0 0 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 0 0 0 0 0 1 2]\n", + " [0 2 2 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 1 0 0 0 2 0 0]\n", + " [0 0 0 0 0 0 0 1 0 0 1]\n", + " [0 0 0 0 0 1 2 0 0 0 0]]\n", + "0.224761904762\n" + ] + } + ], + "prompt_number": 191 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "gauss = GaussianNB()\n", + "run_classifier(gauss, x_train, x_test, y_train, y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " precision recall f1-score support\n", + "\n", + " clojure 1.00 0.75 0.86 4\n", + " haskell 0.00 0.00 0.00 3\n", + " java 0.00 0.00 0.00 2\n", + " javascript 1.00 0.25 0.40 4\n", + " ocaml 0.00 0.00 0.00 2\n", + " perl 0.00 0.00 0.00 0\n", + " php 0.00 0.00 0.00 3\n", + " python 0.00 0.00 0.00 4\n", + " ruby 0.40 0.67 0.50 3\n", + " scala 0.00 0.00 0.00 2\n", + " scheme 0.00 0.00 0.00 3\n", + "\n", + "avg / total 0.31 0.20 0.22 30\n", + "\n", + "[[3 1 0 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 2 1 0 0 0 0 0]\n", + " [0 0 0 0 0 0 2 0 0 0 0]\n", + " [0 0 1 1 0 0 0 0 2 0 0]\n", + " [0 0 0 0 0 0 0 2 0 0 0]\n", + " [0 0 0 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 0 0 0 0 1 0 2]\n", + " [0 2 2 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 1 0 0 0 2 0 0]\n", + " [0 0 0 0 0 0 0 1 0 0 1]\n", + " [0 0 0 0 0 1 2 0 0 0 0]]\n", + "0.217619047619\n" + ] + } + ], + "prompt_number": 192 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/programming-language-classifier/workbook.ipynb b/programming-language-classifier/workbook.ipynb deleted file mode 100644 index 234ef19..0000000 --- a/programming-language-classifier/workbook.ipynb +++ /dev/null @@ -1,1015 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:6b2f7875aa3379877868ef9f69e01701c37edab259ecd180a1d40b11f417ae2b" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import os\n", - "import pandas as pd" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 27 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "filename_dict = {\".clj\":\"Clojure\",\n", - " \".cljs\": \"Clojure\",\n", - " \".edn\": \"Clojure\",\n", - " \".clojure\": \"Clojure\",\n", - " \".hs\": \"Haskell\",\n", - " \".lhs\": \"Haskell\",\n", - " \".java\": \"Java\",\n", - " \".class\": \"Java\",\n", - " \".jar\": \"Java\",\n", - " \".js\": \"Javascript\",\n", - " \".javascript\": \"Javascript\",\n", - " \".ocaml\": \"OCaml\",\n", - " \".ml\": \"OCaml\",\n", - " \".pl\": \"Perl\",\n", - " \".pm\": \"Perl\",\n", - " \".t\": \"Perl\",\n", - " \".pod\": \"Perl\",\n", - " \".php\": \"PHP\",\n", - " \".perl\": \"Perl\",\n", - " \".phtml\": \"PHP\",\n", - " \".php4\": \"PHP\",\n", - " \".php3\": \"PHP\",\n", - " \".php5\": \"PHP\",\n", - " \".phps\": \"PHP\",\n", - " \".py\": \"Python\",\n", - " \".pyw\": \"Python\",\n", - " \".pyc\": \"Python\",\n", - " \".pyo\": \"Python\",\n", - " \".pyd\": \"Python\",\n", - " \".python3\": \"Python\",\n", - " \".Python2\": \"Python\",\n", - " \".rb\": \"Ruby\",\n", - " \".rbw\": \"Ruby\",\n", - " \".jruby\": \"Ruby\",\n", - " \".scala\": \"Scala\",\n", - " \".scm\": \"Scheme\",\n", - " \".ss\": \"Scheme\",\n", - " \".tcl\": \"Tcl\",\n", - " \".racket\": \"Scheme\",\n", - " \".ghc\": \"Haskell\"}" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def tuple_maker(adict):\n", - " lista = []\n", - " for key in adict:\n", - " lista.append(key)\n", - " tup = tuple(lista)\n", - " return tup" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 3 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def function_name():\n", - " codelist = []\n", - " for subdir, dirs, files in os.walk(\"bench/\"):\n", - " for fname in files:\n", - " if fname.endswith(tuple_maker(filename_dict)):\n", - " #print(fname)\n", - " with open(os.path.join(subdir, fname)) as current_file:\n", - " codelist.append(current_file.read()) \n", - " return codelist" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 14 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "codelist = function_name()" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 15 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "len(codelist)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "metadata": {}, - "output_type": "pyout", - "prompt_number": 17, - "text": [ - "386" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def type_getter():\n", - " rootDir = 'bench'\n", - " typelist = []\n", - " for subdir, dirs, files in os.walk(rootDir):\n", - " for fname in files:\n", - " #print('\\t%s' % fname)\n", - " name, extension = os.path.splitext(fname)\n", - " if extension in filename_dict:\n", - " print(filename_dict[extension])\n", - " typelist.append(filename_dict[extension])\n", - " return typelist" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 24 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "typelist = type_getter()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Javascript\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "PHP\n", - "PHP\n", - "PHP\n", - "PHP\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Java\n", - "Ruby\n", - "Scala\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Python\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "PHP\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Javascript\n", - "Javascript\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "Perl\n", - "Perl\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Java\n", - "Perl\n", - "Perl\n", - "PHP\n", - "Python\n", - "Python\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "Perl\n", - "Perl\n", - "PHP\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Javascript\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "Python\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Ruby\n", - "OCaml\n", - "Perl\n", - "PHP\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "Perl\n", - "Perl\n", - "PHP\n", - "PHP\n", - "PHP\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Javascript\n", - "Javascript\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "Perl\n", - "Perl\n", - "PHP\n", - "PHP\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Haskell\n", - "Java\n", - "Java\n", - "Javascript\n", - "Javascript\n", - "Javascript\n", - "Ruby\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "Perl\n", - "Perl\n", - "PHP\n", - "PHP\n", - "Python\n", - "Python\n", - "Python\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scheme\n", - "Scheme\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Scala\n", - "Clojure\n", - "Clojure\n", - "Haskell\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Java\n", - "Ruby\n", - "Ruby\n", - "OCaml\n", - "OCaml\n", - "OCaml\n", - "Perl\n", - "Perl\n", - "Python\n", - "Python\n", - "Scheme\n", - "Scala\n" - ] - } - ], - "prompt_number": 25 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "len(typelist)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "metadata": {}, - "output_type": "pyout", - "prompt_number": 26, - "text": [ - "386" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "df = pd.DataFrame(typelist, index=range(386))" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 32 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "df.columns = [\"Language\"]\n", - "df[\"Code\"] = codelist" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 35 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "df" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
LanguageCode
0 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
1 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
2 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
3 Haskell --\\n-- The Computer Language Benchmarks Game\\n...
4 Haskell --\\n-- The Computer Language Benchmarks Game\\n...
5 Haskell --\\n-- The Computer Language Benchmarks Game\\n...
6 Java /* The Computer Language Benchmarks Game\\n h...
7 Java /* The Computer Language Benchmarks Game\\n h...
8 Java /* The Computer Language Benchmarks Game\\n * h...
9 Javascript /* The Computer Language Benchmarks Game\\n h...
10 Ruby # The Computer Language Shootout Benchmarks\\n#...
11 Ruby # The Computer Language Benchmarks Game\\n# htt...
12 Ruby # The Computer Language Benchmarks Game\\n# htt...
13 Ruby # The Computer Language Benchmarks Game\\n# htt...
14 OCaml (* The Computer Language Benchmarks Game\\n * h...
15 OCaml (* The Computer Language Benchmarks Game\\n * h...
16 OCaml (* The Computer Language Benchmarks Game\\n * h...
17 Perl # The Computer Language Benchmarks Game\\n# htt...
18 Perl # The Computer Language Benchmarks Game\\n# htt...
19 PHP <?php \\n/* The Computer Language Benchmarks Ga...
20 PHP <?php \\n/* The Computer Language Benchmarks Ga...
21 PHP <?php \\n/* The Computer Language Benchmarks Ga...
22 PHP <?php \\n/* The Computer Language Benchmarks Ga...
23 Python # The Computer Language Benchmarks Game\\n# htt...
24 Scheme #lang racket/base\\n\\n;;; The Computer Language...
25 Scheme #lang racket/base\\n\\n;;; The Computer Language...
26 Scheme #lang racket/base\\n\\n;;; The Computer Language...
27 Scala /* The Computer Language Benchmarks Game\\n h...
28 Scala /* The Computer Language Benchmarks Game\\n h...
29 Scala /* The Computer Language Benchmarks Game\\n h...
.........
356 Python # The Computer Language Benchmarks Game\\n# htt...
357 Python # The Computer Language Benchmarks Game\\n# htt...
358 Python # The Computer Language Benchmarks Game\\n# htt...
359 Scheme #lang racket/base\\n\\n;;; The Computer Language...
360 Scheme #lang racket/base\\n\\n;;; The Computer Language...
361 Scheme #lang racket/base\\n;; The Computer Language Be...
362 Scala /* The Computer Language Benchmarks Game\\n h...
363 Scala /* The Computer Language Benchmarks Game\\n h...
364 Scala /* The Computer Language Benchmarks Game\\n h...
365 Scala /* The Computer Language Benchmarks Game\\n h...
366 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
367 Clojure ;; The Computer Language Benchmarks Game\\n;; h...
368 Haskell -- The Computer Language Benchmarks Game\\n-- h...
369 Java /**\\n * The Computer Language Benchmarks Game\\...
370 Java /**\\n * The Computer Language Benchmarks Game\\...
371 Java /**\\n * The Computer Language Benchmarks Game\\...
372 Java /**\\n * The Computer Language Benchmarks Game\\...
373 Java /**\\n * The Computer Language Benchmarks Game\\...
374 Java /**\\n * The Computer Language Benchmarks Game\\...
375 Ruby # The Computer Language Benchmarks Game\\n# htt...
376 Ruby # The Computer Language Benchmarks Game\\n# htt...
377 OCaml (* The Computer Language Benchmarks Game\\n * h...
378 OCaml (* The Computer Language Benchmarks Game\\n * h...
379 OCaml (* The Computer Language Benchmarks Game\\n * h...
380 Perl # The Computer Language Benchmarks Game\\n# htt...
381 Perl # The Computer Language Benchmarks Game\\n# htt...
382 Python # The Computer Language Benchmarks Game\\n# htt...
383 Python # The Computer Language Benchmarks Game\\n# htt...
384 Scheme #lang racket/base\\n\\n;;; The Computer Language...
385 Scala /* The Computer Language Benchmarks Game\\n h...
\n", - "

386 rows \u00d7 2 columns

\n", - "
" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 36, - "text": [ - " Language Code\n", - "0 Clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", - "1 Clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", - "2 Clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", - "3 Haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", - "4 Haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", - "5 Haskell --\\n-- The Computer Language Benchmarks Game\\n...\n", - "6 Java /* The Computer Language Benchmarks Game\\n h...\n", - "7 Java /* The Computer Language Benchmarks Game\\n h...\n", - "8 Java /* The Computer Language Benchmarks Game\\n * h...\n", - "9 Javascript /* The Computer Language Benchmarks Game\\n h...\n", - "10 Ruby # The Computer Language Shootout Benchmarks\\n#...\n", - "11 Ruby # The Computer Language Benchmarks Game\\n# htt...\n", - "12 Ruby # The Computer Language Benchmarks Game\\n# htt...\n", - "13 Ruby # The Computer Language Benchmarks Game\\n# htt...\n", - "14 OCaml (* The Computer Language Benchmarks Game\\n * h...\n", - "15 OCaml (* The Computer Language Benchmarks Game\\n * h...\n", - "16 OCaml (* The Computer Language Benchmarks Game\\n * h...\n", - "17 Perl # The Computer Language Benchmarks Game\\n# htt...\n", - "18 Perl # The Computer Language Benchmarks Game\\n# htt...\n", - "19 PHP Date: Fri, 13 Feb 2015 21:16:07 -0500 Subject: [PATCH 3/9] made my megafunction --- plc/workbook.ipynb | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/plc/workbook.ipynb b/plc/workbook.ipynb index c974277..88f8227 100644 --- a/plc/workbook.ipynb +++ b/plc/workbook.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:30544480392234b3bde3c304b51b9ee0b41e65f8c2b482bbce68de6060e3ab15" + "signature": "sha256:1b276628b91aa6f93e909526ed4263f16818b2c785da2a7f4712e8f663929476" }, "nbformat": 3, "nbformat_minor": 0, @@ -731,6 +731,48 @@ "outputs": [], "prompt_number": 34 }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "word_list = ['let', 'end', 'defn', 'function', 'fun', 'defn', 'def', 'return', 'check', 'make', '.format', '$', 'printf']" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 193 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def data_frame_generator():\n", + " codelist = code_sucker()\n", + " typelist = type_getter()\n", + " df = pd.DataFrame(typelist, index=range(386))\n", + " df.columns = [\"Language\"]\n", + " df[\"Code\"] = codelist\n", + " df['Language'] = df.Language.apply(lambda x:x.lower())\n", + " for string in word_list:\n", + " def sub_function(code):\n", + " x = string_ratio(string, code)\n", + " return x\n", + " df[string] = df.Code.apply(sub_function)\n", + " return df" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 194 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + }, { "cell_type": "code", "collapsed": false, From 24c558f8d6dcd94bb633b0e93875eaef8cb08385 Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Sat, 14 Feb 2015 10:11:49 -0500 Subject: [PATCH 4/9] new streamlined notebook --- plc/Code Classifier.ipynb | 266 ++ plc/classifier.py | 17 + plc/features.py | 2 +- plc/test.csv | 31 + plc/test/1 | 30 + plc/test/10 | 14 + plc/test/11 | 789 ++++++ plc/test/12 | 11 + plc/test/13 | 112 + plc/test/14 | 16 + plc/test/15 | 30 + plc/test/16 | 364 +++ plc/test/17 | 5 + plc/test/18 | 69 + plc/test/19 | 18 + plc/test/2 | 9 + plc/test/20 | 2 + plc/test/21 | 220 ++ plc/test/22 | 64 + plc/test/23 | 59 + plc/test/24 | 77 + plc/test/25 | 48 + plc/test/28 | 209 ++ plc/test/29 | 9 + plc/test/3 | 4 + plc/test/30 | 61 + plc/test/31 | 213 ++ plc/test/32 | 15 + plc/test/4 | 21 + plc/test/5 | 26 + plc/test/6 | 88 + plc/test/7 | 15 + plc/test/8 | 532 ++++ plc/test/9 | 53 + plc/workbook.ipynb | 5463 +++++++++++++++++++++++++++---------- 35 files changed, 7482 insertions(+), 1480 deletions(-) create mode 100644 plc/Code Classifier.ipynb create mode 100644 plc/classifier.py create mode 100644 plc/test.csv create mode 100644 plc/test/1 create mode 100644 plc/test/10 create mode 100644 plc/test/11 create mode 100644 plc/test/12 create mode 100644 plc/test/13 create mode 100644 plc/test/14 create mode 100644 plc/test/15 create mode 100644 plc/test/16 create mode 100644 plc/test/17 create mode 100644 plc/test/18 create mode 100644 plc/test/19 create mode 100644 plc/test/2 create mode 100644 plc/test/20 create mode 100644 plc/test/21 create mode 100644 plc/test/22 create mode 100644 plc/test/23 create mode 100644 plc/test/24 create mode 100644 plc/test/25 create mode 100644 plc/test/28 create mode 100644 plc/test/29 create mode 100644 plc/test/3 create mode 100644 plc/test/30 create mode 100644 plc/test/31 create mode 100644 plc/test/32 create mode 100644 plc/test/4 create mode 100644 plc/test/5 create mode 100644 plc/test/6 create mode 100644 plc/test/7 create mode 100644 plc/test/8 create mode 100644 plc/test/9 diff --git a/plc/Code Classifier.ipynb b/plc/Code Classifier.ipynb new file mode 100644 index 0000000..6461510 --- /dev/null +++ b/plc/Code Classifier.ipynb @@ -0,0 +1,266 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:506a4c7268842306b7c8e76a3a9556459f92507e332006299787ba26f077df1d" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from data_load import*\n", + "from features import*\n", + "from classifier import*" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 55 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import pandas as pd\n", + "import re" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 56 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "word_list = ['let', 'end', 'defn', 'function', 'fun', 'return', 'def', 'return', 'check', 'make', '->', '.format',\n", + " 'define', '::', 'done', 'type', 'rescue']\n", + "symbol_list = ['$', '^', ',', ';', '&', '|', '!']" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 57 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def data_frame_generator():\n", + " codelist = code_sucker()\n", + " typelist = type_getter()\n", + " df = pd.DataFrame(typelist, index=range(386))\n", + " df.columns = [\"Language\"]\n", + " df[\"Code\"] = codelist\n", + " df['Language'] = df.Language.apply(lambda x:x.lower())\n", + " for string in word_list:\n", + " def sub_function(code):\n", + " x = string_ratio(string, code)\n", + " return x\n", + " df[string] = df.Code.apply(sub_function)\n", + " for char in symbol_list:\n", + " def sub_function2(code):\n", + " y = character_ratio(code, char)\n", + " return y\n", + " df[char] = df.Code.apply(sub_function2)\n", + " return df" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 58 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df = data_frame_generator()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 59 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#df.head(2)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 60 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def tdata_frame_generator():\n", + " test_codelist = tcode_sucker()\n", + " df = pd.read_csv(\"test.csv\")\n", + " df[\"Code\"] = test_codelist\n", + " for string in word_list:\n", + " def sub_function(code):\n", + " x = string_ratio(string, code)\n", + " return x\n", + " df[string] = df.Code.apply(sub_function)\n", + " for char in symbol_list:\n", + " def sub_function2(code):\n", + " y = character_ratio(code, char)\n", + " return y\n", + " df[char] = df.Code.apply(sub_function2)\n", + " return df" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 61 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df = tdata_frame_generator()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 62 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#test_df" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 69 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train, x_test, y_train, y_test = create_xy(df, test_df, word_list[0], 'Language')" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 64 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn.naive_bayes import GaussianNB\n", + "from sklearn.tree import DecisionTreeClassifier" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 65 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "tree = DecisionTreeClassifier()\n", + "run_classifier(tree, x_train, x_test, y_train, y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " precision recall f1-score support\n", + "\n", + " clojure 0.33 0.25 0.29 4\n", + " haskell 0.25 0.33 0.29 3\n", + " java 0.00 0.00 0.00 2\n", + " javascript 0.25 0.25 0.25 4\n", + " ocaml 0.00 0.00 0.00 2\n", + " php 0.00 0.00 0.00 3\n", + " python 0.00 0.00 0.00 4\n", + " ruby 0.00 0.00 0.00 3\n", + " scala 0.00 0.00 0.00 2\n", + " scheme 0.00 0.00 0.00 3\n", + "\n", + "avg / total 0.10 0.10 0.10 30\n", + "\n", + "[[1 0 0 2 0 0 1 0 0 0]\n", + " [0 1 1 0 0 0 0 0 1 0]\n", + " [0 0 0 0 0 1 0 0 1 0]\n", + " [1 2 0 1 0 0 0 0 0 0]\n", + " [0 0 0 1 0 0 0 1 0 0]\n", + " [0 0 0 0 0 0 2 1 0 0]\n", + " [0 1 0 0 0 0 0 3 0 0]\n", + " [0 0 1 0 0 0 0 0 2 0]\n", + " [1 0 0 0 1 0 0 0 0 0]\n", + " [0 0 0 0 0 2 0 1 0 0]]\n", + "0.1\n" + ] + } + ], + "prompt_number": 66 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "gauss = GaussianNB()\n", + "run_classifier(gauss, x_train, x_test, y_train, y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " precision recall f1-score support\n", + "\n", + " clojure 0.25 0.25 0.25 4\n", + " haskell 0.00 0.00 0.00 3\n", + " java 0.00 0.00 0.00 2\n", + " javascript 0.00 0.00 0.00 4\n", + " ocaml 0.00 0.00 0.00 2\n", + " perl 0.00 0.00 0.00 0\n", + " php 0.00 0.00 0.00 3\n", + " python 0.20 0.25 0.22 4\n", + " ruby 0.00 0.00 0.00 3\n", + " scala 0.00 0.00 0.00 2\n", + " scheme 0.00 0.00 0.00 3\n", + "\n", + "avg / total 0.06 0.07 0.06 30\n", + "\n", + "[[1 0 0 2 0 0 1 0 0 0 0]\n", + " [1 0 0 1 0 1 0 0 0 0 0]\n", + " [0 0 0 0 1 0 1 0 0 0 0]\n", + " [1 0 0 0 1 1 1 0 0 0 0]\n", + " [0 0 0 1 0 0 0 1 0 0 0]\n", + " [0 0 0 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 0 0 0 3 0 0 0]\n", + " [0 0 0 0 0 1 1 1 1 0 0]\n", + " [0 1 0 0 0 0 0 0 0 0 2]\n", + " [1 0 0 0 1 0 0 0 0 0 0]\n", + " [0 0 0 0 1 0 2 0 0 0 0]]\n", + "0.062962962963\n" + ] + } + ], + "prompt_number": 67 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/plc/classifier.py b/plc/classifier.py new file mode 100644 index 0000000..af69ddd --- /dev/null +++ b/plc/classifier.py @@ -0,0 +1,17 @@ +from sklearn import metrics + + +def create_xy(df, test_df, startx, columny): + x_train = df.loc[:, startx:] + x_test = test_df.loc[:, startx:] + y_train = df[columny] + y_test = test_df[columny] + return x_train, x_test, y_train, y_test + + +def run_classifier(clf, x_train, x_test, y_train, y_test): + clf.fit(x_train, y_train) + predicted = clf.predict(x_test) + print(metrics.classification_report(y_test, predicted)) + print(metrics.confusion_matrix(y_test, predicted)) + print(metrics.f1_score(y_test, predicted)) diff --git a/plc/features.py b/plc/features.py index b8b2620..328db60 100644 --- a/plc/features.py +++ b/plc/features.py @@ -16,5 +16,5 @@ def string_finder(string, code): return value def string_ratio(string, code): - value = string_ratio(string, code)/len(code) + value = string_finder(string, code)/len(code) return value diff --git a/plc/test.csv b/plc/test.csv new file mode 100644 index 0000000..289113e --- /dev/null +++ b/plc/test.csv @@ -0,0 +1,31 @@ +Filename,Language +1,clojure +2,clojure +3,clojure +4,clojure +5,python +6,python +7,python +8,python +9,javascript +10,javascript +11,javascript +12,javascript +13,ruby +14,ruby +15,ruby +16,haskell +17,haskell +18,haskell +19,scheme +20,scheme +21,scheme +22,java +23,java +24,scala +25,scala +28,php +29,php +30,php +31,ocaml +32,ocaml diff --git a/plc/test/1 b/plc/test/1 new file mode 100644 index 0000000..e34d574 --- /dev/null +++ b/plc/test/1 @@ -0,0 +1,30 @@ +(defn cf-settings + "Setup settings for campfire. Required information is your api-token, ssl connection + true or false, and your campfire sub-domain." + [token ssl sub-domain] + {:api-token token, :ssl ssl, :sub-domain sub-domain}) + +(defn room + "Sets up the room to send events too. Pass in the settings created with cf-settings + and the room name" + [settings room-name] + (cf/room-by-name settings room-name)) + +(defn campfire_message + "Formats an event into a string" + [e] + (str (join " " ["Riemann alert on" (str (:host e)) "-" (str (:service e)) "is" (upper-case (str (:state e))) "- Description:" (str (:description e))]))) + +(defn campfire + "Creates an adaptor to forward events to campfire. The campfire event will + contain the host, state, service, metric and description. + Tested with: + (streams + (by [:host, :service] + (let [camp (campfire \"token\", true, \"sub-domain\", \"room\")] + camp)))" + [token ssl sub-domain room-name] + (fn [e] + (let [message_string (campfire_message e) + settings (cf-settings token ssl sub-domain)] + (cf/message (room settings room-name) message_string)))) \ No newline at end of file diff --git a/plc/test/10 b/plc/test/10 new file mode 100644 index 0000000..7ae70f9 --- /dev/null +++ b/plc/test/10 @@ -0,0 +1,14 @@ +var _ = require('lodash'), + fs = require('fs'), + yaml = require('js-yaml'); + +function getDefaultSettings() { + return yaml.safeLoad(fs.readFileSync('defaults.yml', 'utf8')); +} + +function getFileSettings() { + if (fs.existsSync('settings.yml')) { + return yaml.safeLoad(fs.readFileSync('settings.yml', 'utf8')); + } + return {}; +} diff --git a/plc/test/11 b/plc/test/11 new file mode 100644 index 0000000..53a58a4 --- /dev/null +++ b/plc/test/11 @@ -0,0 +1,789 @@ +/* Riot v2.0.8, @license MIT, (c) 2015 Muut Inc. + contributors */ + +;(function() { + +var riot = { version: 'v2.0.8', settings: {} } + +'use strict' + +riot.observable = function(el) { + + el = el || {} + + var callbacks = {} + + el.on = function(events, fn) { + if (typeof fn == 'function') { + events.replace(/\S+/g, function(name, pos) { + (callbacks[name] = callbacks[name] || []).push(fn) + fn.typed = pos > 0 + }) + } + return el + } + + el.off = function(events, fn) { + if (events == '*') callbacks = {} + else if (fn) { + var arr = callbacks[events] + for (var i = 0, cb; (cb = arr && arr[i]); ++i) { + if (cb == fn) { arr.splice(i, 1); i-- } + } + } else { + events.replace(/\S+/g, function(name) { + callbacks[name] = [] + }) + } + return el + } + + // only single event supported + el.one = function(name, fn) { + if (fn) fn.one = 1 + return el.on(name, fn) + } + + el.trigger = function(name) { + var args = [].slice.call(arguments, 1), + fns = callbacks[name] || [] + + for (var i = 0, fn; (fn = fns[i]); ++i) { + if (!fn.busy) { + fn.busy = 1 + fn.apply(el, fn.typed ? [name].concat(args) : args) + if (fn.one) { fns.splice(i, 1); i-- } + else if (fns[i] !== fn) { i-- } // Makes self-removal possible during iteration + fn.busy = 0 + } + } + + return el + } + + return el + +} +;(function(riot, evt) { + + // browsers only + if (!this.top) return + + var loc = location, + fns = riot.observable(), + current = hash(), + win = window + + function hash() { + return loc.hash.slice(1) + } + + function parser(path) { + return path.split('/') + } + + function emit(path) { + if (path.type) path = hash() + + if (path != current) { + fns.trigger.apply(null, ['H'].concat(parser(path))) + current = path + } + } + + var r = riot.route = function(arg) { + // string + if (arg[0]) { + loc.hash = arg + emit(arg) + + // function + } else { + fns.on('H', arg) + } + } + + r.exec = function(fn) { + fn.apply(null, parser(hash())) + } + + r.parser = function(fn) { + parser = fn + } + + win.addEventListener ? win.addEventListener(evt, emit, false) : win.attachEvent('on' + evt, emit) + +})(riot, 'hashchange') +/* + +//// How it works? + + +Three ways: + +1. Expressions: tmpl('{ value }', data). + Returns the result of evaluated expression as a raw object. + +2. Templates: tmpl('Hi { name } { surname }', data). + Returns a string with evaluated expressions. + +3. Filters: tmpl('{ show: !done, highlight: active }', data). + Returns a space separated list of trueish keys (mainly + used for setting html classes), e.g. "show highlight". + + +// Template examples + +tmpl('{ title || "Untitled" }', data) +tmpl('Results are { results ? "ready" : "loading" }', data) +tmpl('Today is { new Date() }', data) +tmpl('{ message.length > 140 && "Message is too long" }', data) +tmpl('This item got { Math.round(rating) } stars', data) +tmpl('

{ title }

{ body }', data) + + +// Falsy expressions in templates + +In templates (as opposed to single expressions) all falsy values +except zero (undefined/null/false) will default to empty string: + +tmpl('{ undefined } - { false } - { null } - { 0 }', {}) +// will return: " - - - 0" + + +// Customizable brackets + + riot.settings.brackets = '[ ]' + riot.settings.brackets = '<% %>' + +*/ + +var tmpl = (function() { + + var cache = {}, + brackets, + re_expr, + re_vars = /("|').+?[^\\]\1|\.\w*|\w*:|\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\b|function *\()|([a-z_]\w*)/gi + // [ 1 ][ 2 ][ 3 ][ 4 ][ 5 ] + // find variable names: + // 1. skip quoted strings: "a b", 'a b', 'a \'b\'' + // 2. skip object properties: .name + // 3. skip object literals: name: + // 4. skip javascript keywords + // 5. match var name + + return function(str, data) { + + // make sure we use current brackets setting + var b = riot.settings.brackets || '{ }' + if(b != brackets){ + brackets = b.split(' ') + re_expr = re(/({[\s\S]*?})/) + } + + // build a template (or get it from cache), render with data + // (or just test if string has expression when called w/o data) + return data + ? str && (cache[str] = cache[str] || tmpl(str))(data) + : re_expr.test(str) + + } + + + // create a template instance + + function tmpl(s, p) { + + // default template string to {} + p = (s || brackets.join('')) + + // temporarily convert \{ and \} to a non-character + .replace(re(/\\{/), '\uFFF0') + .replace(re(/\\}/), '\uFFF1') + + // split string to expression and non-expresion parts + .split(re_expr) + + return new Function('d', 'return ' + ( + + // is it a single expression or a template? i.e. {x} or {x} + !p[0] && !p[2] && !p[3] + + // if expression, evaluate it + ? expr(p[1]) + + // if template, evaluate all expressions in it + : '[' + p.map(function(s, i) { + + // is it an expression or a string (every second part is an expression) + return i % 2 + + // evaluate the expressions + ? expr(s, 1) + + // process string parts of the template: + : '"' + s + + // preserve new lines + .replace(/\n/g, '\\n') + + // escape quotes + .replace(/"/g, '\\"') + + + '"' + + }).join(',') + '].join("")' + ) + + // bring escaped { and } back + .replace(/\uFFF0/g, brackets[0]) + .replace(/\uFFF1/g, brackets[1]) + + ) + + } + + + // parse { ... } expression + + function expr(s, n) { + s = s + + // convert new lines to spaces + .replace(/\n/g, ' ') + + // trim whitespace, curly brackets, strip comments + .replace(re(/^[{ ]+|[ }]+$|\/\*.+?\*\//g), '') + + // is it an object literal? i.e. { key : value } + return /^\s*[\w-"']+ *:/.test(s) + + // if object literal, return trueish keys + // e.g.: { show: isOpen(), done: item.done } -> "show done" + ? '[' + s.replace(/\W*([\w-]+)\W*:([^,]+)/g, function(_, k, v) { + + // safely execute vars to prevent undefined value errors + return v.replace(/\w[^,|& ]*/g, function(v) { return wrap(v, n) }) + '?"' + k + '":"",' + + }) + '].join(" ")' + + // if js expression, evaluate as javascript + : wrap(s, n) + + } + + + // execute js w/o breaking on errors or undefined vars + + function wrap(s, nonull) { + return '(function(v){try{v=' + + // prefix vars (name => data.name) + + (s.replace(re_vars, function(s, _, v) { return v ? '(d.'+v+'===undefined?window.'+v+':d.'+v+')' : s }) + + // break the expression if its empty (resulting in undefined value) + || 'x') + + + '}finally{return ' + + // default to empty string for falsy values except zero + + (nonull ? '!v&&v!==0?"":v' : 'v') + + + '}}).call(d)' + } + + + // change regexp to use custom brackets + + function re(r) { + return RegExp(r.source + .split('{').join('\\'+brackets[0]) + .split('}').join('\\'+brackets[1]), + r.global ? 'g' : '') + } + +})() +// { key, i in items} -> { key, i, items } +function loopKeys(expr) { + var ret = { val: expr }, + els = expr.split(/\s+in\s+/) + + if (els[1]) { + ret.val = '{ ' + els[1] + els = els[0].slice(1).trim().split(/,\s*/) + ret.key = els[0] + ret.pos = els[1] + } + return ret +} + +function _each(dom, parent, expr) { + + remAttr(dom, 'each') + + var template = dom.outerHTML, + prev = dom.previousSibling, + root = dom.parentNode, + rendered = [], + tags = [], + checksum + + expr = loopKeys(expr) + + // clean template code after update (and let walk finish it's parse) + parent.one('update', function() { + root.removeChild(dom) + + }).one('mount', function() { + if (!hasParent(root)) root = parent.root + + }).on('update', function() { + + var items = tmpl(expr.val, parent) + if (!items) return + + // object loop. any changes cause full redraw + if (!Array.isArray(items)) { + var testsum = JSON.stringify(items) + if (testsum == checksum) return + checksum = testsum + + // clear old items + tags.map(function(tag) { + tag.unmount() + }) + + tags = rendered = [] + + items = Object.keys(items).map(function(key, i) { + var obj = {} + obj[expr.key] = key + obj[expr.pos] = items[key] + return obj + }) + + } + + // unmount redundant + arrDiff(rendered, items).map(function(item) { + var pos = rendered.indexOf(item), + tag = tags[pos] + + if (tag) { + tag.unmount() + rendered.splice(pos, 1) + tags.splice(pos, 1) + } + }) + + // mount new + var nodes = root.childNodes, + prev_index = Array.prototype.indexOf.call(nodes, prev) + + arrDiff(items, rendered).map(function(item, i) { + + var pos = items.indexOf(item) + + if (!checksum && expr.key) { + var obj = {} + obj[expr.key] = item + obj[expr.pos] = pos + item = obj + } + + var tag = new Tag({ tmpl: template }, { + before: nodes[prev_index + 1 + pos], + parent: parent, + root: root, + loop: true, + item: item + }) + + tags.splice(pos, 0, tag) + + }) + + rendered = items.slice() + + }) + +} +function parseNamedElements(root, tag, expressions) { + walk(root, function(dom) { + if (dom.nodeType != 1) return + + each(dom.attributes, function(attr) { + if (/^(name|id)$/.test(attr.name)) tag[attr.value] = dom + }) + }) +} + +function parseLayout(root, tag, expressions) { + + function addExpr(dom, value, data) { + if (tmpl(value) || data) { + var expr = { dom: dom, expr: value } + expressions.push(extend(expr, data || {})) + } + } + + walk(root, function(dom) { + + var type = dom.nodeType + + // text node + if (type == 3 && dom.parentNode.tagName != 'STYLE') addExpr(dom, dom.nodeValue) + if (type != 1) return + + /* element */ + + // loop + var attr = dom.getAttribute('each') + if (attr) { _each(dom, tag, attr); return false } + + // child tag + var impl = tag_impl[dom.tagName.toLowerCase()] + if (impl) { + impl = new Tag(impl, { root: dom, parent: tag }) + return false + } + + // attributes + each(dom.attributes, function(attr) { + var name = attr.name, + value = attr.value + + // expressions + var bool = name.split('__')[1] + addExpr(dom, value, { attr: bool || name, bool: bool }) + + if (bool) { + remAttr(dom, name) + return false + } + + }) + + }) + +} +function Tag(impl, conf) { + + var self = riot.observable(this), + expressions = [], + attributes = {}, + parent = conf.parent, + is_loop = conf.loop, + root = conf.root, + opts = conf.opts, + item = conf.item + + // cannot initialize twice on the same root element + if (!is_loop && root.riot) return + root.riot = 1 + + opts = opts || {} + + extend(this, { parent: parent, root: root, opts: opts, children: [] }) + extend(this, item) + + + // attributes + each(root.attributes, function(attr) { + var name = attr.name, + val = attr.value + + attributes[name] = val + + // remove dynamic attributes from node + if (val.indexOf('{') >= 0) { + remAttr(root, name) + return false + } + }) + + // options + function updateOpts() { + Object.keys(attributes).map(function(name) { + opts[name] = tmpl(attributes[name], parent || self) + }) + } + + updateOpts() + + // child + parent && parent.children.push(this) + + var dom = mkdom(impl.tmpl), + loop_dom + + // named elements + parseNamedElements(dom, this) + + this.update = function(data, init) { + extend(self, data) + extend(self, item) + self.trigger('update') + updateOpts() + update(expressions, self, item) + self.trigger('updated') + } + + this.unmount = function() { + + if (is_loop) { + root.removeChild(loop_dom) + + } else { + var p = root.parentNode + p && p.removeChild(root) + } + + // splice from parent.children[] + if (parent) { + var els = parent.children + els.splice(els.indexOf(self), 1) + } + + self.trigger('unmount') + + // cleanup + parent && parent.off('update', self.update) + mounted = false + } + + function mount() { + while (dom.firstChild) { + if (is_loop) { + loop_dom = dom.firstChild + root.insertBefore(dom.firstChild, conf.before || null) // null needed for IE8 + + } else { + root.appendChild(dom.firstChild) + } + } + + if (!hasParent(root)) self.root = root = parent.root + + self.trigger('mount') + + // one way data flow: propagate updates and unmounts downwards from parent to children + parent && parent.on('update', self.update).one('unmount', self.unmount) + + } + + // initialize + if (impl.fn) impl.fn.call(this, opts) + + // layout + parseLayout(dom, this, expressions) + + this.update() + mount() + +} + + +function setEventHandler(name, handler, dom, tag, item) { + + dom[name] = function(e) { + + // cross browser event fix + e = e || window.event + e.which = e.which || e.charCode || e.keyCode + e.target = e.target || e.srcElement + e.currentTarget = dom + e.item = item + + // prevent default behaviour (by default) + if (handler.call(tag, e) !== true) { + e.preventDefault && e.preventDefault() + e.returnValue = false + } + + tag.update() + } + +} + +function insertTo(root, node, before) { + if (root) { + root.insertBefore(before, node) + root.removeChild(node) + } +} + +// item = currently looped item +function update(expressions, tag, item) { + + each(expressions, function(expr) { + var dom = expr.dom, + attr_name = expr.attr, + value = tmpl(expr.expr, tag) + + if (value == null) value = '' + + // no change + if (expr.value === value) return + expr.value = value + + // text node + if (!attr_name) return dom.nodeValue = value + + // remove attribute + if (!value && expr.bool || /obj|func/.test(typeof value)) remAttr(dom, attr_name) + + // event handler + if (typeof value == 'function') { + setEventHandler(attr_name, value, dom, tag, item) + + // if- conditional + } else if (attr_name == 'if') { + + remAttr(dom, attr_name) + + var stub = expr.stub + + // add to DOM + if (value) { + stub && insertTo(stub.parentNode, stub, dom) + + // remove from DOM + } else { + stub = expr.stub = stub || document.createTextNode('') + insertTo(dom.parentNode, dom, stub) + } + + // show / hide + } else if (/^(show|hide)$/.test(attr_name)) { + remAttr(dom, attr_name) + if (attr_name == 'hide') value = !value + dom.style.display = value ? '' : 'none' + + // normal attribute + } else { + if (expr.bool) { + dom[attr_name] = value + if (!value) return + value = attr_name + } + + dom.setAttribute(attr_name, value) + } + + }) + +} +function each(nodes, fn) { + for (var i = 0; i < (nodes || []).length; i++) { + if (fn(nodes[i], i) === false) i-- + } +} + +function remAttr(dom, name) { + dom.removeAttribute(name) +} + +function extend(obj, from) { + from && Object.keys(from).map(function(key) { + obj[key] = from[key] + }) + return obj +} + +function mkdom(template) { + var tag_name = template.trim().slice(1, 3).toLowerCase(), + root_tag = /td|th/.test(tag_name) ? 'tr' : tag_name == 'tr' ? 'tbody' : 'div' + el = document.createElement(root_tag) + + el.stub = true + el.innerHTML = template + return el +} + +function walk(dom, fn) { + dom = fn(dom) === false ? dom.nextSibling : dom.firstChild + + while (dom) { + walk(dom, fn) + dom = dom.nextSibling + } +} + +function arrDiff(arr1, arr2) { + return arr1.filter(function(el) { + return arr2.indexOf(el) < 0 + }) +} + +// HTMLDocument == IE8 thing +function hasParent(el) { + var p = el.parentNode, + doc = window.HTMLDocument + + return p && !(doc && p instanceof doc) +} + +/* + Virtual dom is an array of custom tags on the document. + Each tag stores an array of child tags. + Updates and unmounts propagate downwards from parent to children. +*/ + +var virtual_dom = [], + tag_impl = {} + +riot.tag = function(name, html, fn) { + tag_impl[name] = { name: name, tmpl: html, fn: fn } +} + +var mountTo = riot.mountTo = function(root, tagName, opts) { + var impl = tag_impl[tagName], tag + + if (impl) tag = new Tag(impl, { root: root, opts: opts }) + + if (tag) { + virtual_dom.push(tag) + return tag.on('unmount', function() { + virtual_dom.splice(virtual_dom.indexOf(tag), 1) + }) + } +} + +riot.mount = function(selector, opts) { + if (selector == '*') selector = Object.keys(tag_impl).join(', ') + + var tags = [] + + each(document.querySelectorAll(selector), function(root) { + + var tagName = root.tagName.toLowerCase(), + tag = mountTo(root, tagName, opts) + + if (tag) tags.push(tag) + }) + + return tags +} + +// update everything +riot.update = function() { + virtual_dom.map(function(tag) { + tag.update() + }) + return virtual_dom +} + + +// support CommonJS +if (typeof exports === 'object') + module.exports = riot + +// support AMD +else if (typeof define === 'function' && define.amd) + define(function() { return riot }) + +// support browser +else + this.riot = riot + +})(); \ No newline at end of file diff --git a/plc/test/12 b/plc/test/12 new file mode 100644 index 0000000..126a430 --- /dev/null +++ b/plc/test/12 @@ -0,0 +1,11 @@ + var r = riot.route = function(arg) { + // string + if (arg[0]) { + loc.hash = arg + emit(arg) + + // function + } else { + fns.on('H', arg) + } + } \ No newline at end of file diff --git a/plc/test/13 b/plc/test/13 new file mode 100644 index 0000000..ea5c97f --- /dev/null +++ b/plc/test/13 @@ -0,0 +1,112 @@ +module ActiveJob + module Core + extend ActiveSupport::Concern + + included do + # Job arguments + attr_accessor :arguments + attr_writer :serialized_arguments + + # Timestamp when the job should be performed + attr_accessor :scheduled_at + + # Job Identifier + attr_accessor :job_id + + # Queue in which the job will reside. + attr_writer :queue_name + end + + # These methods will be included into any Active Job object, adding + # helpers for de/serialization and creation of job instances. + module ClassMethods + # Creates a new job instance from a hash created with +serialize+ + def deserialize(job_data) + job = job_data['job_class'].constantize.new + job.deserialize(job_data) + job + end + + # Creates a job preconfigured with the given options. You can call + # perform_later with the job arguments to enqueue the job with the + # preconfigured options + # + # ==== Options + # * :wait - Enqueues the job with the specified delay + # * :wait_until - Enqueues the job at the time specified + # * :queue - Enqueues the job on the specified queue + # + # ==== Examples + # + # VideoJob.set(queue: :some_queue).perform_later(Video.last) + # VideoJob.set(wait: 5.minutes).perform_later(Video.last) + # VideoJob.set(wait_until: Time.now.tomorrow).perform_later(Video.last) + # VideoJob.set(queue: :some_queue, wait: 5.minutes).perform_later(Video.last) + # VideoJob.set(queue: :some_queue, wait_until: Time.now.tomorrow).perform_later(Video.last) + def set(options={}) + ConfiguredJob.new(self, options) + end + end + + # Creates a new job instance. Takes the arguments that will be + # passed to the perform method. + def initialize(*arguments) + @arguments = arguments + @job_id = SecureRandom.uuid + @queue_name = self.class.queue_name + end + + # Returns a hash with the job data that can safely be passed to the + # queueing adapter. + def serialize + { + 'job_class' => self.class.name, + 'job_id' => job_id, + 'queue_name' => queue_name, + 'arguments' => serialize_arguments(arguments) + } + end + + # Attaches the stored job data to the current instance. Receives a hash + # returned from +serialize+ + # + # ==== Examples + # + # class DeliverWebhookJob < ActiveJob::Base + # def serialize + # super.merge('attempt_number' => (@attempt_number || 0) + 1) + # end + # + # def deserialize(job_data) + # super + # @attempt_number = job_data['attempt_number'] + # end + # + # rescue_from(TimeoutError) do |exception| + # raise exception if @attempt_number > 5 + # retry_job(wait: 10) + # end + # end + def deserialize(job_data) + self.job_id = job_data['job_id'] + self.queue_name = job_data['queue_name'] + self.serialized_arguments = job_data['arguments'] + end + + private + def deserialize_arguments_if_needed + if defined?(@serialized_arguments) && @serialized_arguments.present? + @arguments = deserialize_arguments(@serialized_arguments) + @serialized_arguments = nil + end + end + + def serialize_arguments(serialized_args) + Arguments.serialize(serialized_args) + end + + def deserialize_arguments(serialized_args) + Arguments.deserialize(serialized_args) + end + end +end \ No newline at end of file diff --git a/plc/test/14 b/plc/test/14 new file mode 100644 index 0000000..40fa40d --- /dev/null +++ b/plc/test/14 @@ -0,0 +1,16 @@ +require 'formula' + +class A52dec < Formula + homepage 'http://liba52.sourceforge.net/' + url 'http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz' + sha1 '79b33bd8d89dad7436f85b9154ad35667aa37321' + + def install + system "./configure", "--disable-debug", + "--disable-dependency-tracking", + "--prefix=#{prefix}", + "--enable-shared", + "--mandir=#{man}" + system "make install" + end +end \ No newline at end of file diff --git a/plc/test/15 b/plc/test/15 new file mode 100644 index 0000000..f9936b4 --- /dev/null +++ b/plc/test/15 @@ -0,0 +1,30 @@ +module Fluent + class Input + include Configurable + include PluginId + include PluginLoggerMixin + + attr_accessor :router + + def initialize + super + end + + def configure(conf) + super + + if label_name = conf['@label'] + label = Engine.root_agent.find_label(label_name) + @router = label.event_router + elsif @router.nil? + @router = Engine.root_agent.event_router + end + end + + def start + end + + def shutdown + end + end +end \ No newline at end of file diff --git a/plc/test/16 b/plc/test/16 new file mode 100644 index 0000000..9e0b446 --- /dev/null +++ b/plc/test/16 @@ -0,0 +1,364 @@ +{-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-} +{- +Copyright (C) 2006-2014 John MacFarlane + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-} + +{- | + Module : Text.Pandoc + Copyright : Copyright (C) 2006-2014 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +This helper module exports the main writers, readers, and data +structure definitions from the Pandoc libraries. + +A typical application will chain together a reader and a writer +to convert strings from one format to another. For example, the +following simple program will act as a filter converting markdown +fragments to reStructuredText, using reference-style links instead of +inline links: + +> module Main where +> import Text.Pandoc +> +> markdownToRST :: String -> String +> markdownToRST = +> (writeRST def {writerReferenceLinks = True}) . readMarkdown def +> +> main = getContents >>= putStrLn . markdownToRST + +Note: all of the readers assume that the input text has @'\n'@ +line endings. So if you get your input text from a web form, +you should remove @'\r'@ characters using @filter (/='\r')@. + +-} + +module Text.Pandoc + ( + -- * Definitions + module Text.Pandoc.Definition + -- * Generics + , module Text.Pandoc.Generic + -- * Options + , module Text.Pandoc.Options + -- * Lists of readers and writers + , readers + , writers + -- * Readers: converting /to/ Pandoc format + , Reader (..) + , mkStringReader + , readDocx + , readMarkdown + , readMediaWiki + , readRST + , readOrg + , readLaTeX + , readHtml + , readTextile + , readDocBook + , readOPML + , readHaddock + , readNative + , readJSON + , readTWiki + , readTxt2Tags + , readTxt2TagsNoMacros + , readEPUB + -- * Writers: converting /from/ Pandoc format + , Writer (..) + , writeNative + , writeJSON + , writeMarkdown + , writePlain + , writeRST + , writeLaTeX + , writeConTeXt + , writeTexinfo + , writeHtml + , writeHtmlString + , writeICML + , writeDocbook + , writeOPML + , writeOpenDocument + , writeMan + , writeMediaWiki + , writeDokuWiki + , writeTextile + , writeRTF + , writeODT + , writeDocx + , writeEPUB + , writeFB2 + , writeOrg + , writeAsciiDoc + , writeHaddock + , writeCustom + -- * Rendering templates and default templates + , module Text.Pandoc.Templates + -- * Version + , pandocVersion + -- * Miscellaneous + , getReader + , getWriter + , ToJsonFilter(..) + ) where + +import Text.Pandoc.Definition +import Text.Pandoc.Generic +import Text.Pandoc.JSON +import Text.Pandoc.Readers.Markdown +import Text.Pandoc.Readers.MediaWiki +import Text.Pandoc.Readers.RST +import Text.Pandoc.Readers.Org +import Text.Pandoc.Readers.DocBook +import Text.Pandoc.Readers.OPML +import Text.Pandoc.Readers.LaTeX +import Text.Pandoc.Readers.HTML +import Text.Pandoc.Readers.Textile +import Text.Pandoc.Readers.Native +import Text.Pandoc.Readers.Haddock +import Text.Pandoc.Readers.TWiki +import Text.Pandoc.Readers.Docx +import Text.Pandoc.Readers.Txt2Tags +import Text.Pandoc.Readers.EPUB +import Text.Pandoc.Writers.Native +import Text.Pandoc.Writers.Markdown +import Text.Pandoc.Writers.RST +import Text.Pandoc.Writers.LaTeX +import Text.Pandoc.Writers.ConTeXt +import Text.Pandoc.Writers.Texinfo +import Text.Pandoc.Writers.HTML +import Text.Pandoc.Writers.ODT +import Text.Pandoc.Writers.Docx +import Text.Pandoc.Writers.EPUB +import Text.Pandoc.Writers.FB2 +import Text.Pandoc.Writers.ICML +import Text.Pandoc.Writers.Docbook +import Text.Pandoc.Writers.OPML +import Text.Pandoc.Writers.OpenDocument +import Text.Pandoc.Writers.Man +import Text.Pandoc.Writers.RTF +import Text.Pandoc.Writers.MediaWiki +import Text.Pandoc.Writers.DokuWiki +import Text.Pandoc.Writers.Textile +import Text.Pandoc.Writers.Org +import Text.Pandoc.Writers.AsciiDoc +import Text.Pandoc.Writers.Haddock +import Text.Pandoc.Writers.Custom +import Text.Pandoc.Templates +import Text.Pandoc.Options +import Text.Pandoc.Shared (safeRead, warn) +import Text.Pandoc.MediaBag (MediaBag) +import Data.Aeson +import qualified Data.ByteString.Lazy as BL +import Data.List (intercalate) +import Data.Version (showVersion) +import Data.Set (Set) +import qualified Data.Set as Set +import Text.Parsec +import Text.Parsec.Error +import qualified Text.Pandoc.UTF8 as UTF8 +import Paths_pandoc (version) + +-- | Version number of pandoc library. +pandocVersion :: String +pandocVersion = showVersion version + +parseFormatSpec :: String + -> Either ParseError (String, Set Extension -> Set Extension) +parseFormatSpec = parse formatSpec "" + where formatSpec = do + name <- formatName + extMods <- many extMod + return (name, foldl (.) id extMods) + formatName = many1 $ noneOf "-+" + extMod = do + polarity <- oneOf "-+" + name <- many $ noneOf "-+" + ext <- case safeRead ("Ext_" ++ name) of + Just n -> return n + Nothing + | name == "lhs" -> return Ext_literate_haskell + | otherwise -> fail $ "Unknown extension: " ++ name + return $ case polarity of + '-' -> Set.delete ext + _ -> Set.insert ext + +data Reader = StringReader (ReaderOptions -> String -> IO Pandoc) + | ByteStringReader (ReaderOptions -> BL.ByteString -> IO (Pandoc, MediaBag)) + +mkStringReader :: (ReaderOptions -> String -> Pandoc) -> Reader +mkStringReader r = StringReader (\o s -> return $ r o s) + +mkStringReaderWithWarnings :: (ReaderOptions -> String -> (Pandoc, [String])) -> Reader +mkStringReaderWithWarnings r = StringReader $ \o s -> do + let (doc, warnings) = r o s + mapM_ warn warnings + return doc + +mkBSReader :: (ReaderOptions -> BL.ByteString -> (Pandoc, MediaBag)) -> Reader +mkBSReader r = ByteStringReader (\o s -> return $ r o s) + +-- | Association list of formats and readers. +readers :: [(String, Reader)] +readers = [ ("native" , StringReader $ \_ s -> return $ readNative s) + ,("json" , mkStringReader readJSON ) + ,("markdown" , mkStringReaderWithWarnings readMarkdownWithWarnings) + ,("markdown_strict" , mkStringReaderWithWarnings readMarkdownWithWarnings) + ,("markdown_phpextra" , mkStringReaderWithWarnings readMarkdownWithWarnings) + ,("markdown_github" , mkStringReaderWithWarnings readMarkdownWithWarnings) + ,("markdown_mmd", mkStringReaderWithWarnings readMarkdownWithWarnings) + ,("rst" , mkStringReaderWithWarnings readRSTWithWarnings ) + ,("mediawiki" , mkStringReader readMediaWiki) + ,("docbook" , mkStringReader readDocBook) + ,("opml" , mkStringReader readOPML) + ,("org" , mkStringReader readOrg) + ,("textile" , mkStringReader readTextile) -- TODO : textile+lhs + ,("html" , mkStringReader readHtml) + ,("latex" , mkStringReader readLaTeX) + ,("haddock" , mkStringReader readHaddock) + ,("twiki" , mkStringReader readTWiki) + ,("docx" , mkBSReader readDocx) + ,("t2t" , mkStringReader readTxt2TagsNoMacros) + ,("epub" , mkBSReader readEPUB) + ] + +data Writer = PureStringWriter (WriterOptions -> Pandoc -> String) + | IOStringWriter (WriterOptions -> Pandoc -> IO String) + | IOByteStringWriter (WriterOptions -> Pandoc -> IO BL.ByteString) + +-- | Association list of formats and writers. +writers :: [ ( String, Writer ) ] +writers = [ + ("native" , PureStringWriter writeNative) + ,("json" , PureStringWriter writeJSON) + ,("docx" , IOByteStringWriter writeDocx) + ,("odt" , IOByteStringWriter writeODT) + ,("epub" , IOByteStringWriter $ \o -> + writeEPUB o{ writerEpubVersion = Just EPUB2 }) + ,("epub3" , IOByteStringWriter $ \o -> + writeEPUB o{ writerEpubVersion = Just EPUB3 }) + ,("fb2" , IOStringWriter writeFB2) + ,("html" , PureStringWriter writeHtmlString) + ,("html5" , PureStringWriter $ \o -> + writeHtmlString o{ writerHtml5 = True }) + ,("icml" , PureStringWriter writeICML) + ,("s5" , PureStringWriter $ \o -> + writeHtmlString o{ writerSlideVariant = S5Slides + , writerTableOfContents = False }) + ,("slidy" , PureStringWriter $ \o -> + writeHtmlString o{ writerSlideVariant = SlidySlides }) + ,("slideous" , PureStringWriter $ \o -> + writeHtmlString o{ writerSlideVariant = SlideousSlides }) + ,("dzslides" , PureStringWriter $ \o -> + writeHtmlString o{ writerSlideVariant = DZSlides + , writerHtml5 = True }) + ,("revealjs" , PureStringWriter $ \o -> + writeHtmlString o{ writerSlideVariant = RevealJsSlides + , writerHtml5 = True }) + ,("docbook" , PureStringWriter writeDocbook) + ,("opml" , PureStringWriter writeOPML) + ,("opendocument" , PureStringWriter writeOpenDocument) + ,("latex" , PureStringWriter writeLaTeX) + ,("beamer" , PureStringWriter $ \o -> + writeLaTeX o{ writerBeamer = True }) + ,("context" , PureStringWriter writeConTeXt) + ,("texinfo" , PureStringWriter writeTexinfo) + ,("man" , PureStringWriter writeMan) + ,("markdown" , PureStringWriter writeMarkdown) + ,("markdown_strict" , PureStringWriter writeMarkdown) + ,("markdown_phpextra" , PureStringWriter writeMarkdown) + ,("markdown_github" , PureStringWriter writeMarkdown) + ,("markdown_mmd" , PureStringWriter writeMarkdown) + ,("plain" , PureStringWriter writePlain) + ,("rst" , PureStringWriter writeRST) + ,("mediawiki" , PureStringWriter writeMediaWiki) + ,("dokuwiki" , PureStringWriter writeDokuWiki) + ,("textile" , PureStringWriter writeTextile) + ,("rtf" , IOStringWriter writeRTFWithEmbeddedImages) + ,("org" , PureStringWriter writeOrg) + ,("asciidoc" , PureStringWriter writeAsciiDoc) + ,("haddock" , PureStringWriter writeHaddock) + ] + +getDefaultExtensions :: String -> Set Extension +getDefaultExtensions "markdown_strict" = strictExtensions +getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions +getDefaultExtensions "markdown_mmd" = multimarkdownExtensions +getDefaultExtensions "markdown_github" = githubMarkdownExtensions +getDefaultExtensions "markdown" = pandocExtensions +getDefaultExtensions "plain" = pandocExtensions +getDefaultExtensions "org" = Set.fromList [Ext_citations] +getDefaultExtensions "textile" = Set.fromList [Ext_auto_identifiers] +getDefaultExtensions "html" = Set.fromList [Ext_auto_identifiers, + Ext_native_divs, + Ext_native_spans] +getDefaultExtensions "html5" = getDefaultExtensions "html" +getDefaultExtensions "epub" = Set.fromList [Ext_auto_identifiers, + Ext_raw_html, + Ext_native_divs, + Ext_native_spans, + Ext_epub_html_exts] +getDefaultExtensions _ = Set.fromList [Ext_auto_identifiers] + +-- | Retrieve reader based on formatSpec (format+extensions). +getReader :: String -> Either String Reader +getReader s = + case parseFormatSpec s of + Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e] + Right (readerName, setExts) -> + case lookup readerName readers of + Nothing -> Left $ "Unknown reader: " ++ readerName + Just (StringReader r) -> Right $ StringReader $ \o -> + r o{ readerExtensions = setExts $ + getDefaultExtensions readerName } + Just (ByteStringReader r) -> Right $ ByteStringReader $ \o -> + r o{ readerExtensions = setExts $ + getDefaultExtensions readerName } + +-- | Retrieve writer based on formatSpec (format+extensions). +getWriter :: String -> Either String Writer +getWriter s + = case parseFormatSpec s of + Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e] + Right (writerName, setExts) -> + case lookup writerName writers of + Nothing -> Left $ "Unknown writer: " ++ writerName + Just (PureStringWriter r) -> Right $ PureStringWriter $ + \o -> r o{ writerExtensions = setExts $ + getDefaultExtensions writerName } + Just (IOStringWriter r) -> Right $ IOStringWriter $ + \o -> r o{ writerExtensions = setExts $ + getDefaultExtensions writerName } + Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $ + \o -> r o{ writerExtensions = setExts $ + getDefaultExtensions writerName } + +{-# DEPRECATED toJsonFilter "Use 'toJSONFilter' from 'Text.Pandoc.JSON' instead" #-} +-- | Deprecated. Use @toJSONFilter@ from @Text.Pandoc.JSON@ instead. +class ToJSONFilter a => ToJsonFilter a + where toJsonFilter :: a -> IO () + toJsonFilter = toJSONFilter + +readJSON :: ReaderOptions -> String -> Pandoc +readJSON _ = either error id . eitherDecode' . UTF8.fromStringLazy + +writeJSON :: WriterOptions -> Pandoc -> String +writeJSON _ = UTF8.toStringLazy . encode \ No newline at end of file diff --git a/plc/test/17 b/plc/test/17 new file mode 100644 index 0000000..6b0eb12 --- /dev/null +++ b/plc/test/17 @@ -0,0 +1,5 @@ +reverseDependencies :: ModuleGraph -> M.Map ModuleName [ModuleName] +reverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ] + where + combine :: (Ord a) => [(a, b)] -> M.Map a [b] + combine = M.fromList . map ((fst . head) &&& map snd) . groupBy ((==) `on` fst) . sortBy (compare `on` fst) \ No newline at end of file diff --git a/plc/test/18 b/plc/test/18 new file mode 100644 index 0000000..14cec7c --- /dev/null +++ b/plc/test/18 @@ -0,0 +1,69 @@ +{- git-annex extra config files + - + - Copyright 2012 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Config.Files where + +import Common +import Utility.Tmp +import Utility.FreeDesktop + +{- ~/.config/git-annex/file -} +userConfigFile :: FilePath -> IO FilePath +userConfigFile file = do + dir <- userConfigDir + return $ dir "git-annex" file + +autoStartFile :: IO FilePath +autoStartFile = userConfigFile "autostart" + +{- Returns anything listed in the autostart file (which may not exist). -} +readAutoStartFile :: IO [FilePath] +readAutoStartFile = do + f <- autoStartFile + nub . map dropTrailingPathSeparator . lines + <$> catchDefaultIO "" (readFile f) + +modifyAutoStartFile :: ([FilePath] -> [FilePath]) -> IO () +modifyAutoStartFile func = do + dirs <- readAutoStartFile + let dirs' = nubBy equalFilePath $ func dirs + when (dirs' /= dirs) $ do + f <- autoStartFile + createDirectoryIfMissing True (parentDir f) + viaTmp writeFile f $ unlines dirs' + +{- Adds a directory to the autostart file. If the directory is already + - present, it's moved to the top, so it will be used as the default + - when opening the webapp. -} +addAutoStartFile :: FilePath -> IO () +addAutoStartFile path = modifyAutoStartFile $ (:) path + +{- Removes a directory from the autostart file. -} +removeAutoStartFile :: FilePath -> IO () +removeAutoStartFile path = modifyAutoStartFile $ + filter (not . equalFilePath path) + +{- The path to git-annex is written here; which is useful when cabal + - has installed it to some awful non-PATH location. -} +programFile :: IO FilePath +programFile = userConfigFile "program" + +{- Returns a command to run for git-annex. -} +readProgramFile :: IO FilePath +readProgramFile = do + programfile <- programFile + p <- catchDefaultIO cmd $ + fromMaybe cmd . headMaybe . lines <$> readFile programfile + ifM (inPath p) + ( return p + , ifM (inPath cmd) + ( return cmd + , error $ "cannot find git-annex program in PATH or in the location listed in " ++ programfile + ) + ) + where + cmd = "git-annex" \ No newline at end of file diff --git a/plc/test/19 b/plc/test/19 new file mode 100644 index 0000000..5ec4ae6 --- /dev/null +++ b/plc/test/19 @@ -0,0 +1,18 @@ +(define subst-f + (lambda (new old l) + (cond + ((null? l) '()) + ((eq? (car l) old) + (cons new (cdr l))) + (else + (cons (car l) (subst new old (cdr l))))))) + +; The seqS function is what subst does that neither insertL nor insertR do +; +(define seqS + (lambda (new old l) + (cons new l))) + +; subst is now just (insret-g seqS) +; +(define subst (insert-g seqS)) \ No newline at end of file diff --git a/plc/test/2 b/plc/test/2 new file mode 100644 index 0000000..113faf7 --- /dev/null +++ b/plc/test/2 @@ -0,0 +1,9 @@ +(ns my-cli.core) + +(defn -main [& args] + (println "My CLI received arguments:" args)) + +(defn add-main [& args] + (->> (map #(Integer/parseInt %) args) + (reduce + 0) + (println "The sum is:"))) \ No newline at end of file diff --git a/plc/test/20 b/plc/test/20 new file mode 100644 index 0000000..1b9aceb --- /dev/null +++ b/plc/test/20 @@ -0,0 +1,2 @@ +(define add1 + (lambda (n) (+ n 1))) \ No newline at end of file diff --git a/plc/test/21 b/plc/test/21 new file mode 100644 index 0000000..53d22a0 --- /dev/null +++ b/plc/test/21 @@ -0,0 +1,220 @@ +(define-lib-primitive (length lst) + (if (null? lst) + 0 + (fxadd1 (length (cdr lst))))) + +(define-lib-primitive (fill args setop) + (letrec ([rec (lambda (index args) + (unless (null? args) + (setop index (car args)) + (rec (fxadd1 index) (cdr args))))]) + (rec 0 args))) + +(define-lib-primitive (vector . args) + (let ([v (make-vector (length args))]) + (fill args (lambda (index arg) (vector-set! v index arg))) + v)) + +(define-lib-primitive (string . args) + (let ([s (make-string (length args))]) + (fill args (lambda (index arg) (string-set! s index arg))) + s)) + +(define-lib-primitive (list . args) + args) + +(define-lib-primitive (make_cell value) + (cons value '())) + +(define-lib-primitive (cell_get cell) + (car cell)) + +(define-lib-primitive (cell_set cell value) + (set-car! cell value)) + +(define-lib-primitive __symbols__ + (make_cell '())) + +(define-lib-primitive (string=? s1 s2) + (letrec ([rec (lambda (index) + (or (fx= index (string-length s1)) + (and (char= (string-ref s1 index) (string-ref s2 index)) + (rec (fxadd1 index)))))]) + (and (string? s1) (string? s2) (fx= (string-length s1) (string-length s2)) (rec 0)))) + +(define-lib-primitive (__find_symbol__ str) + (letrec ([rec (lambda (symbols) + (cond + [(null? symbols) #f] + [(string=? str (string-symbol (car symbols))) (car symbols)] + [else (rec (cdr symbols))]))]) + (rec (cell_get __symbols__)))) + +(define-lib-primitive (string->symbol str) + (or (__find_symbol__ str) + (let ([symbol (make-symbol str)]) + (cell_set __symbols__ (cons symbol (cell_get __symbols__))) + symbol))) + +(define-lib-primitive (error . args) + (foreign-call "ik_error" args)) + +(define-lib-primitive (log msg) + (foreign-call "ik_log" msg)) + +(define-lib-primitive (string-set! s i c) + (cond + [(not (string? s)) (error)] + [(not (fixnum? i)) (error)] + [(not (char? c)) (error)] + [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)] + [else ($string-set! s i c)])) + +(define-lib-primitive (string-ref s i) + (cond + [(not (string? s)) (error)] + [(not (fixnum? i)) (error)] + [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)] + [else ($string-ref s i)])) + +(define-lib-primitive (vector-set! v i e) + (cond + [(not (vector? v)) (error)] + [(not (fixnum? i)) (error)] + [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)] + [else ($vector-set! v i e)])) + +(define-lib-primitive (vector-ref v i) + (cond + [(not (vector? v)) (error)] + [(not (fixnum? i)) (error)] + [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)] + [else ($vector-ref v i)])) + +(define-lib-primitive (liftneg f a b) + (cond + [(and (fx< a 0) (fx>= b 0)) + (fx- 0 (f (fx- 0 a) b))] + [(and (fx>= a 0) (fx< b 0)) + (fx- 0 (f a (fx- 0 b)))] + [(and (fx< a 0) (fx< b 0)) + (f (fx- 0 a) (fx- 0 b))] + [else + (f a b)])) + +(define-lib-primitive (liftneg1 f a b) + (cond + [(and (fx< a 0) (fx>= b 0)) + (fx- 0 (f (fx- 0 a) b))] + [(and (fx>= a 0) (fx< b 0)) + (f a (fx- 0 b))] + [(and (fx< a 0) (fx< b 0)) + (fx- 0 (f (fx- 0 a) (fx- 0 b)))] + [else + (f a b)])) + +(define-lib-primitive (fxquotient a b) + (liftneg (lambda (a b) ($fxquotient a b)) a b)) + +(define-lib-primitive (fxremainder a b) + (liftneg1 (lambda (a b) ($fxremainder a b)) a b)) + +(define-lib-primitive (exit . args) + (let ([status (if (null? args) 0 (car args))]) + (foreign-call "exit" status))) + +(define-lib-primitive (s_write fd str len) + (foreign-call "s_write" fd str len)) + +(define-lib-primitive stdout + (make-output-port "" 1)) + +(define-lib-primitive (current-output-port) + stdout) + +(define-lib-primitive BUFFER_SIZE 4096) + +(define-lib-primitive (open-output-file fname . args) + (let ([fd (foreign-call "s_open_write" fname)]) + (make-output-port fname fd))) + +(define-lib-primitive (make-output-port fname fd) + (vector 'output-port fname fd (make-string BUFFER_SIZE) 0 BUFFER_SIZE)) + +(define-lib-primitive (output-port-fname port) + (vector-ref port 1)) + +(define-lib-primitive (output-port-fd port) + (vector-ref port 2)) + +(define-lib-primitive (output-port-buffer port) + (vector-ref port 3)) + +(define-lib-primitive (output-port-buffer-index port) + (vector-ref port 4)) + +(define-lib-primitive (output-port-buffer-size port) + (vector-ref port 5)) + +(define-lib-primitive (set-output-port-buffer-index! port index) + (vector-set! port 4 index)) + +(define-lib-primitive (inc-output-port-buffer-index! port) + (set-output-port-buffer-index! port (fxadd1 (output-port-buffer-index port)))) + +(define-lib-primitive (write-char c (port (current-output-port))) + (string-set! (output-port-buffer port) (output-port-buffer-index port) c) + (inc-output-port-buffer-index! port) + (when (fx= (output-port-buffer-index port) (output-port-buffer-size port)) + (output-port-write-buffer port))) + +(define-lib-primitive (output-port? x) + (and (vector? x) (fx= (vector-length x) 6) (eq? 'output-port (vector-ref x 0)))) + +(define-lib-primitive (output-port-write-buffer port) + (s_write (output-port-fd port) + (output-port-buffer port) + (output-port-buffer-index port)) + (set-output-port-buffer-index! port 0)) + +(define-lib-primitive (flush-output-port (port (current-output-port))) + (output-port-write-buffer port) + (foreign-call "s_fflush" (output-port-fd port))) + +(define-lib-primitive (close-output-port port) + (flush-output-port port) + (unless (string=? "" (output-port-fname port)) + (foreign-call "s_close" (output-port-fd port)))) + +(define-lib-primitive (write x (port (current-output-port))) + (flush-output-port port) + ;; This is cheating... should write it in Scheme. + (foreign-call "scheme_write" (output-port-fd port) x 0) + (flush-output-port port)) + +(define-lib-primitive (display x (port (current-output-port))) + (flush-output-port port) + (foreign-call "scheme_write" (output-port-fd port) x 2) + (flush-output-port port)) + +(define-lib-primitive (open-input-file fname . args) + (let ([fd (foreign-call "s_open_read" fname)]) + (make-input-port fname fd))) + +(define-lib-primitive (make-input-port fname fd) + (vector 'input-port fname fd)) + +(define-lib-primitive (input-port-fname port) + (vector-ref port 1)) + +(define-lib-primitive (input-port-fd port) + (vector-ref port 2)) + +(define-lib-primitive (input-port? x) + (and (vector? x) (fx= (vector-length x) 3) (eq? 'input-port (vector-ref x 0)))) + +(define-lib-primitive (read-char port) + (foreign-call "s_read_char" (input-port-fd port))) + +(define-lib-primitive (close-input-port port) + (foreign-call "s_close" (input-port-fd port))) \ No newline at end of file diff --git a/plc/test/22 b/plc/test/22 new file mode 100644 index 0000000..8dedd41 --- /dev/null +++ b/plc/test/22 @@ -0,0 +1,64 @@ +/** + * Interface to represent a persistence store for archives + * + * @author James Kojo + * @author Vasanth Asokan + */ +public interface ArchiveRepository { + /** + * Get the ID of this repository + * @return the id string. + */ + public String getRepositoryId(); + + /** + * Get the default view into this repository. + * @return the default repository view. + */ + public RepositoryView getDefaultView(); + + /** + * Get a specific named view into this repository. + * + * @param view the name of the view. + * @return a {@link RepositoryView} that matches the given name or null if + * one wasn't found. + * @throws UnsupportedOperationException + * if this repository does not support named views. + */ + public RepositoryView getView(String view); + + /** + * Insert a Jar into the repository + * @param jarScriptArchive script archive which describes the jar and + * the ModuleSpec which should be inserted + */ + public void insertArchive(JarScriptArchive jarScriptArchive) + throws IOException; + + /** + * Insert a Jar into the repository + * @param jarScriptArchive script archive which describes the jar and + * the ModuleSpec which should be inserted + * @param initialDeploySpecs a set of initial deployment specs. + * @throws UnsupportedOperationException if this repository does not support + * adding deploy specs to a module. + */ + public void insertArchive(JarScriptArchive jarScriptArchive, Map initialDeploySpecs) + throws IOException; + + /** + * Get all of the {@link ScriptArchive}s for the given set of moduleIds. + * + * @param moduleIds keys to search for + * @return set of ScriptArchives retrieved from the database + */ + public Set getScriptArchives(Set moduleIds) throws IOException; + + /** + * Delete an archive by ID + * @param moduleId module id to delete + * @throws IOException + */ + public void deleteArchive(ModuleId moduleId) throws IOException; +} \ No newline at end of file diff --git a/plc/test/23 b/plc/test/23 new file mode 100644 index 0000000..ec2333d --- /dev/null +++ b/plc/test/23 @@ -0,0 +1,59 @@ +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.core; + +/** + * Common interface for managing aliases. Serves as super-interface for + * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}. + * + * @author Juergen Hoeller + * @since 2.5.2 + */ +public interface AliasRegistry { + + /** + * Given a name, register an alias for it. + * @param name the canonical name + * @param alias the alias to be registered + * @throws IllegalStateException if the alias is already in use + * and may not be overridden + */ + void registerAlias(String name, String alias); + + /** + * Remove the specified alias from this registry. + * @param alias the alias to remove + * @throws IllegalStateException if no such alias was found + */ + void removeAlias(String alias); + + /** + * Determine whether this given name is defines as an alias + * (as opposed to the name of an actually registered component). + * @param beanName the bean name to check + * @return whether the given name is an alias + */ + boolean isAlias(String beanName); + + /** + * Return the aliases for the given name, if defined. + * @param name the name to check for aliases + * @return the aliases, or an empty array if none + */ + String[] getAliases(String name); + +} \ No newline at end of file diff --git a/plc/test/24 b/plc/test/24 new file mode 100644 index 0000000..ffed0c6 --- /dev/null +++ b/plc/test/24 @@ -0,0 +1,77 @@ +package com.github.pathikrit + +import scala.annotation.StaticAnnotation + +class MetaRest extends StaticAnnotation { + def macroTransform(annottees: Any*): Any = macro MetaRest.impl +} + +object MetaRest { + sealed trait MethodAnnotations extends StaticAnnotation + class get extends MethodAnnotations + class put extends MethodAnnotations + class post extends MethodAnnotations + class patch extends MethodAnnotations + object MethodAnnotations { + val values = List("get", "post", "put", "patch") //TODO: use some enum/sealed trait macro to do this automatically + } + + def impl(c: macros.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { + import c.universe._ + + def withCompileError[A](msg: String)(block: => A): A = try { + block + } catch { + case _: MatchError => c.abort(c.enclosingPosition, s"@MetaRest: $msg") + } + + def generateModels(fields: List[ValDef]) = { + val fieldsWithAnnotations = fields.map(_.mods.annotations).zip(fields) + val newFields = fieldsWithAnnotations flatMap { case (annotations, field) => + annotations.map(_ -> field) collect { + case (q"new patch", q"$accessor val $vname: $tpe") => "patch" -> q"$accessor val $vname: Option[$tpe] = None" + case (q"new $annotation", f) if MethodAnnotations.values contains annotation.toString => annotation.toString -> f.duplicate + } + } + newFields.groupBy(_._1) map { case (annotation, values) => + val (className, classFields) = (macros.toTypeName(c)(annotation.capitalize), values.map(_._2)) + q"@com.kifi.macros.json case class $className(..$classFields)" //TODO: Switch back to jsonstrict once this is fixed: https://github.com/kifi/json-annotation/issues/7 + } + } + + def modifiedDeclaration(classDecl: ClassDef, compDeclOpt: Option[ModuleDef] = None) = { + val (className, fields) = withCompileError("must annotate a case class") { + val q"case class $className(..$fields) extends ..$bases { ..$body }" = classDecl + (className, fields) + } + + val compDecl = compDeclOpt map { compDecl => + val q"object $obj extends ..$bases { ..$body }" = compDecl + q""" + object $obj extends ..$bases { + ..$body + ..${generateModels(fields)} + } + """ + } getOrElse { + q""" + object ${className.toTermName} { + ..${generateModels(fields)} + } + """ + } + + c.Expr(q""" + $classDecl + $compDecl + """) + } + + withCompileError("must annotate a class") { + annottees.map(_.tree) match { + case (classDecl: ClassDef) :: Nil => modifiedDeclaration(classDecl) + case (classDecl: ClassDef) :: (compDecl: ModuleDef) :: Nil => modifiedDeclaration(classDecl, Some(compDecl)) + } + } + } +} \ No newline at end of file diff --git a/plc/test/25 b/plc/test/25 new file mode 100644 index 0000000..42e4a35 --- /dev/null +++ b/plc/test/25 @@ -0,0 +1,48 @@ +/* sbt -- Simple Build Tool + * Copyright 2010, 2011 Mark Harrah + */ +package object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtra with sbt.impl.DependencyBuilders + with sbt.PathExtra with sbt.ProjectExtra with sbt.DependencyFilterExtra with sbt.BuildExtra with sbt.TaskMacroExtra + with sbt.ScopeFilter.Make { + type Setting[T] = Def.Setting[T] + type ScopedKey[T] = Def.ScopedKey[T] + type SettingsDefinition = Def.SettingsDefinition + type File = java.io.File + type URI = java.net.URI + type URL = java.net.URL + + object CompileOrder { + val JavaThenScala = xsbti.compile.CompileOrder.JavaThenScala + val ScalaThenJava = xsbti.compile.CompileOrder.ScalaThenJava + val Mixed = xsbti.compile.CompileOrder.Mixed + } + type CompileOrder = xsbti.compile.CompileOrder + + implicit def maybeToOption[S](m: xsbti.Maybe[S]): Option[S] = + if (m.isDefined) Some(m.get) else None + def uri(s: String): URI = new URI(s) + def file(s: String): File = new File(s) + def url(s: String): URL = new URL(s) + + final val ThisScope = Scope.ThisScope + final val GlobalScope = Scope.GlobalScope + + import sbt.{ Configurations => C } + final val Compile = C.Compile + final val Test = C.Test + final val Runtime = C.Runtime + final val IntegrationTest = C.IntegrationTest + final val Default = C.Default + final val Docs = C.Docs + final val Sources = C.Sources + final val Provided = C.Provided + // java.lang.System is more important, so don't alias this one + // final val System = C.System + final val Optional = C.Optional + def config(s: String): Configuration = Configurations.config(s) + + import language.experimental.macros + def settingKey[T](description: String): SettingKey[T] = macro std.KeyMacro.settingKeyImpl[T] + def taskKey[T](description: String): TaskKey[T] = macro std.KeyMacro.taskKeyImpl[T] + def inputKey[T](description: String): InputKey[T] = macro std.KeyMacro.inputKeyImpl[T] +} \ No newline at end of file diff --git a/plc/test/28 b/plc/test/28 new file mode 100644 index 0000000..3cc77a3 --- /dev/null +++ b/plc/test/28 @@ -0,0 +1,209 @@ +class View +{ + /** + * Data available to the view templates + * @var \Slim\Helper\Set + */ + protected $data; + /** + * Path to templates base directory (without trailing slash) + * @var string + */ + protected $templatesDirectory; + /** + * Constructor + */ + public function __construct() + { + $this->data = new \Slim\Helper\Set(); + } + /******************************************************************************** + * Data methods + *******************************************************************************/ + /** + * Does view data have value with key? + * @param string $key + * @return boolean + */ + public function has($key) + { + return $this->data->has($key); + } + /** + * Return view data value with key + * @param string $key + * @return mixed + */ + public function get($key) + { + return $this->data->get($key); + } + /** + * Set view data value with key + * @param string $key + * @param mixed $value + */ + public function set($key, $value) + { + $this->data->set($key, $value); + } + /** + * Set view data value as Closure with key + * @param string $key + * @param mixed $value + */ + public function keep($key, \Closure $value) + { + $this->data->keep($key, $value); + } + /** + * Return view data + * @return array + */ + public function all() + { + return $this->data->all(); + } + /** + * Replace view data + * @param array $data + */ + public function replace(array $data) + { + $this->data->replace($data); + } + /** + * Clear view data + */ + public function clear() + { + $this->data->clear(); + } + /******************************************************************************** + * Legacy data methods + *******************************************************************************/ + /** + * DEPRECATION WARNING! This method will be removed in the next major point release + * + * Get data from view + */ + public function getData($key = null) + { + if (!is_null($key)) { + return isset($this->data[$key]) ? $this->data[$key] : null; + } else { + return $this->data->all(); + } + } + /** + * DEPRECATION WARNING! This method will be removed in the next major point release + * + * Set data for view + */ + public function setData() + { + $args = func_get_args(); + if (count($args) === 1 && is_array($args[0])) { + $this->data->replace($args[0]); + } elseif (count($args) === 2) { + // Ensure original behavior is maintained. DO NOT invoke stored Closures. + if (is_object($args[1]) && method_exists($args[1], '__invoke')) { + $this->data->set($args[0], $this->data->protect($args[1])); + } else { + $this->data->set($args[0], $args[1]); + } + } else { + throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`'); + } + } + /** + * DEPRECATION WARNING! This method will be removed in the next major point release + * + * Append data to view + * @param array $data + */ + public function appendData($data) + { + if (!is_array($data)) { + throw new \InvalidArgumentException('Cannot append view data. Expected array argument.'); + } + $this->data->replace($data); + } + /******************************************************************************** + * Resolve template paths + *******************************************************************************/ + /** + * Set the base directory that contains view templates + * @param string $directory + * @throws \InvalidArgumentException If directory is not a directory + */ + public function setTemplatesDirectory($directory) + { + $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR); + } + /** + * Get templates base directory + * @return string + */ + public function getTemplatesDirectory() + { + return $this->templatesDirectory; + } + /** + * Get fully qualified path to template file using templates base directory + * @param string $file The template file pathname relative to templates base directory + * @return string + */ + public function getTemplatePathname($file) + { + return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR); + } + /******************************************************************************** + * Rendering + *******************************************************************************/ + /** + * Display template + * + * This method echoes the rendered template to the current output buffer + * + * @param string $template Pathname of template file relative to templates directory + * @param array $data Any additonal data to be passed to the template. + */ + public function display($template, $data = null) + { + echo $this->fetch($template, $data); + } + /** + * Return the contents of a rendered template file + * + * @param string $template The template pathname, relative to the template base directory + * @param array $data Any additonal data to be passed to the template. + * @return string The rendered template + */ + public function fetch($template, $data = null) + { + return $this->render($template, $data); + } + /** + * Render a template file + * + * NOTE: This method should be overridden by custom view subclasses + * + * @param string $template The template pathname, relative to the template base directory + * @param array $data Any additonal data to be passed to the template. + * @return string The rendered template + * @throws \RuntimeException If resolved template pathname is not a valid file + */ + protected function render($template, $data = null) + { + $templatePathname = $this->getTemplatePathname($template); + if (!is_file($templatePathname)) { + throw new \RuntimeException("View cannot render `$template` because the template does not exist"); + } + $data = array_merge($this->data->all(), (array) $data); + extract($data); + ob_start(); + require $templatePathname; + return ob_get_clean(); + } +} \ No newline at end of file diff --git a/plc/test/29 b/plc/test/29 new file mode 100644 index 0000000..1af6e83 --- /dev/null +++ b/plc/test/29 @@ -0,0 +1,9 @@ + public function formatLocalized($format) + { + // Check for Windows to find and replace the %e + // modifier correctly + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { + $format = preg_replace('#(?getContainer(); + /** + * Controllers + */ + $container->registerService('LostController', function(SimpleContainer $c) { + return new LostController( + $c->query('AppName'), + $c->query('Request'), + $c->query('URLGenerator'), + $c->query('UserManager'), + $c->query('Defaults'), + $c->query('L10N'), + $c->query('Config'), + $c->query('SecureRandom'), + $c->query('DefaultEmailAddress'), + $c->query('IsEncryptionEnabled') + ); + }); + $container->registerService('UserController', function(SimpleContainer $c) { + return new UserController( + $c->query('AppName'), + $c->query('Request'), + $c->query('UserManager'), + $c->query('Defaults') + ); + }); + /** + * Core class wrappers + */ + $container->registerService('IsEncryptionEnabled', function() { + return \OC_App::isEnabled('files_encryption'); + }); + $container->registerService('URLGenerator', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getURLGenerator(); + }); + $container->registerService('UserManager', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getUserManager(); + }); + $container->registerService('Config', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getConfig(); + }); + $container->registerService('L10N', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getL10N('core'); + }); + $container->registerService('SecureRandom', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getSecureRandom(); + }); + $container->registerService('Defaults', function() { + return new \OC_Defaults; + }); + $container->registerService('DefaultEmailAddress', function() { + return Util::getDefaultEmailAddress('lostpassword-noreply'); + }); + } +} \ No newline at end of file diff --git a/plc/test/31 b/plc/test/31 new file mode 100644 index 0000000..77b507c --- /dev/null +++ b/plc/test/31 @@ -0,0 +1,213 @@ +type name = string + +let compare_label label1 label2 = + let compare_length = compare (String.length label1) (String.length label2) in + if compare_length = 0 then + String.compare label1 label2 + else compare_length + + +module LabelMap = Map.Make( + struct + type t = name + let compare = compare_label + end) + +type expr = + | Var of name (* variable *) + | Call of expr * expr list (* application *) + | Fun of name list * expr (* abstraction *) + | Let of name * expr * expr (* let *) + | RecordSelect of expr * name (* selecting value of label: `r.a` *) + | RecordExtend of (expr list) LabelMap.t * expr (* extending a record: `{a = 1, b = 2 | r}` *) + | RecordRestrict of expr * name (* deleting a label: `{r - a}` *) + | RecordEmpty (* empty record: `{}` *) + | Variant of name * expr (* new variant value: `:X a` *) + | Case of expr * (name * name * expr) list * (name * expr) option + (* a pattern-matching case expression: + match e { + :X a -> expr1 + | :Y b -> expr2 + ... + | z -> default_expr (optional) + } + *) + +type id = int +type level = int + +type ty = + | TConst of name (* type constant: `int` or `bool` *) + | TApp of ty * ty list (* type application: `list[int]` *) + | TArrow of ty list * ty (* function type: `(int, int) -> int` *) + | TVar of tvar ref (* type variable *) + | TRecord of row (* record type: `{...}` *) + | TVariant of row (* variant type: `[...]` *) + | TRowEmpty (* empty row: `<>` *) + | TRowExtend of (ty list) LabelMap.t * row (* row extension: `
` *) + +and row = ty (* the kind of rows - empty row, row variable, or row extension *) + +and tvar = + | Unbound of id * level + | Link of ty + | Generic of id + + +let rec real_ty = function + | TVar {contents = Link ty} -> real_ty ty + | ty -> ty + +let merge_label_maps label_map1 label_map2 = + LabelMap.merge + (fun label maybe_ty_list1 maybe_ty_list2 -> + match maybe_ty_list1, maybe_ty_list2 with + | None, None -> assert false + | None, (Some ty_list2) -> Some ty_list2 + | (Some ty_list1), None -> Some ty_list1 + | (Some ty_list1), (Some ty_list2) -> Some (ty_list1 @ ty_list2)) + label_map1 label_map2 + +(* Returns a label map with all field types and the type of the "rest", + which is either a type var or an empty row. *) +let rec match_row_ty = function + | TRowExtend(label_ty_map, rest_ty) -> begin + match match_row_ty rest_ty with + | (rest_label_ty_map, rest_ty) when LabelMap.is_empty rest_label_ty_map -> + (label_ty_map, rest_ty) + | (rest_label_ty_map, rest_ty) -> + (merge_label_maps label_ty_map rest_label_ty_map, rest_ty) + end + | TVar {contents = Link ty} -> match_row_ty ty + | TVar _ as var -> (LabelMap.empty, var) + | TRowEmpty -> (LabelMap.empty, TRowEmpty) + | ty -> raise (Failure "not a row") + +(* Adds new bindings to a label map. Assumes all bindings (both + new and existing) are distinct. *) +let add_distinct_labels label_el_map label_el_list = + List.fold_left + (fun label_el_map (label, el) -> + assert (not (LabelMap.mem label label_el_map)) ; + LabelMap.add label el label_el_map) + label_el_map label_el_list + +let label_map_from_list label_el_list = + add_distinct_labels LabelMap.empty label_el_list + + + +let string_of_expr expr : string = + let rec f is_simple = function + | Var name -> name + | Call(fn_expr, arg_list) -> + f true fn_expr ^ "(" ^ String.concat ", " (List.map (f false) arg_list) ^ ")" + | Fun(param_list, body_expr) -> + let fun_str = + "fun " ^ String.concat " " param_list ^ " -> " ^ f false body_expr + in + if is_simple then "(" ^ fun_str ^ ")" else fun_str + | Let(var_name, value_expr, body_expr) -> + let let_str = + "let " ^ var_name ^ " = " ^ f false value_expr ^ " in " ^ f false body_expr + in + if is_simple then "(" ^ let_str ^ ")" else let_str + | RecordEmpty -> "{}" + | RecordSelect(record_expr, label) -> f true record_expr ^ "." ^ label + | RecordRestrict(record_expr, label) -> "{" ^ f false record_expr ^ " - " ^ label ^ "}" + | RecordExtend(label_expr_map, rest_expr) -> + let label_expr_str = + String.concat ", " + (List.map + (fun (label, expr_list) -> + String.concat ", " + (List.map (fun expr -> label ^ " = " ^ f false expr) expr_list)) + (LabelMap.bindings label_expr_map)) + in + let rest_expr_str = match rest_expr with + | RecordEmpty -> "" + | expr -> " | " ^ f false expr + in + "{" ^ label_expr_str ^ rest_expr_str ^ "}" + | Variant(label, value) -> + let variant_str = ":" ^ label ^ " " ^ f true value in + if is_simple then "(" ^ variant_str ^ ")" else variant_str + | Case(expr, cases, maybe_default_case) -> + let cases_str_list = List.map + (fun (label, var_name, expr) -> + "| :" ^ label ^ " " ^ var_name ^ " -> " ^ f false expr) + cases + in + let all_cases_str = match (cases_str_list, maybe_default_case) with + | ([], Some (var_name, expr)) -> var_name ^ " -> " ^ f false expr + | (cases_str_list, None) -> String.concat "" cases_str_list + | (cases_str_list, Some (var_name, expr)) -> + String.concat "" cases_str_list ^ " | " ^ var_name ^ " -> " ^ f false expr + in + "match " ^ f false expr ^ " { " ^ all_cases_str ^ " } " + in + f false expr + +let string_of_ty ty : string = + let id_name_map = Hashtbl.create 10 in + let count = ref 0 in + let next_name () = + let i = !count in + incr count ; + let name = String.make 1 (Char.chr (97 + i mod 26)) ^ + if i >= 26 then string_of_int (i / 26) else "" + in + name + in + let rec f is_simple = function + | TConst name -> name + | TApp(ty, ty_arg_list) -> + f true ty ^ "[" ^ String.concat ", " (List.map (f false) ty_arg_list) ^ "]" + | TArrow(param_ty_list, return_ty) -> + let arrow_ty_str = match param_ty_list with + | [param_ty] -> + let param_ty_str = f true param_ty in + let return_ty_str = f false return_ty in + param_ty_str ^ " -> " ^ return_ty_str + | _ -> + let param_ty_list_str = String.concat ", " (List.map (f false) param_ty_list) in + let return_ty_str = f false return_ty in + "(" ^ param_ty_list_str ^ ") -> " ^ return_ty_str + in + if is_simple then "(" ^ arrow_ty_str ^ ")" else arrow_ty_str + | TVar {contents = Generic id} -> begin + try + Hashtbl.find id_name_map id + with Not_found -> + let name = next_name () in + Hashtbl.add id_name_map id name ; + name + end + | TVar {contents = Unbound(id, _)} -> "_" ^ string_of_int id + | TVar {contents = Link ty} -> f is_simple ty + | TRecord row_ty -> "{" ^ f false row_ty ^ "}" + | TVariant row_ty -> "[" ^ f false row_ty ^ "]" + | TRowEmpty -> "" + | TRowExtend _ as row_ty -> + let (label_ty_map, rest_ty) = match_row_ty row_ty in + let label_ty_str = + String.concat ", " + (List.map + (fun (label, ty_list) -> + String.concat ", " + (List.map (fun ty -> label ^ " : " ^ f false ty) ty_list)) + (LabelMap.bindings label_ty_map)) + in + let rest_ty_str = match real_ty rest_ty with + | TRowEmpty -> "" + | TRowExtend _ -> assert false + | other_ty -> " | " ^ f false other_ty + in + label_ty_str ^ rest_ty_str + in + let ty_str = f false ty in + if !count > 0 then + let var_names = Hashtbl.fold (fun _ value acc -> value :: acc) id_name_map [] in + "forall[" ^ String.concat " " (List.sort String.compare var_names) ^ "] " ^ ty_str + else + ty_str \ No newline at end of file diff --git a/plc/test/32 b/plc/test/32 new file mode 100644 index 0000000..baf55ef --- /dev/null +++ b/plc/test/32 @@ -0,0 +1,15 @@ +let search_compiler_libs () = + prerr_endline "I: Searching for OCaml compiler libraries"; + let stdlib = BaseEnv.var_get "standard_library" in + let ( / ) = Filename.concat in + try + List.find (fun path -> Sys.file_exists (path / "types.cmi") || Sys.file_exists (path / "typing" / "types.cmi")) [ + stdlib; + stdlib / "compiler-libs"; + stdlib / "compiler-lib"; + stdlib / ".." / "compiler-libs"; + stdlib / ".." / "compiler-lib"; + ] + with Not_found -> + prerr_endline "E: Cannot find compiler libraries! See the README for details."; + exit 1 \ No newline at end of file diff --git a/plc/test/4 b/plc/test/4 new file mode 100644 index 0000000..2b01695 --- /dev/null +++ b/plc/test/4 @@ -0,0 +1,21 @@ +(require '[overtone.live :as overtone]) + +(defn note [timing pitch] {:time timing :pitch pitch}) + +(def melody + (let [pitches + [0 0 0 1 2 + ; Row, row, row your boat, + 2 1 2 3 4 + ; Gently down the stream, + 7 7 7 4 4 4 2 2 2 0 0 0 + ; (take 4 (repeat "merrily")) + 4 3 2 1 0] + ; Life is but a dream! + durations + [1 1 2/3 1/3 1 + 2/3 1/3 2/3 1/3 2 + 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 + 2/3 1/3 2/3 1/3 2] + times (reductions + 0 durations)] + (map note times pitches))) \ No newline at end of file diff --git a/plc/test/5 b/plc/test/5 new file mode 100644 index 0000000..f091c5f --- /dev/null +++ b/plc/test/5 @@ -0,0 +1,26 @@ +from pkgutil import iter_modules +from subprocess import call + +dependencies = { + "Crypto": "crypto", + "dpkt": "dpkt", + "IPy": "ipy", + "pcap": "pypcap" +} + +installed, missing_pkgs = [pkg[1] for pkg in iter_modules()], [] + +for module, pkg in dependencies.items(): + if module not in installed: + print("dshell requires {}".format(module)) + missing_pkgs.append("python-{}".format(pkg)) + else: + print("{} is installed".format(module)) + +if missing_pkgs: + cmd = ["sudo", "apt-get", "install"] + missing_pkgs + + print(" ".join(cmd)) + call(cmd) + +call(["make", "all"]) \ No newline at end of file diff --git a/plc/test/6 b/plc/test/6 new file mode 100644 index 0000000..233a6b9 --- /dev/null +++ b/plc/test/6 @@ -0,0 +1,88 @@ +import re +import subprocess + +def cmd_keymap_table(): + return subprocess.Popen( + ['xmodmap','-pk'], stdout=subprocess.PIPE).communicate()[0] + +def cmd_modifier_map(): + return subprocess.Popen( + ['xmodmap','-pm'], stdout=subprocess.PIPE).communicate()[0] + +def get_keymap_table(): + keymap = {} + + keymap_table = cmd_keymap_table() + + re_line = re.compile(r'0x\w+') + for line in keymap_table.split('\n')[1:]: + if len(line) > 0: + keycode = re.search(r'\s+(\d+).*', line) + if keycode: + new_keysyms = [] + keycode = int(keycode.group(1)) + keysyms = re_line.findall(line) + # When you press only one key + unicode_char = '' + try: + unicode_char = unichr(int(keysyms[0], 16)) + except: + unicode_char = '' + if unicode_char == u'\x00': + unicode_char = '' + new_keysyms.append(unicode_char) + + # When you press a key plus Shift key + unicode_char = '' + try: + unicode_char = unichr(int(keysyms[1], 16)) + except: + unicode_char = '' + if unicode_char == u'\x00': + unicode_char = '' + new_keysyms.append(unicode_char) + + # When you press a key plus meta (dead keys) + unicode_char = '' + try: + unicode_char = unichr(int(keysyms[4], 16)) + except: + unicode_char = '' + if unicode_char == u'\x00': + unicode_char = '' + new_keysyms.append(unicode_char) + + # When you press a key plus meta plus Shift key + unicode_char = '' + try: + unicode_char = unichr(int(keysyms[5], 16)) + except: + unicode_char = '' + if unicode_char == u'\x00': + unicode_char = '' + new_keysyms.append(unicode_char) + + #keymap[keycode-8] = new_keysyms + keymap[keycode] = new_keysyms + + return keymap + +def get_modifier_map(): + modifiers = {} + + modifier_map = cmd_modifier_map() + + re_line = re.compile(r'(0x\w+)') + for line in modifier_map.split('\n')[1:]: + if len(line) > 0: + mod_name = re.match(r'(\w+).*', line) + if mod_name: + mod_name = mod_name.group(1) + keycodes = re_line.findall(line) + # Convert key codes from hex to dec for use them + # with the keymap table + keycodes =[ int(kc, 16) for kc in keycodes] + + modifiers[mod_name] = keycodes + + return modifiers \ No newline at end of file diff --git a/plc/test/7 b/plc/test/7 new file mode 100644 index 0000000..f709879 --- /dev/null +++ b/plc/test/7 @@ -0,0 +1,15 @@ +class NoSuchService(Exception): + def __init__(self, name): + self.name = name + self.msg = "No such service: %s" % self.name + + def __str__(self): + return self.msg + + +class ConfigurationError(Exception): + def __init__(self, msg): + self.msg = msg + + def __str__(self): + return self.msg \ No newline at end of file diff --git a/plc/test/8 b/plc/test/8 new file mode 100644 index 0000000..95f2402 --- /dev/null +++ b/plc/test/8 @@ -0,0 +1,532 @@ +from collections import namedtuple +import functools +import heapq +import itertools +import logging +import Queue +import random +import threading + +# data types +Proposal = namedtuple('Proposal', ['caller', 'client_id', 'input']) +Ballot = namedtuple('Ballot', ['n', 'leader']) + +# message types +Accepted = namedtuple('Accepted', ['slot', 'ballot_num']) +Accept = namedtuple('Accept', ['slot', 'ballot_num', 'proposal']) +Decision = namedtuple('Decision', ['slot', 'proposal']) +Invoked = namedtuple('Invoked', ['client_id', 'output']) +Invoke = namedtuple('Invoke', ['caller', 'client_id', 'input_value']) +Join = namedtuple('Join', []) +Active = namedtuple('Active', []) +Prepare = namedtuple('Prepare', ['ballot_num']) +Promise = namedtuple('Promise', ['ballot_num', 'accepted_proposals']) +Propose = namedtuple('Propose', ['slot', 'proposal']) +Welcome = namedtuple('Welcome', ['state', 'slot', 'decisions']) +Decided = namedtuple('Decided', ['slot']) +Preempted = namedtuple('Preempted', ['slot', 'preempted_by']) +Adopted = namedtuple('Adopted', ['ballot_num', 'accepted_proposals']) +Accepting = namedtuple('Accepting', ['leader']) + +# constants - these times should really be in terms of average round-trip time +JOIN_RETRANSMIT = 0.7 +CATCHUP_INTERVAL = 0.6 +ACCEPT_RETRANSMIT = 1.0 +PREPARE_RETRANSMIT = 1.0 +INVOKE_RETRANSMIT = 0.5 +LEADER_TIMEOUT = 1.0 +NULL_BALLOT = Ballot(-1, -1) # sorts before all real ballots +NOOP_PROPOSAL = Proposal(None, None, None) # no-op to fill otherwise empty slots + +class Node(object): + unique_ids = itertools.count() + + def __init__(self, network, address): + self.network = network + self.address = address or 'N%d' % self.unique_ids.next() + self.logger = SimTimeLogger(logging.getLogger(self.address), {'network': self.network}) + self.logger.info('starting') + self.roles = [] + self.send = functools.partial(self.network.send, self) + + def register(self, roles): + self.roles.append(roles) + + def unregister(self, roles): + self.roles.remove(roles) + + def receive(self, sender, message): + handler_name = 'do_%s' % type(message).__name__ + + for comp in self.roles[:]: + if not hasattr(comp, handler_name): + continue + comp.logger.debug("received %s from %s", message, sender) + fn = getattr(comp, handler_name) + fn(sender=sender, **message._asdict()) + +class Timer(object): + + def __init__(self, expires, address, callback): + self.expires = expires + self.address = address + self.callback = callback + self.cancelled = False + + def __cmp__(self, other): + return cmp(self.expires, other.expires) + + def cancel(self): + self.cancelled = True + +class Network(object): + PROP_DELAY = 0.03 + PROP_JITTER = 0.02 + DROP_PROB = 0.05 + + def __init__(self, seed): + self.nodes = {} + self.rnd = random.Random(seed) + self.timers = [] + self.now = 1000.0 + + def new_node(self, address=None): + node = Node(self, address=address) + self.nodes[node.address] = node + return node + + def run(self): + while self.timers: + next_timer = self.timers[0] + if next_timer.expires > self.now: + self.now = next_timer.expires + heapq.heappop(self.timers) + if next_timer.cancelled: + continue + if not next_timer.address or next_timer.address in self.nodes: + next_timer.callback() + + def stop(self): + self.timers = [] + + def set_timer(self, address, seconds, callback): + timer = Timer(self.now + seconds, address, callback) + heapq.heappush(self.timers, timer) + return timer + + def send(self, sender, destinations, message): + sender.logger.debug("sending %s to %s", message, destinations) + for dest in (d for d in destinations if d in self.nodes): + if dest == sender.address: + # reliably deliver local messages with no delay + self.set_timer(sender.address, 0, lambda: sender.receive(sender.address, message)) + elif self.rnd.uniform(0, 1.0) > self.DROP_PROB: + delay = self.PROP_DELAY + self.rnd.uniform(-self.PROP_JITTER, self.PROP_JITTER) + self.set_timer(dest, delay, functools.partial(self.nodes[dest].receive, + sender.address, message)) + +class SimTimeLogger(logging.LoggerAdapter): + + def process(self, msg, kwargs): + return "T=%.3f %s" % (self.extra['network'].now, msg), kwargs + + def getChild(self, name): + return self.__class__(self.logger.getChild(name), + {'network': self.extra['network']}) + +class Role(object): + + def __init__(self, node): + self.node = node + self.node.register(self) + self.running = True + self.logger = node.logger.getChild(type(self).__name__) + + def set_timer(self, seconds, callback): + return self.node.network.set_timer(self.node.address, seconds, + lambda: self.running and callback()) + + def stop(self): + self.running = False + self.node.unregister(self) + +class Acceptor(Role): + + def __init__(self, node): + super(Acceptor, self).__init__(node) + self.ballot_num = NULL_BALLOT + self.accepted_proposals = {} # {slot: (ballot_num, proposal)} + + def do_Prepare(self, sender, ballot_num): + if ballot_num > self.ballot_num: + self.ballot_num = ballot_num + # we've heard from a scout, so it might be the next leader + self.node.send([self.node.address], Accepting(leader=sender)) + + self.node.send([sender], Promise(ballot_num=self.ballot_num, accepted_proposals=self.accepted_proposals)) + + def do_Accept(self, sender, ballot_num, slot, proposal): + if ballot_num >= self.ballot_num: + self.ballot_num = ballot_num + acc = self.accepted_proposals + if slot not in acc or acc[slot][0] < ballot_num: + acc[slot] = (ballot_num, proposal) + + self.node.send([sender], Accepted( + slot=slot, ballot_num=self.ballot_num)) + +class Replica(Role): + + def __init__(self, node, execute_fn, state, slot, decisions, peers): + super(Replica, self).__init__(node) + self.execute_fn = execute_fn + self.state = state + self.slot = slot + self.decisions = decisions.copy() + self.peers = peers + self.proposals = {} + # next slot num for a proposal (may lead slot) + self.next_slot = slot + self.latest_leader = None + self.latest_leader_timeout = None + + # making proposals + + def do_Invoke(self, sender, caller, client_id, input_value): + proposal = Proposal(caller, client_id, input_value) + slot = next((s for s, p in self.proposals.iteritems() if p == proposal), None) + # propose, or re-propose if this proposal already has a slot + self.propose(proposal, slot) + + def propose(self, proposal, slot=None): + """Send (or resend, if slot is specified) a proposal to the leader""" + if not slot: + slot, self.next_slot = self.next_slot, self.next_slot + 1 + self.proposals[slot] = proposal + # find a leader we think is working - either the latest we know of, or + # ourselves (which may trigger a scout to make us the leader) + leader = self.latest_leader or self.node.address + self.logger.info("proposing %s at slot %d to leader %s" % (proposal, slot, leader)) + self.node.send([leader], Propose(slot=slot, proposal=proposal)) + + # handling decided proposals + + def do_Decision(self, sender, slot, proposal): + assert not self.decisions.get(self.slot, None), \ + "next slot to commit is already decided" + if slot in self.decisions: + assert self.decisions[slot] == proposal, \ + "slot %d already decided with %r!" % (slot, self.decisions[slot]) + return + self.decisions[slot] = proposal + self.next_slot = max(self.next_slot, slot + 1) + + # re-propose our proposal in a new slot if it lost its slot and wasn't a no-op + our_proposal = self.proposals.get(slot) + if our_proposal is not None and our_proposal != proposal and our_proposal.caller: + self.propose(our_proposal) + + # execute any pending, decided proposals + while True: + commit_proposal = self.decisions.get(self.slot) + if not commit_proposal: + break # not decided yet + commit_slot, self.slot = self.slot, self.slot + 1 + + self.commit(commit_slot, commit_proposal) + + def commit(self, slot, proposal): + """Actually commit a proposal that is decided and in sequence""" + decided_proposals = [p for s, p in self.decisions.iteritems() if s < slot] + if proposal in decided_proposals: + self.logger.info("not committing duplicate proposal %r at slot %d", proposal, slot) + return # duplicate + + self.logger.info("committing %r at slot %d" % (proposal, slot)) + if proposal.caller is not None: + # perform a client operation + self.state, output = self.execute_fn(self.state, proposal.input) + self.node.send([proposal.caller], Invoked(client_id=proposal.client_id, output=output)) + + # tracking the leader + + def do_Adopted(self, sender, ballot_num, accepted_proposals): + self.latest_leader = self.node.address + self.leader_alive() + + def do_Accepting(self, sender, leader): + self.latest_leader = leader + self.leader_alive() + + def do_Active(self, sender): + if sender != self.latest_leader: + return + self.leader_alive() + + def leader_alive(self): + if self.latest_leader_timeout: + self.latest_leader_timeout.cancel() + + def reset_leader(): + idx = self.peers.index(self.latest_leader) + self.latest_leader = self.peers[(idx + 1) % len(self.peers)] + self.logger.debug("leader timed out; tring the next one, %s", self.latest_leader) + self.latest_leader_timeout = self.set_timer(LEADER_TIMEOUT, reset_leader) + + # adding new cluster members + + def do_Join(self, sender): + if sender in self.peers: + self.node.send([sender], Welcome( + state=self.state, slot=self.slot, decisions=self.decisions)) + +class Commander(Role): + + def __init__(self, node, ballot_num, slot, proposal, peers): + super(Commander, self).__init__(node) + self.ballot_num = ballot_num + self.slot = slot + self.proposal = proposal + self.acceptors = set([]) + self.peers = peers + self.quorum = len(peers) / 2 + 1 + + def start(self): + self.node.send(set(self.peers) - self.acceptors, Accept( + slot=self.slot, ballot_num=self.ballot_num, proposal=self.proposal)) + self.set_timer(ACCEPT_RETRANSMIT, self.start) + + def finished(self, ballot_num, preempted): + if preempted: + self.node.send([self.node.address], Preempted(slot=self.slot, preempted_by=ballot_num)) + else: + self.node.send([self.node.address], Decided(slot=self.slot)) + self.stop() + + def do_Accepted(self, sender, slot, ballot_num): + if slot != self.slot: + return + if ballot_num == self.ballot_num: + self.acceptors.add(sender) + if len(self.acceptors) < self.quorum: + return + self.node.send(self.peers, Decision(slot=self.slot, proposal=self.proposal)) + self.finished(ballot_num, False) + else: + self.finished(ballot_num, True) + +class Scout(Role): + + def __init__(self, node, ballot_num, peers): + super(Scout, self).__init__(node) + self.ballot_num = ballot_num + self.accepted_proposals = {} + self.acceptors = set([]) + self.peers = peers + self.quorum = len(peers) / 2 + 1 + self.retransmit_timer = None + + def start(self): + self.logger.info("scout starting") + self.send_prepare() + + def send_prepare(self): + self.node.send(self.peers, Prepare(ballot_num=self.ballot_num)) + self.retransmit_timer = self.set_timer(PREPARE_RETRANSMIT, self.send_prepare) + + def update_accepted(self, accepted_proposals): + acc = self.accepted_proposals + for slot, (ballot_num, proposal) in accepted_proposals.iteritems(): + if slot not in acc or acc[slot][0] < ballot_num: + acc[slot] = (ballot_num, proposal) + + def do_Promise(self, sender, ballot_num, accepted_proposals): + if ballot_num == self.ballot_num: + self.logger.info("got matching promise; need %d" % self.quorum) + self.update_accepted(accepted_proposals) + self.acceptors.add(sender) + if len(self.acceptors) >= self.quorum: + # strip the ballot numbers from self.accepted_proposals, now that it + # represents a majority + accepted_proposals = dict((s, p) for s, (b, p) in self.accepted_proposals.iteritems()) + # We're adopted; note that this does *not* mean that no other leader is active. + # Any such conflicts will be handled by the commanders. + self.node.send([self.node.address], + Adopted(ballot_num=ballot_num, accepted_proposals=accepted_proposals)) + self.stop() + else: + # this acceptor has promised another leader a higher ballot number, so we've lost + self.node.send([self.node.address], Preempted(slot=None, preempted_by=ballot_num)) + self.stop() + +class Leader(Role): + + def __init__(self, node, peers, commander_cls=Commander, scout_cls=Scout): + super(Leader, self).__init__(node) + self.ballot_num = Ballot(0, node.address) + self.active = False + self.proposals = {} + self.commander_cls = commander_cls + self.scout_cls = scout_cls + self.scouting = False + self.peers = peers + + def start(self): + # reminder others we're active before LEADER_TIMEOUT expires + def active(): + if self.active: + self.node.send(self.peers, Active()) + self.set_timer(LEADER_TIMEOUT / 2.0, active) + active() + + def spawn_scout(self): + assert not self.scouting + self.scouting = True + self.scout_cls(self.node, self.ballot_num, self.peers).start() + + def do_Adopted(self, sender, ballot_num, accepted_proposals): + self.scouting = False + self.proposals.update(accepted_proposals) + # note that we don't re-spawn commanders here; if there are undecided + # proposals, the replicas will re-propose + self.logger.info("leader becoming active") + self.active = True + + def spawn_commander(self, ballot_num, slot): + proposal = self.proposals[slot] + self.commander_cls(self.node, ballot_num, slot, proposal, self.peers).start() + + def do_Preempted(self, sender, slot, preempted_by): + if not slot: # from the scout + self.scouting = False + self.logger.info("leader preempted by %s", preempted_by.leader) + self.active = False + self.ballot_num = Ballot((preempted_by or self.ballot_num).n + 1, self.ballot_num.leader) + + def do_Propose(self, sender, slot, proposal): + if slot not in self.proposals: + if self.active: + self.proposals[slot] = proposal + self.logger.info("spawning commander for slot %d" % (slot,)) + self.spawn_commander(self.ballot_num, slot) + else: + if not self.scouting: + self.logger.info("got PROPOSE when not active - scouting") + self.spawn_scout() + else: + self.logger.info("got PROPOSE while scouting; ignored") + else: + self.logger.info("got PROPOSE for a slot already being proposed") + +class Bootstrap(Role): + + def __init__(self, node, peers, execute_fn, + replica_cls=Replica, acceptor_cls=Acceptor, leader_cls=Leader, + commander_cls=Commander, scout_cls=Scout): + super(Bootstrap, self).__init__(node) + self.execute_fn = execute_fn + self.peers = peers + self.peers_cycle = itertools.cycle(peers) + self.replica_cls = replica_cls + self.acceptor_cls = acceptor_cls + self.leader_cls = leader_cls + self.commander_cls = commander_cls + self.scout_cls = scout_cls + + def start(self): + self.join() + + def join(self): + self.node.send([next(self.peers_cycle)], Join()) + self.set_timer(JOIN_RETRANSMIT, self.join) + + def do_Welcome(self, sender, state, slot, decisions): + self.acceptor_cls(self.node) + self.replica_cls(self.node, execute_fn=self.execute_fn, peers=self.peers, + state=state, slot=slot, decisions=decisions) + self.leader_cls(self.node, peers=self.peers, commander_cls=self.commander_cls, + scout_cls=self.scout_cls).start() + self.stop() + +class Seed(Role): + + def __init__(self, node, initial_state, execute_fn, peers, bootstrap_cls=Bootstrap): + super(Seed, self).__init__(node) + self.initial_state = initial_state + self.execute_fn = execute_fn + self.peers = peers + self.bootstrap_cls = bootstrap_cls + self.seen_peers = set([]) + self.exit_timer = None + + def do_Join(self, sender): + self.seen_peers.add(sender) + if len(self.seen_peers) <= len(self.peers) / 2: + return + + # cluster is ready - welcome everyone + self.node.send(list(self.seen_peers), Welcome( + state=self.initial_state, slot=1, decisions={})) + + # stick around for long enough that we don't hear any new JOINs from + # the newly formed cluster + if self.exit_timer: + self.exit_timer.cancel() + self.exit_timer = self.set_timer(JOIN_RETRANSMIT * 2, self.finish) + + def finish(self): + # bootstrap this node into the cluster we just seeded + bs = self.bootstrap_cls(self.node, peers=self.peers, execute_fn=self.execute_fn) + bs.start() + self.stop() + +class Requester(Role): + + client_ids = itertools.count(start=100000) + + def __init__(self, node, n, callback): + super(Requester, self).__init__(node) + self.client_id = self.client_ids.next() + self.n = n + self.output = None + self.callback = callback + + def start(self): + self.node.send([self.node.address], Invoke(caller=self.node.address, + client_id=self.client_id, input_value=self.n)) + self.invoke_timer = self.set_timer(INVOKE_RETRANSMIT, self.start) + + def do_Invoked(self, sender, client_id, output): + if client_id != self.client_id: + return + self.logger.debug("received output %r" % (output,)) + self.invoke_timer.cancel() + self.callback(output) + self.stop() + +class Member(object): + + def __init__(self, state_machine, network, peers, seed=None, + seed_cls=Seed, bootstrap_cls=Bootstrap): + self.network = network + self.node = network.new_node() + if seed is not None: + self.startup_role = seed_cls(self.node, initial_state=seed, peers=peers, + execute_fn=state_machine) + else: + self.startup_role = bootstrap_cls(self.node, execute_fn=state_machine, peers=peers) + self.requester = None + + def start(self): + self.startup_role.start() + self.thread = threading.Thread(target=self.network.run) + self.thread.start() + + def invoke(self, input_value, request_cls=Requester): + assert self.requester is None + q = Queue.Queue() + self.requester = request_cls(self.node, input_value, q.put) + self.requester.start() + output = q.get() + self.requester = None + return output \ No newline at end of file diff --git a/plc/test/9 b/plc/test/9 new file mode 100644 index 0000000..02061e2 --- /dev/null +++ b/plc/test/9 @@ -0,0 +1,53 @@ +function errorHandler(context) { + return function(error) { + trace('Failure in ' + context + ': ' + error.toString); + } +} + +function successHandler(context) { + return function() { + trace('Success in ' + context); + } +} + +function noAction() { +} + + +function VideoPipe(stream, handler) { + var servers = null; + var pc1 = new RTCPeerConnection(servers); + var pc2 = new RTCPeerConnection(servers); + + pc1.addStream(stream); + pc1.onicecandidate = function(event) { + if (event.candidate) { + pc2.addIceCandidate(new RTCIceCandidate(event.candidate), + noAction, errorHandler('AddIceCandidate')); + } + } + pc2.onicecandidate = function(event) { + if (event.candidate) { + pc1.addIceCandidate(new RTCIceCandidate(event.candidate), + noAction, errorHandler('AddIceCandidate')); + } + } + pc2.onaddstream = function(e) { + handler(e.stream); + } + pc1.createOffer(function(desc) { + pc1.setLocalDescription(desc); + pc2.setRemoteDescription(desc); + pc2.createAnswer(function(desc2) { + pc2.setLocalDescription(desc2); + pc1.setRemoteDescription(desc2); + }, errorHandler('pc2.createAnswer')); + }, errorHandler('pc1.createOffer')); + this.pc1 = pc1; + this.pc2 = pc2; +} + +VideoPipe.prototype.close = function() { + this.pc1.close(); + this.pc2.close(); +} \ No newline at end of file diff --git a/plc/workbook.ipynb b/plc/workbook.ipynb index 88f8227..c4b7079 100644 --- a/plc/workbook.ipynb +++ b/plc/workbook.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:1b276628b91aa6f93e909526ed4263f16818b2c785da2a7f4712e8f663929476" + "signature": "sha256:40570cfaf8cdd3aad2186afd0616a0c01503a5cc2774f3bbc4fa0964e6c3400d" }, "nbformat": 3, "nbformat_minor": 0, @@ -735,12 +735,13 @@ "cell_type": "code", "collapsed": false, "input": [ - "word_list = ['let', 'end', 'defn', 'function', 'fun', 'defn', 'def', 'return', 'check', 'make', '.format', '$', 'printf']" + "word_list = ['let', 'end', 'defn', 'function', 'fun', 'return', 'def', 'return', 'check', 'make', '->', '.format',\n", + " 'define', '::', '$', '^', ',', ';', '&', '|', '!']" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 193 + "prompt_number": 197 }, { "cell_type": "code", @@ -765,141 +766,16 @@ "outputs": [], "prompt_number": 194 }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "df['^'] = df.Code.apply(carat)\n", - "df[';'] = df.Code.apply(semicolon)\n", - "df[','] = df.Code.apply(comma)\n", - "df['&'] = df.Code.apply(carat)\n", - "df['!'] = df.Code.apply(semicolon)\n", - "df['|'] = df.Code.apply(comma)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 103 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def carat(code):\n", - " x =character_ratio(code, '^')\n", - " return x\n", - "\n", - "def comma(code):\n", - " x =character_ratio(code, ',')\n", - " return x\n", - "\n", - "def semicolon(code):\n", - " x =character_ratio(code, ';')\n", - " return x\n", - "\n", - "def ampersand(code):\n", - " x =character_ratio(code, '&')\n", - " return x\n", - "\n", - "def exclamation(code):\n", - " x =character_ratio(code, '!')\n", - " return x\n", - "\n", - "def pipe(code):\n", - " x =character_ratio(code, '|')\n", - " return x" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 102 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def let_ratio(code):\n", - " return string_ratio('let', code)\n", - "\n", - "def end_ratio(code):\n", - " return string_ratio('end', code)\n", - "\n", - "def fun_ratio(code):\n", - " return string_ratio('fun', code)\n", - "\n", - "def defn_ratio(code):\n", - " return string_ratio('defn', code)\n", - "\n", - "def def_ratio(code):\n", - " return string_ratio('def', code)\n", - "\n", - "def function_ratio(code):\n", - " return string_ratio('function', code)\n", - "\n", - "def return_ratio(code):\n", - " return string_ratio('return', code)\n", - "\n", - "def define_ratio(code):\n", - " return string_ratio('define', code)\n", - "\n", - "def doublecolon_ratio(code):\n", - " return string_ratio('::', code)\n", - "\n", - "def check_ratio(code):\n", - " return string_ratio('check', code)\n", - "\n", - "def make_ratio(code):\n", - " return string_ratio('make', code)\n", - "\n", - "def format_ratio(code):\n", - " return string_ratio('.format', code)\n", - "\n", - "def arrow_ratio(code):\n", - " return string_ratio('->', code)\n", - "\n", - "def dollar_ratio(code):\n", - " return string_ratio('$', code)\n", - "\n", - "def printf_ratio(code):\n", - " return string_ratio('printf', code)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 188 - }, { "cell_type": "code", "collapsed": false, "input": [ - "df['let'] = df.Code.apply(let_ratio)\n", - "df['end'] = df.Code.apply(end_ratio)\n", - "df['fun'] = df.Code.apply(fun_ratio)\n", - "df['defn'] = df.Code.apply(defn_ratio)\n", - "df['def'] = df.Code.apply(def_ratio)\n", - "df['function'] = df.Code.apply(function_ratio)\n", - "df['return'] = df.Code.apply(return_ratio)\n", - "df['define'] = df.Code.apply(define_ratio)\n", - "df['doublecolon'] = df.Code.apply(doublecolon_ratio)\n", - "df['check'] = df.Code.apply(check_ratio)\n", - "df['make'] = df.Code.apply(make_ratio)\n", - "df['.format'] = df.Code.apply(format_ratio)\n", - "df['->'] = df.Code.apply(arrow_ratio)\n", - "df['$'] = df.Code.apply(dollar_ratio)\n", - "df['printf'] = df.Code.apply(printf_ratio)" + "df = data_frame_generator()" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 187 + "prompt_number": 198 }, { "cell_type": "code", @@ -919,25 +795,25 @@ " \n", " Language\n", " Code\n", - " code length\n", - " ^\n", - " ;\n", - " ,\n", - " &\n", - " !\n", - " |\n", " let\n", - " ...\n", - " fun\n", + " end\n", " defn\n", - " def\n", " function\n", - " slice\n", + " fun\n", " return\n", - " define\n", - " doublecolon\n", + " def\n", " check\n", - " make\n", + " ...\n", + " define\n", + " ::\n", + " $\n", + " printf\n", + " ^\n", + " ,\n", + " ;\n", + " &\n", + " |\n", + " !\n", " \n", " \n", " \n", @@ -945,720 +821,720 @@ " 0 \n", " clojure\n", " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 2420\n", - " 0.003719\n", - " 0.009091\n", - " 0.000826\n", - " 0.003719\n", - " 0.009091\n", - " 0.000826\n", " 0.002066\n", - " ...\n", " 0.000000\n", " 0.002066\n", - " 0.004545\n", - " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.004545\n", " 0.005372\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.000826\n", " 0.000000\n", + " 0.000413\n", + " 0.000826\n", + " 0.009091\n", + " 0.000413\n", + " 1.000413\n", + " 0.000826\n", " \n", " \n", " 1 \n", " clojure\n", " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 2594\n", - " 0.004241\n", - " 0.008096\n", - " 0.000771\n", - " 0.004241\n", - " 0.008096\n", - " 0.000771\n", " 0.002699\n", - " ...\n", - " 0.000000\n", + " 0.000386\n", " 0.001928\n", - " 0.003470\n", - " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.003470\n", " 0.005012\n", - " 0.002699\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.000771\n", + " 0.000000\n", + " 0.000386\n", + " 0.000771\n", + " 0.008096\n", + " 0.000771\n", + " 1.000386\n", + " 0.000771\n", " \n", " \n", " 2 \n", " clojure\n", " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 2969\n", - " 0.003705\n", - " 0.010104\n", - " 0.001347\n", - " 0.003705\n", - " 0.010104\n", - " 0.001347\n", " 0.002695\n", - " ...\n", " 0.000000\n", " 0.002021\n", - " 0.003705\n", - " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.003705\n", " 0.009094\n", + " ...\n", + " 0.000000\n", " 0.000000\n", + " 0.000674\n", + " 0.000000\n", + " 0.000337\n", + " 0.001347\n", + " 0.010104\n", + " 0.000337\n", + " 1.000337\n", + " 0.000337\n", " \n", " \n", " 3 \n", " haskell\n", " --\\n-- The Computer Language Benchmarks Game\\n...\n", - " 1619\n", + " 0.002471\n", " 0.000000\n", - " 0.000618\n", - " 0.006177\n", " 0.000000\n", - " 0.000618\n", - " 0.006177\n", - " 0.002471\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", + " 0.006794\n", + " ...\n", " 0.000000\n", + " 0.002471\n", + " 0.001235\n", + " 0.000618\n", + " 0.000618\n", + " 0.006177\n", + " 0.000618\n", " 0.000000\n", + " 1.000618\n", " 0.002471\n", - " 0.006794\n", - " 0.005559\n", " \n", " \n", " 4 \n", " haskell\n", " --\\n-- The Computer Language Benchmarks Game\\n...\n", - " 1889\n", - " 0.000000\n", - " 0.000529\n", - " 0.005294\n", - " 0.000000\n", - " 0.000529\n", - " 0.005294\n", " 0.002647\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", - " 0.002118\n", " 0.006882\n", - " 0.004764\n", + " ...\n", + " 0.000000\n", + " 0.002118\n", + " 0.001059\n", + " 0.000529\n", + " 0.000529\n", + " 0.005294\n", + " 0.000529\n", + " 0.000000\n", + " 1.000529\n", + " 0.003176\n", " \n", " \n", " 5 \n", " haskell\n", " --\\n-- The Computer Language Benchmarks Game\\n...\n", - " 1745\n", - " 0.000000\n", - " 0.000573\n", - " 0.005158\n", - " 0.000000\n", - " 0.000573\n", - " 0.005158\n", " 0.002865\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", - " 0.002292\n", " 0.007450\n", + " ...\n", + " 0.000000\n", + " 0.002292\n", + " 0.001146\n", + " 0.000573\n", + " 0.000573\n", " 0.005158\n", + " 0.000573\n", + " 0.000000\n", + " 1.000573\n", + " 0.002292\n", " \n", " \n", " 6 \n", " java\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 4072\n", - " 0.000000\n", - " 0.016208\n", - " 0.001719\n", " 0.000000\n", - " 0.016208\n", - " 0.001719\n", + " 0.001228\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000737\n", " 0.000000\n", + " 0.002947\n", + " ...\n", " 0.000000\n", - " 0\n", - " 0.000737\n", " 0.000000\n", + " 0.000491\n", " 0.000000\n", - " 0.002947\n", + " 0.000246\n", + " 0.001719\n", + " 0.016208\n", " 0.000000\n", + " 1.000246\n", + " 0.000246\n", " \n", " \n", " 7 \n", " java\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 2112\n", " 0.000000\n", - " 0.013258\n", - " 0.005682\n", " 0.000000\n", - " 0.013258\n", - " 0.005682\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.001894\n", " 0.000000\n", + " 0.004261\n", + " ...\n", " 0.000000\n", - " 0\n", - " 0.001894\n", " 0.000000\n", + " 0.000947\n", " 0.000000\n", - " 0.004261\n", + " 0.000473\n", + " 0.005682\n", + " 0.013258\n", + " 0.000000\n", + " 1.000473\n", " 0.000000\n", " \n", " \n", " 8 \n", " java\n", " /* The Computer Language Benchmarks Game\\n * h...\n", - " 2157\n", " 0.000000\n", - " 0.014372\n", - " 0.004636\n", " 0.000000\n", - " 0.014372\n", - " 0.004636\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.001391\n", " 0.000000\n", + " 0.006027\n", + " ...\n", " 0.000000\n", - " 0\n", - " 0.001391\n", " 0.000000\n", + " 0.000927\n", " 0.000000\n", - " 0.006027\n", + " 0.000464\n", + " 0.004636\n", + " 0.014372\n", + " 0.000000\n", + " 1.000464\n", " 0.000000\n", " \n", " \n", " 9 \n", " javascript\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 1368\n", " 0.000000\n", - " 0.017544\n", - " 0.010234\n", " 0.000000\n", - " 0.017544\n", - " 0.010234\n", " 0.000000\n", - " ...\n", " 0.002193\n", - " 0.000000\n", - " 0.000000\n", " 0.002193\n", - " 0\n", " 0.002924\n", " 0.000000\n", - " 0.000000\n", " 0.006579\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.001462\n", + " 0.000000\n", + " 0.000731\n", + " 0.010234\n", + " 0.017544\n", + " 0.000000\n", + " 1.000731\n", " 0.000000\n", " \n", " \n", " 10 \n", " ruby\n", " # The Computer Language Shootout Benchmarks\\n#...\n", - " 1246\n", " 0.000000\n", + " 0.003210\n", " 0.000000\n", - " 0.011236\n", " 0.000000\n", " 0.000000\n", + " 0.001605\n", + " 0.001605\n", " 0.011236\n", - " 0.000000\n", " ...\n", " 0.000000\n", " 0.000000\n", " 0.001605\n", " 0.000000\n", - " 0\n", - " 0.001605\n", + " 0.000803\n", + " 0.011236\n", " 0.000000\n", " 0.000000\n", - " 0.011236\n", + " 1.000803\n", " 0.000000\n", " \n", " \n", " 11 \n", " ruby\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 1426\n", " 0.000000\n", - " 0.001403\n", - " 0.011921\n", + " 0.003506\n", " 0.000000\n", - " 0.001403\n", - " 0.011921\n", - " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.001403\n", + " 0.001403\n", + " 0.009818\n", + " ...\n", + " 0.000000\n", " 0.000000\n", - " 0\n", " 0.001403\n", " 0.000000\n", + " 0.000701\n", + " 0.011921\n", + " 0.001403\n", " 0.000000\n", - " 0.009818\n", + " 1.000701\n", " 0.000000\n", " \n", " \n", " 12 \n", " ruby\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 1263\n", " 0.000000\n", + " 0.004751\n", " 0.000000\n", - " 0.011876\n", " 0.000000\n", " 0.000000\n", - " 0.011876\n", " 0.000000\n", + " 0.001584\n", + " 0.011085\n", " ...\n", " 0.000000\n", " 0.000000\n", " 0.001584\n", " 0.000000\n", - " 0\n", - " 0.000000\n", + " 0.000792\n", + " 0.011876\n", " 0.000000\n", " 0.000000\n", - " 0.011085\n", + " 1.000792\n", " 0.000000\n", " \n", " \n", " 13 \n", " ruby\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 4592\n", - " 0.000218\n", " 0.000000\n", - " 0.011324\n", - " 0.000218\n", + " 0.006533\n", " 0.000000\n", - " 0.011324\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.002395\n", + " 0.005444\n", + " ...\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " 0.000436\n", " 0.000000\n", + " 0.000218\n", + " 0.011324\n", " 0.000000\n", - " 0.005444\n", + " 0.003049\n", + " 1.000218\n", " 0.000000\n", " \n", " \n", " 14 \n", " ocaml\n", " (* The Computer Language Benchmarks Game\\n * h...\n", - " 1627\n", - " 0.000000\n", - " 0.004302\n", - " 0.002459\n", - " 0.000000\n", - " 0.004302\n", - " 0.002459\n", " 0.012293\n", - " ...\n", - " 0.001229\n", " 0.000000\n", " 0.000000\n", " 0.001229\n", - " 0\n", - " 0.000000\n", + " 0.001229\n", " 0.000000\n", " 0.000000\n", " 0.006146\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.001229\n", + " 0.001844\n", + " 0.000615\n", + " 0.002459\n", " 0.004302\n", + " 0.000000\n", + " 1.000615\n", + " 0.000000\n", " \n", " \n", " 15 \n", " ocaml\n", " (* The Computer Language Benchmarks Game\\n * h...\n", - " 2251\n", + " 0.009773\n", " 0.000000\n", - " 0.006219\n", - " 0.004887\n", " 0.000000\n", - " 0.006219\n", - " 0.004887\n", - " 0.009773\n", - " ...\n", + " 0.000888\n", " 0.002665\n", " 0.000000\n", " 0.000000\n", - " 0.000888\n", - " 0\n", + " 0.004442\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000888\n", + " 0.001333\n", + " 0.000444\n", + " 0.004887\n", + " 0.006219\n", " 0.000000\n", - " 0.004442\n", - " 0.003110\n", + " 1.000444\n", + " 0.000888\n", " \n", " \n", " 16 \n", " ocaml\n", " (* The Computer Language Benchmarks Game\\n * h...\n", - " 1373\n", - " 0.000000\n", - " 0.005098\n", - " 0.004370\n", - " 0.000000\n", - " 0.005098\n", - " 0.004370\n", " 0.010925\n", - " ...\n", - " 0.000728\n", " 0.000000\n", " 0.000000\n", " 0.000728\n", - " 0\n", - " 0.000000\n", + " 0.000728\n", " 0.000000\n", " 0.000000\n", " 0.007283\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.001457\n", + " 0.002185\n", + " 0.000728\n", + " 0.004370\n", " 0.005098\n", + " 0.000000\n", + " 1.000728\n", + " 0.001457\n", " \n", " \n", " 17 \n", " perl\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 1341\n", " 0.000000\n", - " 0.013423\n", - " 0.013423\n", " 0.000000\n", - " 0.013423\n", - " 0.013423\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000746\n", - " 0.000000\n", - " 0\n", " 0.000746\n", + " 0.010440\n", + " ...\n", " 0.000000\n", " 0.000000\n", - " 0.010440\n", + " 0.001491\n", + " 0.000000\n", + " 0.000746\n", + " 0.013423\n", + " 0.013423\n", + " 0.000000\n", + " 1.000746\n", " 0.000000\n", " \n", " \n", " 18 \n", " perl\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 2099\n", " 0.000000\n", - " 0.015722\n", - " 0.014293\n", - " 0.000000\n", - " 0.015722\n", - " 0.014293\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000476\n", " 0.000000\n", - " 0\n", " 0.001906\n", + " 0.000476\n", + " 0.007623\n", + " ...\n", " 0.000000\n", " 0.000953\n", - " 0.007623\n", + " 0.000953\n", + " 0.000000\n", + " 0.000476\n", + " 0.014293\n", + " 0.015722\n", + " 0.000000\n", + " 1.000476\n", " 0.000000\n", " \n", " \n", " 19 \n", " php\n", " <?php \\n/* The Computer Language Benchmarks Ga...\n", - " 1578\n", " 0.000000\n", - " 0.022180\n", - " 0.009506\n", " 0.000000\n", - " 0.022180\n", - " 0.009506\n", " 0.000000\n", - " ...\n", " 0.001267\n", - " 0.000000\n", - " 0.000000\n", " 0.001267\n", - " 0\n", " 0.001901\n", " 0.000000\n", - " 0.000000\n", " 0.004436\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.001267\n", + " 0.001901\n", + " 0.000634\n", + " 0.009506\n", + " 0.022180\n", " 0.000000\n", + " 1.000634\n", + " 0.000634\n", " \n", " \n", " 20 \n", " php\n", " <?php \\n/* The Computer Language Benchmarks Ga...\n", - " 1442\n", " 0.000000\n", - " 0.017337\n", - " 0.009709\n", " 0.000000\n", - " 0.017337\n", - " 0.009709\n", " 0.000000\n", - " ...\n", " 0.001387\n", + " 0.001387\n", + " 0.000693\n", + " 0.000000\n", + " 0.009015\n", + " ...\n", " 0.000000\n", " 0.000000\n", " 0.001387\n", - " 0\n", + " 0.002080\n", " 0.000693\n", + " 0.009709\n", + " 0.017337\n", " 0.000000\n", - " 0.000000\n", - " 0.009015\n", + " 1.000693\n", " 0.000000\n", " \n", " \n", " 21 \n", " php\n", " <?php \\n/* The Computer Language Benchmarks Ga...\n", - " 1476\n", " 0.000000\n", - " 0.018970\n", - " 0.012873\n", " 0.000000\n", - " 0.018970\n", - " 0.012873\n", " 0.000000\n", - " ...\n", " 0.001355\n", - " 0.000000\n", - " 0.000000\n", " 0.001355\n", - " 0\n", " 0.002033\n", " 0.000000\n", - " 0.000000\n", " 0.004743\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.001355\n", + " 0.002033\n", + " 0.000678\n", + " 0.012873\n", + " 0.018970\n", " 0.000000\n", + " 1.000678\n", + " 0.000678\n", " \n", " \n", " 22 \n", " php\n", " <?php \\n/* The Computer Language Benchmarks Ga...\n", - " 3880\n", - " 0.000000\n", - " 0.027320\n", - " 0.015206\n", " 0.000000\n", - " 0.027320\n", - " 0.015206\n", + " 0.000258\n", " 0.000000\n", - " ...\n", " 0.000515\n", - " 0.000000\n", - " 0.000000\n", " 0.000515\n", - " 0\n", " 0.001289\n", " 0.000000\n", - " 0.000000\n", " 0.003866\n", + " ...\n", " 0.000000\n", + " 0.000000\n", + " 0.000515\n", + " 0.000773\n", + " 0.000258\n", + " 0.015206\n", + " 0.027320\n", + " 0.001289\n", + " 1.000258\n", + " 0.001031\n", " \n", " \n", " 23 \n", " python\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 1796\n", " 0.000000\n", + " 0.000557\n", " 0.000000\n", - " 0.017261\n", + " 0.000557\n", + " 0.000557\n", + " 0.002784\n", + " 0.002784\n", + " 0.007238\n", + " ...\n", " 0.000000\n", " 0.000000\n", - " 0.017261\n", + " 0.001114\n", " 0.000000\n", - " ...\n", " 0.000557\n", + " 0.017261\n", " 0.000000\n", - " 0.002784\n", - " 0.000557\n", - " 0\n", - " 0.002784\n", " 0.000000\n", + " 1.000557\n", " 0.000000\n", - " 0.007238\n", - " 0.005568\n", " \n", " \n", " 24 \n", " scheme\n", " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 1716\n", - " 0.000000\n", - " 0.008159\n", + " 0.002914\n", " 0.000000\n", " 0.000000\n", - " 0.008159\n", " 0.000000\n", - " 0.002914\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.004079\n", + " 0.005828\n", + " ...\n", + " 0.004079\n", " 0.000000\n", - " 0\n", + " 0.001166\n", + " 0.001748\n", + " 0.000583\n", " 0.000000\n", - " 0.004079\n", + " 0.008159\n", + " 0.000000\n", + " 1.000583\n", " 0.000000\n", - " 0.005828\n", - " 0.004079\n", " \n", " \n", " 25 \n", " scheme\n", " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 2071\n", - " 0.000000\n", - " 0.005794\n", + " 0.003380\n", " 0.000000\n", " 0.000000\n", - " 0.005794\n", " 0.000000\n", - " 0.003380\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.005311\n", + " 0.003863\n", + " ...\n", + " 0.005311\n", " 0.000000\n", - " 0\n", + " 0.000966\n", + " 0.001449\n", + " 0.000483\n", " 0.000000\n", - " 0.005311\n", + " 0.005794\n", + " 0.000000\n", + " 1.000483\n", " 0.000000\n", - " 0.003863\n", - " 0.005311\n", " \n", " \n", " 26 \n", " scheme\n", " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 2711\n", - " 0.000000\n", - " 0.004426\n", + " 0.001107\n", " 0.000000\n", " 0.000000\n", - " 0.004426\n", " 0.000000\n", - " 0.001107\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.009222\n", + " 0.002951\n", + " ...\n", + " 0.009222\n", " 0.000000\n", - " 0\n", + " 0.000738\n", + " 0.001107\n", + " 0.000369\n", " 0.000000\n", - " 0.009222\n", + " 0.004426\n", " 0.000000\n", - " 0.002951\n", - " 0.004795\n", + " 1.000369\n", + " 0.000369\n", " \n", " \n", " 27 \n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 1554\n", " 0.000000\n", + " 0.001931\n", " 0.000000\n", - " 0.018018\n", " 0.000000\n", " 0.000000\n", - " 0.018018\n", " 0.000000\n", + " 0.004505\n", + " 0.001931\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.004505\n", - " 0.000000\n", - " 0\n", + " 0.001287\n", " 0.000000\n", + " 0.000644\n", + " 0.018018\n", " 0.000000\n", " 0.000000\n", - " 0.001931\n", + " 1.000644\n", " 0.000000\n", " \n", " \n", " 28 \n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 1645\n", " 0.000000\n", " 0.000608\n", - " 0.015805\n", " 0.000000\n", - " 0.000608\n", - " 0.015805\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.003647\n", + " 0.003040\n", + " ...\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " 0.001216\n", " 0.000000\n", + " 0.000608\n", + " 0.015805\n", + " 0.000608\n", " 0.000000\n", - " 0.003040\n", + " 1.000608\n", " 0.000000\n", " \n", " \n", " 29 \n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 1310\n", " 0.000000\n", " 0.000000\n", - " 0.016794\n", - " 0.000000\n", " 0.000000\n", - " 0.016794\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.003053\n", + " 0.002290\n", + " ...\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " 0.001527\n", + " 0.000000\n", + " 0.000763\n", + " 0.016794\n", " 0.000000\n", " 0.000000\n", - " 0.002290\n", + " 1.000763\n", " 0.000000\n", " \n", " \n", @@ -1689,488 +1565,488 @@ " 356\n", " python\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 1444\n", " 0.000000\n", " 0.000000\n", - " 0.009003\n", " 0.000000\n", " 0.000000\n", - " 0.009003\n", " 0.000000\n", - " ...\n", + " 0.004155\n", + " 0.004848\n", " 0.000000\n", + " ...\n", " 0.000000\n", - " 0.004848\n", " 0.000000\n", - " 0\n", - " 0.004155\n", + " 0.001385\n", " 0.000000\n", + " 0.000693\n", + " 0.009003\n", " 0.000000\n", " 0.000000\n", + " 1.000693\n", " 0.000000\n", " \n", " \n", " 357\n", " python\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 1264\n", " 0.000000\n", " 0.000000\n", - " 0.005538\n", " 0.000000\n", " 0.000000\n", - " 0.005538\n", " 0.000000\n", - " ...\n", + " 0.003165\n", + " 0.003956\n", " 0.000000\n", + " ...\n", " 0.000000\n", - " 0.003956\n", " 0.000000\n", - " 0\n", - " 0.003165\n", + " 0.001582\n", " 0.000000\n", + " 0.000791\n", + " 0.005538\n", " 0.000000\n", " 0.000000\n", + " 1.000791\n", " 0.000000\n", " \n", " \n", " 358\n", " python\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 1666\n", " 0.000000\n", " 0.000000\n", - " 0.011405\n", " 0.000000\n", " 0.000000\n", - " 0.011405\n", + " 0.000000\n", + " 0.000600\n", + " 0.003001\n", " 0.000000\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.003001\n", + " 0.001200\n", " 0.000000\n", - " 0\n", " 0.000600\n", + " 0.011405\n", " 0.000000\n", " 0.000000\n", - " 0.000000\n", + " 1.000600\n", " 0.000000\n", " \n", " \n", " 359\n", " scheme\n", " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 1842\n", + " 0.002172\n", " 0.000000\n", - " 0.014115\n", - " 0.000543\n", " 0.000000\n", - " 0.014115\n", - " 0.000543\n", - " 0.002172\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000543\n", " 0.002714\n", " 0.000000\n", - " 0\n", - " 0.000543\n", + " ...\n", " 0.002714\n", " 0.000000\n", + " 0.001086\n", + " 0.000543\n", + " 0.000543\n", + " 0.000543\n", + " 0.014115\n", " 0.000000\n", - " 0.001629\n", + " 1.000543\n", + " 0.001086\n", " \n", " \n", " 360\n", " scheme\n", " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 2104\n", + " 0.001901\n", " 0.000000\n", - " 0.013308\n", - " 0.000475\n", " 0.000000\n", - " 0.013308\n", - " 0.000475\n", - " 0.001901\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000475\n", " 0.002376\n", " 0.000000\n", - " 0\n", - " 0.000475\n", + " ...\n", " 0.002376\n", " 0.000000\n", + " 0.000951\n", + " 0.000475\n", + " 0.000475\n", + " 0.000475\n", + " 0.013308\n", " 0.000000\n", - " 0.001901\n", + " 1.000475\n", + " 0.000951\n", " \n", " \n", " 361\n", " scheme\n", " #lang racket/base\\n;; The Computer Language Be...\n", - " 2071\n", + " 0.003863\n", " 0.000000\n", - " 0.004829\n", " 0.000000\n", " 0.000000\n", - " 0.004829\n", " 0.000000\n", - " 0.003863\n", - " ...\n", " 0.000000\n", + " 0.005311\n", " 0.000000\n", + " ...\n", " 0.005311\n", " 0.000000\n", - " 0\n", + " 0.000966\n", " 0.000000\n", - " 0.005311\n", + " 0.000483\n", " 0.000000\n", + " 0.004829\n", " 0.000000\n", - " 0.001931\n", + " 1.000483\n", + " 0.000966\n", " \n", " \n", " 362\n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 1196\n", - " 0.000000\n", - " 0.000836\n", - " 0.015050\n", " 0.000000\n", - " 0.000836\n", - " 0.015050\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", - " 0.002508\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " 0.002508\n", " 0.000000\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.001672\n", + " 0.000836\n", + " 0.000836\n", + " 0.015050\n", + " 0.000836\n", + " 0.000836\n", + " 1.000836\n", " 0.000000\n", " \n", " \n", " 363\n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 2433\n", - " 0.000000\n", - " 0.000000\n", - " 0.009453\n", " 0.000000\n", + " 0.002877\n", " 0.000000\n", - " 0.009453\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.002877\n", " 0.000000\n", - " 0\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000822\n", + " 0.000000\n", + " 0.000411\n", + " 0.009453\n", " 0.000000\n", " 0.000000\n", + " 1.000411\n", " 0.000000\n", " \n", " \n", " 364\n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 4040\n", - " 0.000000\n", - " 0.000000\n", - " 0.009406\n", - " 0.000000\n", - " 0.000000\n", - " 0.009406\n", " 0.000248\n", - " ...\n", " 0.000248\n", " 0.000000\n", - " 0.002475\n", " 0.000248\n", - " 0\n", " 0.000248\n", + " 0.000248\n", + " 0.002475\n", + " 0.000000\n", + " ...\n", " 0.000000\n", " 0.000495\n", + " 0.000495\n", + " 0.000000\n", + " 0.000248\n", + " 0.009406\n", + " 0.000000\n", " 0.000000\n", + " 1.000248\n", " 0.000000\n", " \n", " \n", " 365\n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 4364\n", - " 0.000000\n", - " 0.000000\n", - " 0.008249\n", - " 0.000000\n", - " 0.000000\n", - " 0.008249\n", " 0.000458\n", - " ...\n", " 0.000229\n", " 0.000000\n", - " 0.002521\n", " 0.000229\n", - " 0\n", " 0.000229\n", + " 0.000229\n", + " 0.002521\n", + " 0.000000\n", + " ...\n", " 0.000000\n", " 0.000687\n", + " 0.000458\n", " 0.000000\n", + " 0.000229\n", + " 0.008249\n", + " 0.000000\n", + " 0.000000\n", + " 1.000229\n", " 0.000000\n", " \n", " \n", " 366\n", " clojure\n", " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 1115\n", - " 0.002691\n", - " 0.008969\n", - " 0.000897\n", - " 0.002691\n", - " 0.008969\n", - " 0.000897\n", " 0.001794\n", - " ...\n", - " 0.000000\n", " 0.002691\n", " 0.002691\n", " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", + " 0.002691\n", + " 0.000000\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.001794\n", " 0.000000\n", + " 0.000897\n", + " 0.000897\n", + " 0.008969\n", + " 0.000897\n", + " 1.000897\n", + " 0.000897\n", " \n", " \n", " 367\n", " clojure\n", " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 951\n", - " 0.000000\n", - " 0.011567\n", " 0.000000\n", - " 0.000000\n", - " 0.011567\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.001052\n", - " 0.003155\n", " 0.004206\n", + " 0.003155\n", + " 0.001052\n", " 0.001052\n", - " 0\n", " 0.001052\n", + " 0.004206\n", + " 0.000000\n", + " ...\n", + " 0.000000\n", " 0.000000\n", + " 0.002103\n", " 0.000000\n", + " 0.001052\n", " 0.000000\n", + " 0.011567\n", + " 0.001052\n", + " 1.001052\n", " 0.000000\n", " \n", " \n", " 368\n", " haskell\n", " -- The Computer Language Benchmarks Game\\n-- h...\n", - " 870\n", - " 0.000000\n", " 0.000000\n", - " 0.001149\n", " 0.000000\n", " 0.000000\n", - " 0.001149\n", " 0.000000\n", - " ...\n", " 0.000000\n", + " 0.001149\n", " 0.000000\n", " 0.000000\n", + " ...\n", " 0.000000\n", - " 0\n", " 0.001149\n", + " 0.002299\n", " 0.000000\n", " 0.001149\n", + " 0.001149\n", + " 0.000000\n", " 0.000000\n", + " 1.001149\n", " 0.001149\n", " \n", " \n", " 369\n", " java\n", " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 2229\n", - " 0.000000\n", - " 0.018394\n", - " 0.000897\n", " 0.000000\n", - " 0.018394\n", " 0.000897\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000897\n", " 0.000000\n", " 0.000000\n", - " 0\n", - " 0.000897\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000897\n", " 0.000000\n", + " 0.000449\n", + " 0.000897\n", + " 0.018394\n", " 0.000000\n", + " 1.000449\n", + " 0.000449\n", " \n", " \n", " 370\n", " java\n", " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 1666\n", - " 0.000000\n", - " 0.017407\n", - " 0.001801\n", " 0.000000\n", - " 0.017407\n", - " 0.001801\n", + " 0.000600\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000600\n", " 0.000000\n", " 0.000000\n", - " 0\n", - " 0.000600\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.001200\n", " 0.000000\n", + " 0.000600\n", + " 0.001801\n", + " 0.017407\n", " 0.000000\n", + " 1.000600\n", + " 0.000600\n", " \n", " \n", " 371\n", " java\n", " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 3934\n", " 0.000000\n", - " 0.014743\n", - " 0.002542\n", + " 0.001525\n", " 0.000000\n", - " 0.014743\n", - " 0.002542\n", " 0.000000\n", - " ...\n", + " 0.000000\n", + " 0.000508\n", " 0.000000\n", " 0.000000\n", + " ...\n", " 0.000000\n", " 0.000000\n", - " 0\n", " 0.000508\n", " 0.000000\n", + " 0.000254\n", + " 0.002542\n", + " 0.014743\n", " 0.000000\n", - " 0.000000\n", + " 1.000254\n", " 0.000000\n", " \n", " \n", " 372\n", " java\n", " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 1330\n", - " 0.000000\n", - " 0.015038\n", " 0.000000\n", " 0.000000\n", - " 0.015038\n", " 0.000000\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.001504\n", " 0.000000\n", + " 0.000752\n", " 0.000000\n", + " 0.015038\n", " 0.000000\n", + " 1.000752\n", + " 0.000752\n", " \n", " \n", " 373\n", " java\n", " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 2536\n", " 0.000000\n", - " 0.011435\n", - " 0.001577\n", + " 0.001183\n", " 0.000000\n", - " 0.011435\n", - " 0.001577\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000789\n", " 0.000000\n", + " 0.000394\n", + " 0.001577\n", + " 0.011435\n", " 0.000000\n", + " 1.000394\n", " 0.000000\n", " \n", " \n", " 374\n", " java\n", " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 1598\n", - " 0.000000\n", - " 0.019399\n", " 0.000000\n", + " 0.000626\n", " 0.000000\n", - " 0.019399\n", " 0.000000\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " ...\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " 0.001252\n", " 0.000000\n", + " 0.000626\n", " 0.000000\n", + " 0.019399\n", " 0.000000\n", + " 1.000626\n", " 0.000000\n", " \n", " \n", " 375\n", " ruby\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 919\n", " 0.000000\n", + " 0.010881\n", " 0.000000\n", - " 0.001088\n", - " 0.000000\n", - " 0.000000\n", - " 0.001088\n", " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.004353\n", " 0.000000\n", - " 0\n", + " ...\n", + " 0.000000\n", " 0.000000\n", + " 0.002176\n", " 0.000000\n", + " 0.001088\n", + " 0.001088\n", " 0.000000\n", " 0.000000\n", + " 1.001088\n", " 0.000000\n", " \n", " \n", " 376\n", " ruby\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 592\n", " 0.000000\n", + " 0.010135\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", @@ -2180,517 +2056,497 @@ " ...\n", " 0.000000\n", " 0.000000\n", + " 0.003378\n", " 0.000000\n", - " 0.000000\n", - " 0\n", - " 0.000000\n", + " 0.001689\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 1.001689\n", " 0.000000\n", " \n", " \n", " 377\n", " ocaml\n", " (* The Computer Language Benchmarks Game\\n * h...\n", - " 689\n", - " 0.000000\n", - " 0.005806\n", - " 0.000000\n", + " 0.011611\n", + " 0.002903\n", " 0.000000\n", - " 0.005806\n", " 0.000000\n", - " 0.011611\n", - " ...\n", " 0.002903\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", + " ...\n", + " 0.000000\n", " 0.000000\n", + " 0.002903\n", " 0.000000\n", + " 0.001451\n", " 0.000000\n", + " 0.005806\n", " 0.000000\n", + " 1.001451\n", " 0.000000\n", " \n", " \n", " 378\n", " ocaml\n", " (* The Computer Language Benchmarks Game\\n * h...\n", - " 848\n", + " 0.010613\n", " 0.000000\n", - " 0.014151\n", - " 0.002358\n", " 0.000000\n", - " 0.014151\n", - " 0.002358\n", - " 0.010613\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.002358\n", " 0.000000\n", + " 0.001179\n", + " 0.002358\n", + " 0.014151\n", " 0.000000\n", + " 1.001179\n", + " 0.002358\n", " \n", " \n", " 379\n", " ocaml\n", " (* The Computer Language Benchmarks Game\\n * h...\n", - " 733\n", + " 0.010914\n", + " 0.000000\n", " 0.000000\n", - " 0.012278\n", - " 0.002729\n", " 0.000000\n", - " 0.012278\n", - " 0.002729\n", - " 0.010914\n", - " ...\n", " 0.001364\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.002729\n", " 0.000000\n", + " 0.001364\n", + " 0.002729\n", + " 0.012278\n", " 0.000000\n", + " 1.001364\n", " 0.000000\n", " \n", " \n", " 380\n", " perl\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 940\n", " 0.000000\n", - " 0.029787\n", - " 0.001064\n", " 0.000000\n", - " 0.029787\n", - " 0.001064\n", " 0.000000\n", - " ...\n", - " 0.002128\n", " 0.000000\n", + " 0.002128\n", " 0.000000\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " ...\n", " 0.000000\n", " 0.004255\n", + " 0.002128\n", " 0.000000\n", + " 0.001064\n", + " 0.001064\n", + " 0.029787\n", + " 0.001064\n", + " 1.001064\n", " 0.000000\n", " \n", " \n", " 381\n", " perl\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 2381\n", + " 0.000420\n", + " 0.000840\n", " 0.000000\n", - " 0.012180\n", - " 0.004200\n", " 0.000000\n", - " 0.012180\n", - " 0.004200\n", - " 0.000420\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000840\n", " 0.000000\n", - " 0\n", - " 0.000000\n", + " ...\n", " 0.000420\n", " 0.001260\n", + " 0.000840\n", " 0.000000\n", " 0.000420\n", + " 0.004200\n", + " 0.012180\n", + " 0.000840\n", + " 1.000420\n", + " 0.000000\n", " \n", " \n", " 382\n", " python\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 957\n", - " 0.000000\n", " 0.000000\n", - " 0.006270\n", " 0.000000\n", " 0.000000\n", - " 0.006270\n", " 0.000000\n", - " ...\n", " 0.002090\n", " 0.000000\n", " 0.001045\n", " 0.000000\n", - " 0\n", + " ...\n", + " 0.000000\n", " 0.000000\n", + " 0.002090\n", " 0.000000\n", + " 0.001045\n", + " 0.006270\n", " 0.000000\n", " 0.000000\n", + " 1.001045\n", " 0.000000\n", " \n", " \n", " 383\n", " python\n", " # The Computer Language Benchmarks Game\\n# htt...\n", - " 821\n", - " 0.000000\n", - " 0.000000\n", - " 0.003654\n", " 0.000000\n", + " 0.006090\n", " 0.000000\n", - " 0.003654\n", " 0.000000\n", - " ...\n", " 0.001218\n", " 0.000000\n", " 0.002436\n", " 0.000000\n", - " 0\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.002436\n", + " 0.000000\n", + " 0.001218\n", + " 0.003654\n", " 0.000000\n", " 0.000000\n", + " 1.001218\n", " 0.000000\n", " \n", " \n", " 384\n", " scheme\n", " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 767\n", - " 0.000000\n", - " 0.027379\n", - " 0.000000\n", + " 0.003911\n", + " 0.002608\n", " 0.000000\n", - " 0.027379\n", " 0.000000\n", - " 0.003911\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.001304\n", " 0.000000\n", - " 0\n", + " ...\n", + " 0.001304\n", " 0.000000\n", + " 0.002608\n", + " 0.001304\n", " 0.001304\n", " 0.000000\n", + " 0.027379\n", " 0.000000\n", + " 1.001304\n", " 0.000000\n", " \n", " \n", " 385\n", " scala\n", " /* The Computer Language Benchmarks Game\\n h...\n", - " 707\n", " 0.000000\n", " 0.001414\n", " 0.000000\n", " 0.000000\n", - " 0.001414\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.002829\n", " 0.000000\n", - " 0\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.002829\n", " 0.000000\n", + " 0.001414\n", " 0.000000\n", + " 0.001414\n", " 0.000000\n", + " 1.001414\n", + " 0.002829\n", " \n", " \n", "\n", - "

386 rows \u00d7 21 columns

\n", + "

386 rows \u00d7 23 columns

\n", "" ], "metadata": {}, "output_type": "pyout", - "prompt_number": 159, + "prompt_number": 199, "text": [ - " Language Code \\\n", - "0 clojure ;; The Computer Language Benchmarks Game\\n;; h... \n", - "1 clojure ;; The Computer Language Benchmarks Game\\n;; h... \n", - "2 clojure ;; The Computer Language Benchmarks Game\\n;; h... \n", - "3 haskell --\\n-- The Computer Language Benchmarks Game\\n... \n", - "4 haskell --\\n-- The Computer Language Benchmarks Game\\n... \n", - "5 haskell --\\n-- The Computer Language Benchmarks Game\\n... \n", - "6 java /* The Computer Language Benchmarks Game\\n h... \n", - "7 java /* The Computer Language Benchmarks Game\\n h... \n", - "8 java /* The Computer Language Benchmarks Game\\n * h... \n", - "9 javascript /* The Computer Language Benchmarks Game\\n h... \n", - "10 ruby # The Computer Language Shootout Benchmarks\\n#... \n", - "11 ruby # The Computer Language Benchmarks Game\\n# htt... \n", - "12 ruby # The Computer Language Benchmarks Game\\n# htt... \n", - "13 ruby # The Computer Language Benchmarks Game\\n# htt... \n", - "14 ocaml (* The Computer Language Benchmarks Game\\n * h... \n", - "15 ocaml (* The Computer Language Benchmarks Game\\n * h... \n", - "16 ocaml (* The Computer Language Benchmarks Game\\n * h... \n", - "17 perl # The Computer Language Benchmarks Game\\n# htt... \n", - "18 perl # The Computer Language Benchmarks Game\\n# htt... \n", - "19 php '] = df.Code.apply(arrow_ratio)\n", - "test_df['$'] = df.Code.apply(dollar_ratio)\n", - "test_df['printf'] = df.Code.apply(printf_ratio)" + "test_df = tdata_frame_generator()" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 189 + "prompt_number": 203 }, { "cell_type": "code", @@ -2942,25 +2743,25 @@ " \n", " Filename\n", " Language\n", - " Testcode\n", - " code length\n", - " ^\n", - " ;\n", - " ,\n", - " &\n", - " !\n", - " |\n", - " ...\n", + " Code\n", + " let\n", + " end\n", " defn\n", - " def\n", " function\n", - " slice\n", + " fun\n", " return\n", + " def\n", + " ...\n", " define\n", - " doublecolon\n", - " check\n", - " make\n", - " .format\n", + " ::\n", + " $\n", + " printf\n", + " ^\n", + " ,\n", + " ;\n", + " &\n", + " |\n", + " !\n", " \n", " \n", " \n", @@ -2969,95 +2770,95 @@ " 1\n", " clojure\n", " (defn cf-settings\\n \"Setup settings for campf...\n", - " 1137\n", - " 0.003719\n", - " 0.009091\n", - " 0.000826\n", - " 0.003719\n", - " 0.009091\n", - " 0.000826\n", - " ...\n", - " 0.002066\n", - " 0.004545\n", + " 0.001759\n", + " 0.000880\n", + " 0.003518\n", " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", + " 0.003518\n", + " ...\n", " 0.000000\n", - " 0.005372\n", " 0.000000\n", - " 0.001240\n", + " 0.000880\n", + " 0\n", + " 0.000880\n", + " 0.009675\n", + " 0.000000\n", + " 0.000000\n", + " 1.000880\n", + " 0.000000\n", " \n", " \n", " 1 \n", " 2\n", " clojure\n", " var _ = require('lodash'),\\n fs = require('...\n", - " 349\n", - " 0.004241\n", - " 0.008096\n", - " 0.000771\n", - " 0.004241\n", - " 0.008096\n", - " 0.000771\n", + " 0.000000\n", + " 0.000000\n", + " 0.000000\n", + " 0.005731\n", + " 0.005731\n", + " 0.008596\n", + " 0.002865\n", " ...\n", - " 0.001928\n", - " 0.003470\n", " 0.000000\n", - " 0\n", " 0.000000\n", + " 0.005731\n", + " 0\n", + " 0.002865\n", + " 0.011461\n", + " 0.011461\n", " 0.000000\n", + " 1.002865\n", " 0.000000\n", - " 0.005012\n", - " 0.002699\n", - " 0.001157\n", " \n", " \n", " 2 \n", " 3\n", " clojure\n", " /* Riot v2.0.8, @license MIT, (c) 2015 Muut In...\n", - " 17362\n", - " 0.003705\n", - " 0.010104\n", - " 0.001347\n", - " 0.003705\n", - " 0.010104\n", - " 0.001347\n", + " 0.000058\n", + " 0.000864\n", + " 0.000000\n", + " 0.004377\n", + " 0.004435\n", + " 0.002649\n", + " 0.000864\n", " ...\n", - " 0.002021\n", - " 0.003705\n", + " 0.000576\n", " 0.000000\n", + " 0.000058\n", " 0\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.009094\n", - " 0.000000\n", - " 0.001010\n", + " 0.000058\n", + " 0.012844\n", + " 0.000691\n", + " 0.002361\n", + " 1.000058\n", + " 0.001498\n", " \n", " \n", " 3 \n", " 4\n", " clojure\n", " var r = riot.route = function(arg) {\\n //...\n", - " 170\n", " 0.000000\n", - " 0.000618\n", - " 0.006177\n", " 0.000000\n", - " 0.000618\n", - " 0.006177\n", - " ...\n", " 0.000000\n", + " 0.011765\n", + " 0.011765\n", " 0.000000\n", " 0.000000\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.005882\n", " 0\n", + " 0.005882\n", + " 0.005882\n", " 0.000000\n", " 0.000000\n", - " 0.002471\n", - " 0.006794\n", - " 0.005559\n", + " 1.005882\n", " 0.000000\n", " \n", " \n", @@ -3065,23 +2866,23 @@ " 5\n", " python\n", " module ActiveJob\\n module Core\\n extend Ac...\n", - " 3565\n", - " 0.000000\n", - " 0.000529\n", - " 0.005294\n", " 0.000000\n", - " 0.000529\n", - " 0.005294\n", - " ...\n", + " 0.005049\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.000281\n", + " 0.003086\n", + " ...\n", + " 0.000281\n", + " 0.000561\n", + " 0.000281\n", " 0\n", + " 0.000281\n", + " 0.001964\n", " 0.000000\n", - " 0.000000\n", - " 0.002118\n", - " 0.006882\n", - " 0.004764\n", + " 0.000561\n", + " 1.000281\n", " 0.000000\n", " \n", " \n", @@ -3089,23 +2890,23 @@ " 6\n", " python\n", " require 'formula'\\n\\nclass A52dec < Formula\\n ...\n", - " 491\n", " 0.000000\n", - " 0.000573\n", - " 0.005158\n", + " 0.006110\n", " 0.000000\n", - " 0.000573\n", - " 0.005158\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.002037\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.002037\n", " 0\n", + " 0.002037\n", + " 0.010183\n", " 0.000000\n", " 0.000000\n", - " 0.002292\n", - " 0.007450\n", - " 0.005158\n", + " 1.002037\n", " 0.000000\n", " \n", " \n", @@ -3113,23 +2914,23 @@ " 7\n", " python\n", " module Fluent\\n class Input\\n include Conf...\n", - " 490\n", " 0.000000\n", - " 0.016208\n", - " 0.001719\n", + " 0.014286\n", " 0.000000\n", - " 0.016208\n", - " 0.001719\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.008163\n", + " ...\n", + " 0.000000\n", + " 0.000000\n", + " 0.002041\n", " 0\n", - " 0.000737\n", + " 0.002041\n", " 0.000000\n", " 0.000000\n", - " 0.002947\n", " 0.000000\n", + " 1.002041\n", " 0.000000\n", " \n", " \n", @@ -3137,23 +2938,23 @@ " 8\n", " python\n", " {-# LANGUAGE ScopedTypeVariables, FlexibleInst...\n", - " 15305\n", - " 0.000000\n", - " 0.013258\n", - " 0.005682\n", + " 0.000131\n", + " 0.000196\n", " 0.000000\n", - " 0.013258\n", - " 0.005682\n", - " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000523\n", + " 0.000261\n", + " ...\n", " 0.000000\n", + " 0.000915\n", + " 0.000065\n", " 0\n", - " 0.001894\n", - " 0.000000\n", - " 0.000000\n", - " 0.004261\n", + " 0.000065\n", + " 0.013264\n", + " 0.000261\n", " 0.000000\n", + " 1.000065\n", " 0.000000\n", " \n", " \n", @@ -3161,23 +2962,23 @@ " 9\n", " javascript\n", " reverseDependencies :: ModuleGraph -> M.Map Mo...\n", - " 310\n", " 0.000000\n", - " 0.014372\n", - " 0.004636\n", + " 0.006452\n", " 0.000000\n", - " 0.014372\n", - " 0.004636\n", - " ...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0\n", - " 0.001391\n", " 0.000000\n", + " ...\n", " 0.000000\n", - " 0.006027\n", + " 0.006452\n", + " 0.003226\n", + " 0\n", + " 0.003226\n", + " 0.012903\n", " 0.000000\n", + " 0.009677\n", + " 1.003226\n", " 0.000000\n", " \n", " \n", @@ -3185,23 +2986,23 @@ " 10\n", " javascript\n", " {- git-annex extra config files\\n -\\n - Copyri...\n", - " 2036\n", + " 0.000491\n", " 0.000000\n", - " 0.017544\n", - " 0.010234\n", " 0.000000\n", - " 0.017544\n", - " 0.010234\n", - " ...\n", " 0.000000\n", + " 0.000982\n", + " 0.001473\n", + " 0.000491\n", + " ...\n", " 0.000000\n", - " 0.002193\n", + " 0.003929\n", + " 0.000491\n", " 0\n", - " 0.002924\n", - " 0.000000\n", - " 0.000000\n", - " 0.006579\n", + " 0.000491\n", + " 0.001965\n", + " 0.000491\n", " 0.000000\n", + " 1.000491\n", " 0.000000\n", " \n", " \n", @@ -3209,23 +3010,23 @@ " 11\n", " javascript\n", " (define subst-f\\n (lambda (new old l)\\n (c...\n", - " 386\n", " 0.000000\n", " 0.000000\n", - " 0.011236\n", " 0.000000\n", + " 0.002591\n", + " 0.002591\n", " 0.000000\n", - " 0.011236\n", + " 0.007772\n", " ...\n", + " 0.007772\n", " 0.000000\n", - " 0.001605\n", - " 0.000000\n", + " 0.002591\n", " 0\n", - " 0.001605\n", + " 0.002591\n", " 0.000000\n", + " 0.010363\n", " 0.000000\n", - " 0.011236\n", - " 0.000000\n", + " 1.002591\n", " 0.000000\n", " \n", " \n", @@ -3233,23 +3034,23 @@ " 12\n", " javascript\n", " (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p...\n", - " 203\n", " 0.000000\n", - " 0.001403\n", - " 0.011921\n", " 0.000000\n", - " 0.001403\n", - " 0.011921\n", + " 0.009852\n", + " 0.000000\n", + " 0.000000\n", + " 0.000000\n", + " 0.009852\n", " ...\n", " 0.000000\n", - " 0.001403\n", " 0.000000\n", + " 0.004926\n", " 0\n", - " 0.001403\n", + " 0.004926\n", " 0.000000\n", " 0.000000\n", - " 0.009818\n", - " 0.000000\n", + " 0.009852\n", + " 1.004926\n", " 0.000000\n", " \n", " \n", @@ -3257,23 +3058,23 @@ " 13\n", " ruby\n", " (define add1\\n (lambda (n) (+ n 1)))\n", - " 36\n", " 0.000000\n", " 0.000000\n", - " 0.011876\n", " 0.000000\n", " 0.000000\n", - " 0.011876\n", - " ...\n", " 0.000000\n", - " 0.001584\n", " 0.000000\n", - " 0\n", + " 0.027778\n", + " ...\n", + " 0.027778\n", " 0.000000\n", + " 0.027778\n", + " 0\n", + " 0.027778\n", " 0.000000\n", " 0.000000\n", - " 0.011085\n", " 0.000000\n", + " 1.027778\n", " 0.000000\n", " \n", " \n", @@ -3281,47 +3082,47 @@ " 14\n", " ruby\n", " (define-lib-primitive (length lst)\\n (if (nul...\n", - " 6712\n", - " 0.000218\n", - " 0.000000\n", - " 0.011324\n", - " 0.000218\n", + " 0.001341\n", " 0.000000\n", - " 0.011324\n", - " ...\n", " 0.000000\n", - " 0.002395\n", " 0.000000\n", - " 0\n", " 0.000000\n", " 0.000000\n", + " 0.007449\n", + " ...\n", + " 0.007449\n", " 0.000000\n", - " 0.005444\n", + " 0.000149\n", + " 0\n", + " 0.000149\n", " 0.000000\n", + " 0.000298\n", " 0.000000\n", + " 1.000149\n", + " 0.002086\n", " \n", " \n", " 14\n", " 15\n", " ruby\n", " /**\\n * Interface to represent a persistence s...\n", - " 2107\n", + " 0.001424\n", " 0.000000\n", - " 0.004302\n", - " 0.002459\n", " 0.000000\n", - " 0.004302\n", - " 0.002459\n", - " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001229\n", - " 0\n", + " 0.001898\n", + " 0.000949\n", + " ...\n", " 0.000000\n", " 0.000000\n", + " 0.000475\n", + " 0\n", + " 0.000475\n", + " 0.000949\n", + " 0.003322\n", " 0.000000\n", - " 0.006146\n", - " 0.004302\n", + " 1.000475\n", " 0.000000\n", " \n", " \n", @@ -3329,23 +3130,23 @@ " 16\n", " haskell\n", " /*\\n * Copyright 2002-2008 the original author...\n", - " 1826\n", " 0.000000\n", - " 0.006219\n", - " 0.004887\n", " 0.000000\n", - " 0.006219\n", - " 0.004887\n", - " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000888\n", - " 0\n", " 0.000000\n", + " 0.001095\n", + " 0.001095\n", + " ...\n", + " 0.001095\n", " 0.000000\n", + " 0.000548\n", + " 0\n", + " 0.000548\n", + " 0.004381\n", + " 0.003286\n", " 0.000000\n", - " 0.004442\n", - " 0.003110\n", + " 1.000548\n", " 0.000000\n", " \n", " \n", @@ -3353,23 +3154,23 @@ " 17\n", " haskell\n", " package com.github.pathikrit\\n\\nimport scala.a...\n", - " 2796\n", " 0.000000\n", - " 0.005098\n", - " 0.004370\n", + " 0.003219\n", " 0.000000\n", - " 0.005098\n", - " 0.004370\n", - " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000728\n", - " 0\n", " 0.000000\n", + " 0.001788\n", + " ...\n", + " 0.000000\n", + " 0.001073\n", + " 0.000358\n", + " 0\n", + " 0.000358\n", + " 0.005007\n", " 0.000000\n", " 0.000000\n", - " 0.007283\n", - " 0.005098\n", + " 1.000358\n", " 0.000000\n", " \n", " \n", @@ -3377,23 +3178,23 @@ " 18\n", " haskell\n", " /* sbt -- Simple Build Tool\\n * Copyright 2010...\n", - " 1917\n", " 0.000000\n", - " 0.013423\n", - " 0.013423\n", + " 0.001565\n", " 0.000000\n", - " 0.013423\n", - " 0.013423\n", + " 0.000000\n", + " 0.000000\n", + " 0.000000\n", + " 0.004173\n", " ...\n", " 0.000000\n", - " 0.000746\n", " 0.000000\n", + " 0.000522\n", " 0\n", - " 0.000746\n", + " 0.000522\n", + " 0.001043\n", " 0.000000\n", " 0.000000\n", - " 0.010440\n", - " 0.000000\n", + " 1.000522\n", " 0.000000\n", " \n", " \n", @@ -3401,71 +3202,71 @@ " 19\n", " scheme\n", " class View\\n{\\n /**\\n * Data available ...\n", - " 6648\n", " 0.000000\n", - " 0.015722\n", - " 0.014293\n", + " 0.001805\n", " 0.000000\n", - " 0.015722\n", - " 0.014293\n", - " ...\n", + " 0.002557\n", + " 0.002708\n", + " 0.002407\n", " 0.000000\n", - " 0.000476\n", + " ...\n", " 0.000000\n", + " 0.000301\n", + " 0.000150\n", " 0\n", - " 0.001906\n", - " 0.000000\n", - " 0.000953\n", - " 0.007623\n", - " 0.000000\n", - " 0.000000\n", + " 0.000150\n", + " 0.002858\n", + " 0.004964\n", + " 0.000602\n", + " 1.000150\n", + " 0.000903\n", " \n", " \n", " 19\n", " 20\n", " scheme\n", " public function formatLocalized($format)\\n...\n", - " 339\n", - " 0.000000\n", - " 0.022180\n", - " 0.009506\n", " 0.000000\n", - " 0.022180\n", - " 0.009506\n", - " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001267\n", - " 0\n", - " 0.001901\n", + " 0.002950\n", + " 0.002950\n", + " 0.002950\n", " 0.000000\n", + " ...\n", " 0.000000\n", - " 0.004436\n", " 0.000000\n", + " 0.002950\n", + " 0\n", + " 0.002950\n", + " 0.014749\n", + " 0.005900\n", " 0.000000\n", + " 1.002950\n", + " 0.002950\n", " \n", " \n", " 20\n", " 21\n", " scheme\n", " (extend-type String\\n Person\\n (first-name [...\n", - " 143\n", " 0.000000\n", - " 0.017337\n", - " 0.009709\n", + " 0.006993\n", + " 0.000000\n", + " 0.000000\n", + " 0.000000\n", + " 0.000000\n", " 0.000000\n", - " 0.017337\n", - " 0.009709\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001387\n", + " 0.006993\n", " 0\n", - " 0.000693\n", + " 0.006993\n", " 0.000000\n", " 0.000000\n", - " 0.009015\n", " 0.000000\n", + " 1.006993\n", " 0.000000\n", " \n", " \n", @@ -3473,23 +3274,23 @@ " 22\n", " java\n", " class Application extends App {\\n\\t/**\\n\\t * @...\n", - " 1954\n", " 0.000000\n", - " 0.018970\n", - " 0.012873\n", + " 0.000512\n", " 0.000000\n", - " 0.018970\n", - " 0.012873\n", - " ...\n", + " 0.005629\n", + " 0.005629\n", + " 0.005118\n", " 0.000000\n", + " ...\n", " 0.000000\n", - " 0.001355\n", + " 0.001535\n", + " 0.000512\n", " 0\n", - " 0.002033\n", - " 0.000000\n", - " 0.000000\n", - " 0.004743\n", + " 0.000512\n", + " 0.011771\n", + " 0.011259\n", " 0.000000\n", + " 1.000512\n", " 0.000000\n", " \n", " \n", @@ -3497,95 +3298,95 @@ " 23\n", " java\n", " type name = string\\n\\nlet compare_label label1...\n", - " 7562\n", + " 0.005422\n", + " 0.001322\n", " 0.000000\n", - " 0.027320\n", - " 0.015206\n", - " 0.000000\n", - " 0.027320\n", - " 0.015206\n", + " 0.000661\n", + " 0.002248\n", + " 0.000926\n", + " 0.000397\n", " ...\n", " 0.000000\n", - " 0.000000\n", - " 0.000515\n", + " 0.000132\n", + " 0.000132\n", " 0\n", - " 0.001289\n", - " 0.000000\n", - " 0.000000\n", - " 0.003866\n", - " 0.000000\n", + " 0.000132\n", + " 0.006612\n", + " 0.000397\n", " 0.000000\n", + " 1.000132\n", + " 0.000264\n", " \n", " \n", " 23\n", " 24\n", " scala\n", " let search_compiler_libs () =\\n prerr_endline...\n", - " 575\n", + " 0.005217\n", + " 0.003478\n", " 0.000000\n", " 0.000000\n", - " 0.017261\n", + " 0.001739\n", " 0.000000\n", " 0.000000\n", - " 0.017261\n", " ...\n", " 0.000000\n", - " 0.002784\n", - " 0.000557\n", + " 0.000000\n", + " 0.001739\n", " 0\n", - " 0.002784\n", + " 0.001739\n", " 0.000000\n", + " 0.012174\n", " 0.000000\n", - " 0.007238\n", - " 0.005568\n", - " 0.001670\n", + " 1.001739\n", + " 0.001739\n", " \n", " \n", " 24\n", " 25\n", " scala\n", " (require '[overtone.live :as overtone])\\n\\n(de...\n", - " 597\n", + " 0.001675\n", " 0.000000\n", - " 0.008159\n", + " 0.001675\n", " 0.000000\n", " 0.000000\n", - " 0.008159\n", " 0.000000\n", + " 0.003350\n", " ...\n", " 0.000000\n", - " 0.004079\n", " 0.000000\n", + " 0.001675\n", " 0\n", + " 0.001675\n", + " 0.006700\n", + " 0.006700\n", " 0.000000\n", - " 0.004079\n", - " 0.000000\n", - " 0.005828\n", - " 0.004079\n", - " 0.000000\n", + " 1.001675\n", + " 0.001675\n", " \n", " \n", " 25\n", " 28\n", " php\n", " from pkgutil import iter_modules\\nfrom subproc...\n", - " 602\n", " 0.000000\n", - " 0.005794\n", + " 0.004983\n", + " 0.000000\n", + " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.005794\n", " 0.000000\n", " ...\n", " 0.000000\n", - " 0.005311\n", " 0.000000\n", + " 0.001661\n", " 0\n", + " 0.001661\n", + " 0.014950\n", " 0.000000\n", - " 0.005311\n", " 0.000000\n", - " 0.003863\n", - " 0.005311\n", + " 1.001661\n", " 0.000000\n", " \n", " \n", @@ -3593,23 +3394,23 @@ " 29\n", " php\n", " import re\\nimport subprocess\\n\\ndef cmd_keymap...\n", - " 2852\n", " 0.000000\n", - " 0.004426\n", + " 0.001403\n", " 0.000000\n", " 0.000000\n", - " 0.004426\n", " 0.000000\n", + " 0.001403\n", + " 0.001403\n", " ...\n", " 0.000000\n", - " 0.009222\n", " 0.000000\n", + " 0.000351\n", " 0\n", + " 0.000351\n", + " 0.003857\n", " 0.000000\n", - " 0.009222\n", " 0.000000\n", - " 0.002951\n", - " 0.004795\n", + " 1.000351\n", " 0.000000\n", " \n", " \n", @@ -3617,23 +3418,23 @@ " 30\n", " php\n", " class NoSuchService(Exception):\\n def __ini...\n", - " 326\n", " 0.000000\n", " 0.000000\n", - " 0.018018\n", " 0.000000\n", " 0.000000\n", - " 0.018018\n", + " 0.000000\n", + " 0.006135\n", + " 0.012270\n", " ...\n", " 0.000000\n", - " 0.004505\n", " 0.000000\n", + " 0.003067\n", " 0\n", + " 0.003067\n", + " 0.006135\n", " 0.000000\n", " 0.000000\n", - " 0.000000\n", - " 0.001931\n", - " 0.000000\n", + " 1.003067\n", " 0.000000\n", " \n", " \n", @@ -3641,59 +3442,59 @@ " 31\n", " ocaml\n", " from collections import namedtuple\\nimport fun...\n", - " 20265\n", " 0.000000\n", - " 0.000608\n", - " 0.015805\n", + " 0.003158\n", " 0.000000\n", - " 0.000608\n", - " 0.015805\n", + " 0.000000\n", + " 0.000148\n", + " 0.000691\n", + " 0.003059\n", " ...\n", " 0.000000\n", - " 0.003647\n", " 0.000000\n", + " 0.000049\n", " 0\n", + " 0.000049\n", + " 0.014952\n", + " 0.000247\n", " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.003040\n", - " 0.000000\n", - " 0.000000\n", + " 1.000049\n", + " 0.000247\n", " \n", " \n", " 29\n", " 32\n", " ocaml\n", " function errorHandler(context) {\\n return fun...\n", - " 1336\n", " 0.000000\n", " 0.000000\n", - " 0.016794\n", " 0.000000\n", + " 0.008982\n", + " 0.008982\n", + " 0.001497\n", " 0.000000\n", - " 0.016794\n", " ...\n", " 0.000000\n", - " 0.003053\n", " 0.000000\n", + " 0.000749\n", " 0\n", + " 0.000749\n", + " 0.005240\n", + " 0.014222\n", " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.002290\n", - " 0.000000\n", + " 1.000749\n", " 0.000000\n", " \n", " \n", "\n", - "

30 rows \u00d7 23 columns

\n", + "

30 rows \u00d7 24 columns

\n", "" ], "metadata": {}, "output_type": "pyout", - "prompt_number": 173, + "prompt_number": 204, "text": [ - " Filename Language Testcode \\\n", + " Filename Language Code \\\n", "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", "1 2 clojure var _ = require('lodash'),\\n fs = require('... \n", "2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", @@ -3725,227 +3526,2931 @@ "28 31 ocaml from collections import namedtuple\\nimport fun... \n", "29 32 ocaml function errorHandler(context) {\\n return fun... \n", "\n", - " code length ^ ; , & ! | \\\n", - "0 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826 \n", - "1 349 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771 \n", - "2 17362 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347 \n", - "3 170 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177 \n", - "4 3565 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294 \n", - "5 491 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158 \n", - "6 490 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719 \n", - "7 15305 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682 \n", - "8 310 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636 \n", - "9 2036 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234 \n", - "10 386 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236 \n", - "11 203 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921 \n", - "12 36 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876 \n", - "13 6712 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324 \n", - "14 2107 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459 \n", - "15 1826 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887 \n", - "16 2796 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370 \n", - "17 1917 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423 \n", - "18 6648 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293 \n", - "19 339 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506 \n", - "20 143 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709 \n", - "21 1954 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873 \n", - "22 7562 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206 \n", - "23 575 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261 \n", - "24 597 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 \n", - "25 602 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000 \n", - "26 2852 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000 \n", - "27 326 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018 \n", - "28 20265 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805 \n", - "29 1336 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794 \n", + " let end defn function fun return def \\\n", + "0 0.001759 0.000880 0.003518 0.000000 0.000000 0.000000 0.003518 \n", + "1 0.000000 0.000000 0.000000 0.005731 0.005731 0.008596 0.002865 \n", + "2 0.000058 0.000864 0.000000 0.004377 0.004435 0.002649 0.000864 \n", + "3 0.000000 0.000000 0.000000 0.011765 0.011765 0.000000 0.000000 \n", + "4 0.000000 0.005049 0.000000 0.000000 0.000000 0.000281 0.003086 \n", + "5 0.000000 0.006110 0.000000 0.000000 0.000000 0.000000 0.002037 \n", + "6 0.000000 0.014286 0.000000 0.000000 0.000000 0.000000 0.008163 \n", + "7 0.000131 0.000196 0.000000 0.000000 0.000000 0.000523 0.000261 \n", + "8 0.000000 0.006452 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "9 0.000491 0.000000 0.000000 0.000000 0.000982 0.001473 0.000491 \n", + "10 0.000000 0.000000 0.000000 0.002591 0.002591 0.000000 0.007772 \n", + "11 0.000000 0.000000 0.009852 0.000000 0.000000 0.000000 0.009852 \n", + "12 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.027778 \n", + "13 0.001341 0.000000 0.000000 0.000000 0.000000 0.000000 0.007449 \n", + "14 0.001424 0.000000 0.000000 0.000000 0.000000 0.001898 0.000949 \n", + "15 0.000000 0.000000 0.000000 0.000000 0.000000 0.001095 0.001095 \n", + "16 0.000000 0.003219 0.000000 0.000000 0.000000 0.000000 0.001788 \n", + "17 0.000000 0.001565 0.000000 0.000000 0.000000 0.000000 0.004173 \n", + "18 0.000000 0.001805 0.000000 0.002557 0.002708 0.002407 0.000000 \n", + "19 0.000000 0.000000 0.000000 0.002950 0.002950 0.002950 0.000000 \n", + "20 0.000000 0.006993 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "21 0.000000 0.000512 0.000000 0.005629 0.005629 0.005118 0.000000 \n", + "22 0.005422 0.001322 0.000000 0.000661 0.002248 0.000926 0.000397 \n", + "23 0.005217 0.003478 0.000000 0.000000 0.001739 0.000000 0.000000 \n", + "24 0.001675 0.000000 0.001675 0.000000 0.000000 0.000000 0.003350 \n", + "25 0.000000 0.004983 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "26 0.000000 0.001403 0.000000 0.000000 0.000000 0.001403 0.001403 \n", + "27 0.000000 0.000000 0.000000 0.000000 0.000000 0.006135 0.012270 \n", + "28 0.000000 0.003158 0.000000 0.000000 0.000148 0.000691 0.003059 \n", + "29 0.000000 0.000000 0.000000 0.008982 0.008982 0.001497 0.000000 \n", "\n", - " ... defn def function slice return define \\\n", - "0 ... 0.002066 0.004545 0.000000 0 0.000000 0.000000 \n", - "1 ... 0.001928 0.003470 0.000000 0 0.000000 0.000000 \n", - "2 ... 0.002021 0.003705 0.000000 0 0.000000 0.000000 \n", - "3 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", - "4 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", - "5 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", - "6 ... 0.000000 0.000000 0.000000 0 0.000737 0.000000 \n", - "7 ... 0.000000 0.000000 0.000000 0 0.001894 0.000000 \n", - "8 ... 0.000000 0.000000 0.000000 0 0.001391 0.000000 \n", - "9 ... 0.000000 0.000000 0.002193 0 0.002924 0.000000 \n", - "10 ... 0.000000 0.001605 0.000000 0 0.001605 0.000000 \n", - "11 ... 0.000000 0.001403 0.000000 0 0.001403 0.000000 \n", - "12 ... 0.000000 0.001584 0.000000 0 0.000000 0.000000 \n", - "13 ... 0.000000 0.002395 0.000000 0 0.000000 0.000000 \n", - "14 ... 0.000000 0.000000 0.001229 0 0.000000 0.000000 \n", - "15 ... 0.000000 0.000000 0.000888 0 0.000000 0.000000 \n", - "16 ... 0.000000 0.000000 0.000728 0 0.000000 0.000000 \n", - "17 ... 0.000000 0.000746 0.000000 0 0.000746 0.000000 \n", - "18 ... 0.000000 0.000476 0.000000 0 0.001906 0.000000 \n", - "19 ... 0.000000 0.000000 0.001267 0 0.001901 0.000000 \n", - "20 ... 0.000000 0.000000 0.001387 0 0.000693 0.000000 \n", - "21 ... 0.000000 0.000000 0.001355 0 0.002033 0.000000 \n", - "22 ... 0.000000 0.000000 0.000515 0 0.001289 0.000000 \n", - "23 ... 0.000000 0.002784 0.000557 0 0.002784 0.000000 \n", - "24 ... 0.000000 0.004079 0.000000 0 0.000000 0.004079 \n", - "25 ... 0.000000 0.005311 0.000000 0 0.000000 0.005311 \n", - "26 ... 0.000000 0.009222 0.000000 0 0.000000 0.009222 \n", - "27 ... 0.000000 0.004505 0.000000 0 0.000000 0.000000 \n", - "28 ... 0.000000 0.003647 0.000000 0 0.000000 0.000000 \n", - "29 ... 0.000000 0.003053 0.000000 0 0.000000 0.000000 \n", + " ... define :: $ printf ^ , \\\n", + "0 ... 0.000000 0.000000 0.000880 0 0.000880 0.009675 \n", + "1 ... 0.000000 0.000000 0.005731 0 0.002865 0.011461 \n", + "2 ... 0.000576 0.000000 0.000058 0 0.000058 0.012844 \n", + "3 ... 0.000000 0.000000 0.005882 0 0.005882 0.005882 \n", + "4 ... 0.000281 0.000561 0.000281 0 0.000281 0.001964 \n", + "5 ... 0.000000 0.000000 0.002037 0 0.002037 0.010183 \n", + "6 ... 0.000000 0.000000 0.002041 0 0.002041 0.000000 \n", + "7 ... 0.000000 0.000915 0.000065 0 0.000065 0.013264 \n", + "8 ... 0.000000 0.006452 0.003226 0 0.003226 0.012903 \n", + "9 ... 0.000000 0.003929 0.000491 0 0.000491 0.001965 \n", + "10 ... 0.007772 0.000000 0.002591 0 0.002591 0.000000 \n", + "11 ... 0.000000 0.000000 0.004926 0 0.004926 0.000000 \n", + "12 ... 0.027778 0.000000 0.027778 0 0.027778 0.000000 \n", + "13 ... 0.007449 0.000000 0.000149 0 0.000149 0.000000 \n", + "14 ... 0.000000 0.000000 0.000475 0 0.000475 0.000949 \n", + "15 ... 0.001095 0.000000 0.000548 0 0.000548 0.004381 \n", + "16 ... 0.000000 0.001073 0.000358 0 0.000358 0.005007 \n", + "17 ... 0.000000 0.000000 0.000522 0 0.000522 0.001043 \n", + "18 ... 0.000000 0.000301 0.000150 0 0.000150 0.002858 \n", + "19 ... 0.000000 0.000000 0.002950 0 0.002950 0.014749 \n", + "20 ... 0.000000 0.000000 0.006993 0 0.006993 0.000000 \n", + "21 ... 0.000000 0.001535 0.000512 0 0.000512 0.011771 \n", + "22 ... 0.000000 0.000132 0.000132 0 0.000132 0.006612 \n", + "23 ... 0.000000 0.000000 0.001739 0 0.001739 0.000000 \n", + "24 ... 0.000000 0.000000 0.001675 0 0.001675 0.006700 \n", + "25 ... 0.000000 0.000000 0.001661 0 0.001661 0.014950 \n", + "26 ... 0.000000 0.000000 0.000351 0 0.000351 0.003857 \n", + "27 ... 0.000000 0.000000 0.003067 0 0.003067 0.006135 \n", + "28 ... 0.000000 0.000000 0.000049 0 0.000049 0.014952 \n", + "29 ... 0.000000 0.000000 0.000749 0 0.000749 0.005240 \n", "\n", - " doublecolon check make .format \n", - "0 0.000000 0.005372 0.000000 0.001240 \n", - "1 0.000000 0.005012 0.002699 0.001157 \n", - "2 0.000000 0.009094 0.000000 0.001010 \n", - "3 0.002471 0.006794 0.005559 0.000000 \n", - "4 0.002118 0.006882 0.004764 0.000000 \n", - "5 0.002292 0.007450 0.005158 0.000000 \n", - "6 0.000000 0.002947 0.000000 0.000000 \n", - "7 0.000000 0.004261 0.000000 0.000000 \n", - "8 0.000000 0.006027 0.000000 0.000000 \n", - "9 0.000000 0.006579 0.000000 0.000000 \n", - "10 0.000000 0.011236 0.000000 0.000000 \n", - "11 0.000000 0.009818 0.000000 0.000000 \n", - "12 0.000000 0.011085 0.000000 0.000000 \n", - "13 0.000000 0.005444 0.000000 0.000000 \n", - "14 0.000000 0.006146 0.004302 0.000000 \n", - "15 0.000000 0.004442 0.003110 0.000000 \n", - "16 0.000000 0.007283 0.005098 0.000000 \n", - "17 0.000000 0.010440 0.000000 0.000000 \n", - "18 0.000953 0.007623 0.000000 0.000000 \n", - "19 0.000000 0.004436 0.000000 0.000000 \n", - "20 0.000000 0.009015 0.000000 0.000000 \n", - "21 0.000000 0.004743 0.000000 0.000000 \n", - "22 0.000000 0.003866 0.000000 0.000000 \n", - "23 0.000000 0.007238 0.005568 0.001670 \n", - "24 0.000000 0.005828 0.004079 0.000000 \n", - "25 0.000000 0.003863 0.005311 0.000000 \n", - "26 0.000000 0.002951 0.004795 0.000000 \n", - "27 0.000000 0.001931 0.000000 0.000000 \n", - "28 0.000000 0.003040 0.000000 0.000000 \n", - "29 0.000000 0.002290 0.000000 0.000000 \n", + " ; & | ! \n", + "0 0.000000 0.000000 1.000880 0.000000 \n", + "1 0.011461 0.000000 1.002865 0.000000 \n", + "2 0.000691 0.002361 1.000058 0.001498 \n", + "3 0.000000 0.000000 1.005882 0.000000 \n", + "4 0.000000 0.000561 1.000281 0.000000 \n", + "5 0.000000 0.000000 1.002037 0.000000 \n", + "6 0.000000 0.000000 1.002041 0.000000 \n", + "7 0.000261 0.000000 1.000065 0.000000 \n", + "8 0.000000 0.009677 1.003226 0.000000 \n", + "9 0.000491 0.000000 1.000491 0.000000 \n", + "10 0.010363 0.000000 1.002591 0.000000 \n", + "11 0.000000 0.009852 1.004926 0.000000 \n", + "12 0.000000 0.000000 1.027778 0.000000 \n", + "13 0.000298 0.000000 1.000149 0.002086 \n", + "14 0.003322 0.000000 1.000475 0.000000 \n", + "15 0.003286 0.000000 1.000548 0.000000 \n", + "16 0.000000 0.000000 1.000358 0.000000 \n", + "17 0.000000 0.000000 1.000522 0.000000 \n", + "18 0.004964 0.000602 1.000150 0.000903 \n", + "19 0.005900 0.000000 1.002950 0.002950 \n", + "20 0.000000 0.000000 1.006993 0.000000 \n", + "21 0.011259 0.000000 1.000512 0.000000 \n", + "22 0.000397 0.000000 1.000132 0.000264 \n", + "23 0.012174 0.000000 1.001739 0.001739 \n", + "24 0.006700 0.000000 1.001675 0.001675 \n", + "25 0.000000 0.000000 1.001661 0.000000 \n", + "26 0.000000 0.000000 1.000351 0.000000 \n", + "27 0.000000 0.000000 1.003067 0.000000 \n", + "28 0.000247 0.000000 1.000049 0.000247 \n", + "29 0.014222 0.000000 1.000749 0.000000 \n", "\n", - "[30 rows x 23 columns]" + "[30 rows x 24 columns]" ] } ], - "prompt_number": 173 + "prompt_number": 204 }, { "cell_type": "code", "collapsed": false, "input": [ - "from sklearn import metrics" + "test_codelist = tcode_sucker()" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 44 + "prompt_number": 40 }, { "cell_type": "code", "collapsed": false, - "input": [], + "input": [ + "test_df = pd.read_csv(\"test.csv\")" + ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 44 + "prompt_number": 41 }, { "cell_type": "code", "collapsed": false, "input": [ - "x_train = df.loc[:,\"^\":]\n", - "x_test = test_df.loc[:, \"^\":]\n", - "y_train = df.Language\n", - "y_test = test_df.Language" + "test_df[\"Testcode\"] = test_codelist" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 190 + "prompt_number": 42 }, { "cell_type": "code", "collapsed": false, - "input": [], + "input": [ + "test_df['code length'] = test_df.Testcode.apply(length_getter)" + ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 166 + "prompt_number": 59 }, { "cell_type": "code", "collapsed": false, "input": [ - "def run_classifier(clf, x_train, x_test, y_train, y_test):\n", - " clf.fit(x_train, y_train)\n", - " predicted = clf.predict(x_test)\n", - " print(metrics.classification_report(y_test, predicted))\n", - " print(metrics.confusion_matrix(y_test, predicted))\n", - " print(metrics.f1_score(y_test, predicted))" + "test_df['^'] = df.Code.apply(carat)\n", + "test_df[';'] = df.Code.apply(semicolon)\n", + "test_df[','] = df.Code.apply(comma)\n", + "test_df['&'] = df.Code.apply(carat)\n", + "test_df['!'] = df.Code.apply(semicolon)\n", + "test_df['|'] = df.Code.apply(comma)" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 142 + "prompt_number": 105 }, { "cell_type": "code", "collapsed": false, "input": [ - "from sklearn.cross_validation import cross_val_score\n", - "from sklearn.naive_bayes import GaussianNB\n", - "from sklearn.tree import DecisionTreeClassifier\n", - "from sklearn.ensemble import RandomForestClassifier" + "test_df['let'] = df.Code.apply(let_ratio)\n", + "test_df['end'] = df.Code.apply(end_ratio)\n", + "test_df['fun'] = df.Code.apply(fun_ratio)\n", + "test_df['defn'] = df.Code.apply(defn_ratio)\n", + "test_df['def'] = df.Code.apply(def_ratio)\n", + "test_df['function'] = df.Code.apply(function_ratio)\n", + "test_df['slice'] = df.Code.apply(slice_ratio)\n", + "test_df['return'] = df.Code.apply(return_ratio)\n", + "test_df['define'] = df.Code.apply(define_ratio)\n", + "test_df['doublecolon'] = df.Code.apply(doublecolon_ratio)\n", + "test_df['check'] = df.Code.apply(check_ratio)\n", + "test_df['make'] = df.Code.apply(make_ratio)\n", + "test_df['.format'] = df.Code.apply(format_ratio)\n", + "test_df['->'] = df.Code.apply(arrow_ratio)\n", + "test_df['$'] = df.Code.apply(dollar_ratio)\n", + "test_df['printf'] = df.Code.apply(printf_ratio)" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 143 + "prompt_number": 189 }, { "cell_type": "code", "collapsed": false, "input": [ - "tree = DecisionTreeClassifier()\n", - "run_classifier(tree, x_train, x_test, y_train, y_test)" + "test_df" ], "language": "python", "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", - "text": [ - " precision recall f1-score support\n", - "\n", - " clojure 1.00 0.75 0.86 4\n", - " haskell 0.00 0.00 0.00 3\n", - " java 0.00 0.00 0.00 2\n", - " javascript 1.00 0.25 0.40 4\n", + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
FilenameLanguageTestcodecode length^;,&!|...defndeffunctionslicereturndefinedoublecoloncheckmake.format
0 1 clojure (defn cf-settings\\n \"Setup settings for campf... 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826... 0.002066 0.004545 0.000000 0 0.000000 0.000000 0.000000 0.005372 0.000000 0.001240
1 2 clojure var _ = require('lodash'),\\n fs = require('... 349 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771... 0.001928 0.003470 0.000000 0 0.000000 0.000000 0.000000 0.005012 0.002699 0.001157
2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... 17362 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347... 0.002021 0.003705 0.000000 0 0.000000 0.000000 0.000000 0.009094 0.000000 0.001010
3 4 clojure var r = riot.route = function(arg) {\\n //... 170 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002471 0.006794 0.005559 0.000000
4 5 python module ActiveJob\\n module Core\\n extend Ac... 3565 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002118 0.006882 0.004764 0.000000
5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... 491 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002292 0.007450 0.005158 0.000000
6 7 python module Fluent\\n class Input\\n include Conf... 490 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719... 0.000000 0.000000 0.000000 0 0.000737 0.000000 0.000000 0.002947 0.000000 0.000000
7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... 15305 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682... 0.000000 0.000000 0.000000 0 0.001894 0.000000 0.000000 0.004261 0.000000 0.000000
8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... 310 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636... 0.000000 0.000000 0.000000 0 0.001391 0.000000 0.000000 0.006027 0.000000 0.000000
9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... 2036 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234... 0.000000 0.000000 0.002193 0 0.002924 0.000000 0.000000 0.006579 0.000000 0.000000
10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... 386 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236... 0.000000 0.001605 0.000000 0 0.001605 0.000000 0.000000 0.011236 0.000000 0.000000
11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... 203 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921... 0.000000 0.001403 0.000000 0 0.001403 0.000000 0.000000 0.009818 0.000000 0.000000
12 13 ruby (define add1\\n (lambda (n) (+ n 1))) 36 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876... 0.000000 0.001584 0.000000 0 0.000000 0.000000 0.000000 0.011085 0.000000 0.000000
13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... 6712 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324... 0.000000 0.002395 0.000000 0 0.000000 0.000000 0.000000 0.005444 0.000000 0.000000
14 15 ruby /**\\n * Interface to represent a persistence s... 2107 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459... 0.000000 0.000000 0.001229 0 0.000000 0.000000 0.000000 0.006146 0.004302 0.000000
15 16 haskell /*\\n * Copyright 2002-2008 the original author... 1826 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887... 0.000000 0.000000 0.000888 0 0.000000 0.000000 0.000000 0.004442 0.003110 0.000000
16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... 2796 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370... 0.000000 0.000000 0.000728 0 0.000000 0.000000 0.000000 0.007283 0.005098 0.000000
17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... 1917 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423... 0.000000 0.000746 0.000000 0 0.000746 0.000000 0.000000 0.010440 0.000000 0.000000
18 19 scheme class View\\n{\\n /**\\n * Data available ... 6648 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293... 0.000000 0.000476 0.000000 0 0.001906 0.000000 0.000953 0.007623 0.000000 0.000000
19 20 scheme public function formatLocalized($format)\\n... 339 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506... 0.000000 0.000000 0.001267 0 0.001901 0.000000 0.000000 0.004436 0.000000 0.000000
20 21 scheme (extend-type String\\n Person\\n (first-name [... 143 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709... 0.000000 0.000000 0.001387 0 0.000693 0.000000 0.000000 0.009015 0.000000 0.000000
21 22 java class Application extends App {\\n\\t/**\\n\\t * @... 1954 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873... 0.000000 0.000000 0.001355 0 0.002033 0.000000 0.000000 0.004743 0.000000 0.000000
22 23 java type name = string\\n\\nlet compare_label label1... 7562 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206... 0.000000 0.000000 0.000515 0 0.001289 0.000000 0.000000 0.003866 0.000000 0.000000
23 24 scala let search_compiler_libs () =\\n prerr_endline... 575 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261... 0.000000 0.002784 0.000557 0 0.002784 0.000000 0.000000 0.007238 0.005568 0.001670
24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... 597 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000... 0.000000 0.004079 0.000000 0 0.000000 0.004079 0.000000 0.005828 0.004079 0.000000
25 28 php from pkgutil import iter_modules\\nfrom subproc... 602 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000... 0.000000 0.005311 0.000000 0 0.000000 0.005311 0.000000 0.003863 0.005311 0.000000
26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... 2852 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000... 0.000000 0.009222 0.000000 0 0.000000 0.009222 0.000000 0.002951 0.004795 0.000000
27 30 php class NoSuchService(Exception):\\n def __ini... 326 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018... 0.000000 0.004505 0.000000 0 0.000000 0.000000 0.000000 0.001931 0.000000 0.000000
28 31 ocaml from collections import namedtuple\\nimport fun... 20265 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805... 0.000000 0.003647 0.000000 0 0.000000 0.000000 0.000000 0.003040 0.000000 0.000000
29 32 ocaml function errorHandler(context) {\\n return fun... 1336 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794... 0.000000 0.003053 0.000000 0 0.000000 0.000000 0.000000 0.002290 0.000000 0.000000
\n", + "

30 rows \u00d7 23 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 173, + "text": [ + " Filename Language Testcode \\\n", + "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", + "1 2 clojure var _ = require('lodash'),\\n fs = require('... \n", + "2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", + "3 4 clojure var r = riot.route = function(arg) {\\n //... \n", + "4 5 python module ActiveJob\\n module Core\\n extend Ac... \n", + "5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", + "6 7 python module Fluent\\n class Input\\n include Conf... \n", + "7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", + "8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... \n", + "9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... \n", + "10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... \n", + "11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", + "12 13 ruby (define add1\\n (lambda (n) (+ n 1))) \n", + "13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... \n", + "14 15 ruby /**\\n * Interface to represent a persistence s... \n", + "15 16 haskell /*\\n * Copyright 2002-2008 the original author... \n", + "16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... \n", + "17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", + "18 19 scheme class View\\n{\\n /**\\n * Data available ... \n", + "19 20 scheme public function formatLocalized($format)\\n... \n", + "20 21 scheme (extend-type String\\n Person\\n (first-name [... \n", + "21 22 java class Application extends App {\\n\\t/**\\n\\t * @... \n", + "22 23 java type name = string\\n\\nlet compare_label label1... \n", + "23 24 scala let search_compiler_libs () =\\n prerr_endline... \n", + "24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... \n", + "25 28 php from pkgutil import iter_modules\\nfrom subproc... \n", + "26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", + "27 30 php class NoSuchService(Exception):\\n def __ini... \n", + "28 31 ocaml from collections import namedtuple\\nimport fun... \n", + "29 32 ocaml function errorHandler(context) {\\n return fun... \n", + "\n", + " code length ^ ; , & ! | \\\n", + "0 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826 \n", + "1 349 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771 \n", + "2 17362 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347 \n", + "3 170 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177 \n", + "4 3565 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294 \n", + "5 491 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158 \n", + "6 490 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719 \n", + "7 15305 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682 \n", + "8 310 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636 \n", + "9 2036 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234 \n", + "10 386 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236 \n", + "11 203 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921 \n", + "12 36 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876 \n", + "13 6712 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324 \n", + "14 2107 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459 \n", + "15 1826 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887 \n", + "16 2796 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370 \n", + "17 1917 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423 \n", + "18 6648 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293 \n", + "19 339 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506 \n", + "20 143 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709 \n", + "21 1954 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873 \n", + "22 7562 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206 \n", + "23 575 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261 \n", + "24 597 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 \n", + "25 602 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000 \n", + "26 2852 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000 \n", + "27 326 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018 \n", + "28 20265 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805 \n", + "29 1336 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794 \n", + "\n", + " ... defn def function slice return define \\\n", + "0 ... 0.002066 0.004545 0.000000 0 0.000000 0.000000 \n", + "1 ... 0.001928 0.003470 0.000000 0 0.000000 0.000000 \n", + "2 ... 0.002021 0.003705 0.000000 0 0.000000 0.000000 \n", + "3 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", + "4 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", + "5 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", + "6 ... 0.000000 0.000000 0.000000 0 0.000737 0.000000 \n", + "7 ... 0.000000 0.000000 0.000000 0 0.001894 0.000000 \n", + "8 ... 0.000000 0.000000 0.000000 0 0.001391 0.000000 \n", + "9 ... 0.000000 0.000000 0.002193 0 0.002924 0.000000 \n", + "10 ... 0.000000 0.001605 0.000000 0 0.001605 0.000000 \n", + "11 ... 0.000000 0.001403 0.000000 0 0.001403 0.000000 \n", + "12 ... 0.000000 0.001584 0.000000 0 0.000000 0.000000 \n", + "13 ... 0.000000 0.002395 0.000000 0 0.000000 0.000000 \n", + "14 ... 0.000000 0.000000 0.001229 0 0.000000 0.000000 \n", + "15 ... 0.000000 0.000000 0.000888 0 0.000000 0.000000 \n", + "16 ... 0.000000 0.000000 0.000728 0 0.000000 0.000000 \n", + "17 ... 0.000000 0.000746 0.000000 0 0.000746 0.000000 \n", + "18 ... 0.000000 0.000476 0.000000 0 0.001906 0.000000 \n", + "19 ... 0.000000 0.000000 0.001267 0 0.001901 0.000000 \n", + "20 ... 0.000000 0.000000 0.001387 0 0.000693 0.000000 \n", + "21 ... 0.000000 0.000000 0.001355 0 0.002033 0.000000 \n", + "22 ... 0.000000 0.000000 0.000515 0 0.001289 0.000000 \n", + "23 ... 0.000000 0.002784 0.000557 0 0.002784 0.000000 \n", + "24 ... 0.000000 0.004079 0.000000 0 0.000000 0.004079 \n", + "25 ... 0.000000 0.005311 0.000000 0 0.000000 0.005311 \n", + "26 ... 0.000000 0.009222 0.000000 0 0.000000 0.009222 \n", + "27 ... 0.000000 0.004505 0.000000 0 0.000000 0.000000 \n", + "28 ... 0.000000 0.003647 0.000000 0 0.000000 0.000000 \n", + "29 ... 0.000000 0.003053 0.000000 0 0.000000 0.000000 \n", + "\n", + " doublecolon check make .format \n", + "0 0.000000 0.005372 0.000000 0.001240 \n", + "1 0.000000 0.005012 0.002699 0.001157 \n", + "2 0.000000 0.009094 0.000000 0.001010 \n", + "3 0.002471 0.006794 0.005559 0.000000 \n", + "4 0.002118 0.006882 0.004764 0.000000 \n", + "5 0.002292 0.007450 0.005158 0.000000 \n", + "6 0.000000 0.002947 0.000000 0.000000 \n", + "7 0.000000 0.004261 0.000000 0.000000 \n", + "8 0.000000 0.006027 0.000000 0.000000 \n", + "9 0.000000 0.006579 0.000000 0.000000 \n", + "10 0.000000 0.011236 0.000000 0.000000 \n", + "11 0.000000 0.009818 0.000000 0.000000 \n", + "12 0.000000 0.011085 0.000000 0.000000 \n", + "13 0.000000 0.005444 0.000000 0.000000 \n", + "14 0.000000 0.006146 0.004302 0.000000 \n", + "15 0.000000 0.004442 0.003110 0.000000 \n", + "16 0.000000 0.007283 0.005098 0.000000 \n", + "17 0.000000 0.010440 0.000000 0.000000 \n", + "18 0.000953 0.007623 0.000000 0.000000 \n", + "19 0.000000 0.004436 0.000000 0.000000 \n", + "20 0.000000 0.009015 0.000000 0.000000 \n", + "21 0.000000 0.004743 0.000000 0.000000 \n", + "22 0.000000 0.003866 0.000000 0.000000 \n", + "23 0.000000 0.007238 0.005568 0.001670 \n", + "24 0.000000 0.005828 0.004079 0.000000 \n", + "25 0.000000 0.003863 0.005311 0.000000 \n", + "26 0.000000 0.002951 0.004795 0.000000 \n", + "27 0.000000 0.001931 0.000000 0.000000 \n", + "28 0.000000 0.003040 0.000000 0.000000 \n", + "29 0.000000 0.002290 0.000000 0.000000 \n", + "\n", + "[30 rows x 23 columns]" + ] + } + ], + "prompt_number": 173 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn import metrics" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 44 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def create_xy(df, test_df startx, columny):\n", + " x_train = df.loc[:, startx:]\n", + " x_test = test_df.loc[:, startx:]\n", + " y_train = df[columny]\n", + " y_test = test_df[columny]\n", + " return x_train, x_test, y_train, y_test" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 208 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train = df.loc[:,\"^\":]\n", + "x_test = test_df.loc[:, \"^\":]\n", + "y_train = df.Language\n", + "y_test = test_df.Language" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 190 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train, x_test, y_train, y_test = create_xy('let', 'Language')" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 211 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
letenddefnfunctionfunreturndefcheckmake->...define::$printf^,;&|!
0 0.002066 0.000000 0.002066 0.000000 0.000000 0.000000 0.004545 0.005372 0.000000 0.000000... 0.000000 0.000000 0.000826 0.000000 0.000413 0.000826 0.009091 0.000413 1.000413 0.000826
1 0.002699 0.000386 0.001928 0.000000 0.000000 0.000000 0.003470 0.005012 0.002699 0.000000... 0.000000 0.000000 0.000771 0.000000 0.000386 0.000771 0.008096 0.000771 1.000386 0.000771
2 0.002695 0.000000 0.002021 0.000000 0.000000 0.000000 0.003705 0.009094 0.000000 0.000000... 0.000000 0.000000 0.000674 0.000000 0.000337 0.001347 0.010104 0.000337 1.000337 0.000337
3 0.002471 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.006794 0.005559 0.005559... 0.000000 0.002471 0.001235 0.000618 0.000618 0.006177 0.000618 0.000000 1.000618 0.002471
4 0.002647 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.006882 0.004764 0.005823... 0.000000 0.002118 0.001059 0.000529 0.000529 0.005294 0.000529 0.000000 1.000529 0.003176
5 0.002865 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.007450 0.005158 0.006304... 0.000000 0.002292 0.001146 0.000573 0.000573 0.005158 0.000573 0.000000 1.000573 0.002292
6 0.000000 0.001228 0.000000 0.000000 0.000000 0.000737 0.000000 0.002947 0.000000 0.000000... 0.000000 0.000000 0.000491 0.000000 0.000246 0.001719 0.016208 0.000000 1.000246 0.000246
7 0.000000 0.000000 0.000000 0.000000 0.000000 0.001894 0.000000 0.004261 0.000000 0.000000... 0.000000 0.000000 0.000947 0.000000 0.000473 0.005682 0.013258 0.000000 1.000473 0.000000
8 0.000000 0.000000 0.000000 0.000000 0.000000 0.001391 0.000000 0.006027 0.000000 0.000000... 0.000000 0.000000 0.000927 0.000000 0.000464 0.004636 0.014372 0.000000 1.000464 0.000000
9 0.000000 0.000000 0.000000 0.002193 0.002193 0.002924 0.000000 0.006579 0.000000 0.000000... 0.000000 0.000000 0.001462 0.000000 0.000731 0.010234 0.017544 0.000000 1.000731 0.000000
10 0.000000 0.003210 0.000000 0.000000 0.000000 0.001605 0.001605 0.011236 0.000000 0.000000... 0.000000 0.000000 0.001605 0.000000 0.000803 0.011236 0.000000 0.000000 1.000803 0.000000
11 0.000000 0.003506 0.000000 0.000000 0.000000 0.001403 0.001403 0.009818 0.000000 0.000000... 0.000000 0.000000 0.001403 0.000000 0.000701 0.011921 0.001403 0.000000 1.000701 0.000000
12 0.000000 0.004751 0.000000 0.000000 0.000000 0.000000 0.001584 0.011085 0.000000 0.000000... 0.000000 0.000000 0.001584 0.000000 0.000792 0.011876 0.000000 0.000000 1.000792 0.000000
13 0.000000 0.006533 0.000000 0.000000 0.000000 0.000000 0.002395 0.005444 0.000000 0.000000... 0.000000 0.000000 0.000436 0.000000 0.000218 0.011324 0.000000 0.003049 1.000218 0.000000
14 0.012293 0.000000 0.000000 0.001229 0.001229 0.000000 0.000000 0.006146 0.004302 0.001229... 0.000000 0.000000 0.001229 0.001844 0.000615 0.002459 0.004302 0.000000 1.000615 0.000000
15 0.009773 0.000000 0.000000 0.000888 0.002665 0.000000 0.000000 0.004442 0.003110 0.006664... 0.000000 0.000000 0.000888 0.001333 0.000444 0.004887 0.006219 0.000000 1.000444 0.000888
16 0.010925 0.000000 0.000000 0.000728 0.000728 0.000000 0.000000 0.007283 0.005098 0.002185... 0.000000 0.000000 0.001457 0.002185 0.000728 0.004370 0.005098 0.000000 1.000728 0.001457
17 0.000000 0.000000 0.000000 0.000000 0.000000 0.000746 0.000746 0.010440 0.000000 0.000000... 0.000000 0.000000 0.001491 0.000000 0.000746 0.013423 0.013423 0.000000 1.000746 0.000000
18 0.000000 0.000000 0.000000 0.000000 0.000000 0.001906 0.000476 0.007623 0.000000 0.003335... 0.000000 0.000953 0.000953 0.000000 0.000476 0.014293 0.015722 0.000000 1.000476 0.000000
19 0.000000 0.000000 0.000000 0.001267 0.001267 0.001901 0.000000 0.004436 0.000000 0.008872... 0.000000 0.000000 0.001267 0.001901 0.000634 0.009506 0.022180 0.000000 1.000634 0.000634
20 0.000000 0.000000 0.000000 0.001387 0.001387 0.000693 0.000000 0.009015 0.000000 0.013870... 0.000000 0.000000 0.001387 0.002080 0.000693 0.009709 0.017337 0.000000 1.000693 0.000000
21 0.000000 0.000000 0.000000 0.001355 0.001355 0.002033 0.000000 0.004743 0.000000 0.000000... 0.000000 0.000000 0.001355 0.002033 0.000678 0.012873 0.018970 0.000000 1.000678 0.000678
22 0.000000 0.000258 0.000000 0.000515 0.000515 0.001289 0.000000 0.003866 0.000000 0.000000... 0.000000 0.000000 0.000515 0.000773 0.000258 0.015206 0.027320 0.001289 1.000258 0.001031
23 0.000000 0.000557 0.000000 0.000557 0.000557 0.002784 0.002784 0.007238 0.005568 0.000000... 0.000000 0.000000 0.001114 0.000000 0.000557 0.017261 0.000000 0.000000 1.000557 0.000000
24 0.002914 0.000000 0.000000 0.000000 0.000000 0.000000 0.004079 0.005828 0.004079 0.000583... 0.004079 0.000000 0.001166 0.001748 0.000583 0.000000 0.008159 0.000000 1.000583 0.000000
25 0.003380 0.000000 0.000000 0.000000 0.000000 0.000000 0.005311 0.003863 0.005311 0.000483... 0.005311 0.000000 0.000966 0.001449 0.000483 0.000000 0.005794 0.000000 1.000483 0.000000
26 0.001107 0.000000 0.000000 0.000000 0.000000 0.000000 0.009222 0.002951 0.004795 0.000369... 0.009222 0.000000 0.000738 0.001107 0.000369 0.000000 0.004426 0.000000 1.000369 0.000369
27 0.000000 0.001931 0.000000 0.000000 0.000000 0.000000 0.004505 0.001931 0.000000 0.000000... 0.000000 0.000000 0.001287 0.000000 0.000644 0.018018 0.000000 0.000000 1.000644 0.000000
28 0.000000 0.000608 0.000000 0.000000 0.000000 0.000000 0.003647 0.003040 0.000000 0.000000... 0.000000 0.000000 0.001216 0.000000 0.000608 0.015805 0.000608 0.000000 1.000608 0.000000
29 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.003053 0.002290 0.000000 0.000000... 0.000000 0.000000 0.001527 0.000000 0.000763 0.016794 0.000000 0.000000 1.000763 0.000000
..................................................................
356 0.000000 0.000000 0.000000 0.000000 0.000000 0.004155 0.004848 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001385 0.000000 0.000693 0.009003 0.000000 0.000000 1.000693 0.000000
357 0.000000 0.000000 0.000000 0.000000 0.000000 0.003165 0.003956 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001582 0.000000 0.000791 0.005538 0.000000 0.000000 1.000791 0.000000
358 0.000000 0.000000 0.000000 0.000000 0.000000 0.000600 0.003001 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001200 0.000000 0.000600 0.011405 0.000000 0.000000 1.000600 0.000000
359 0.002172 0.000000 0.000000 0.000000 0.000000 0.000543 0.002714 0.000000 0.001629 0.002714... 0.002714 0.000000 0.001086 0.000543 0.000543 0.000543 0.014115 0.000000 1.000543 0.001086
360 0.001901 0.000000 0.000000 0.000000 0.000000 0.000475 0.002376 0.000000 0.001901 0.003327... 0.002376 0.000000 0.000951 0.000475 0.000475 0.000475 0.013308 0.000000 1.000475 0.000951
361 0.003863 0.000000 0.000000 0.000000 0.000000 0.000000 0.005311 0.000000 0.001931 0.002414... 0.005311 0.000000 0.000966 0.000000 0.000483 0.000000 0.004829 0.000000 1.000483 0.000966
362 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.002508 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001672 0.000836 0.000836 0.015050 0.000836 0.000836 1.000836 0.000000
363 0.000000 0.002877 0.000000 0.000000 0.000000 0.000000 0.002877 0.000000 0.000000 0.000000... 0.000000 0.000000 0.000822 0.000000 0.000411 0.009453 0.000000 0.000000 1.000411 0.000000
364 0.000248 0.000248 0.000000 0.000248 0.000248 0.000248 0.002475 0.000000 0.000000 0.000000... 0.000000 0.000495 0.000495 0.000000 0.000248 0.009406 0.000000 0.000000 1.000248 0.000000
365 0.000458 0.000229 0.000000 0.000229 0.000229 0.000229 0.002521 0.000000 0.000000 0.000000... 0.000000 0.000687 0.000458 0.000000 0.000229 0.008249 0.000000 0.000000 1.000229 0.000000
366 0.001794 0.002691 0.002691 0.000000 0.000000 0.000000 0.002691 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001794 0.000000 0.000897 0.000897 0.008969 0.000897 1.000897 0.000897
367 0.000000 0.004206 0.003155 0.001052 0.001052 0.001052 0.004206 0.000000 0.000000 0.000000... 0.000000 0.000000 0.002103 0.000000 0.001052 0.000000 0.011567 0.001052 1.001052 0.000000
368 0.000000 0.000000 0.000000 0.000000 0.000000 0.001149 0.000000 0.000000 0.001149 0.004598... 0.000000 0.001149 0.002299 0.000000 0.001149 0.001149 0.000000 0.000000 1.001149 0.001149
369 0.000000 0.000897 0.000000 0.000000 0.000000 0.000897 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.000897 0.000000 0.000449 0.000897 0.018394 0.000000 1.000449 0.000449
370 0.000000 0.000600 0.000000 0.000000 0.000000 0.000600 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001200 0.000000 0.000600 0.001801 0.017407 0.000000 1.000600 0.000600
371 0.000000 0.001525 0.000000 0.000000 0.000000 0.000508 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.000508 0.000000 0.000254 0.002542 0.014743 0.000000 1.000254 0.000000
372 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001504 0.000000 0.000752 0.000000 0.015038 0.000000 1.000752 0.000752
373 0.000000 0.001183 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.000789 0.000000 0.000394 0.001577 0.011435 0.000000 1.000394 0.000000
374 0.000000 0.000626 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001252 0.000000 0.000626 0.000000 0.019399 0.000000 1.000626 0.000000
375 0.000000 0.010881 0.000000 0.000000 0.000000 0.000000 0.004353 0.000000 0.000000 0.000000... 0.000000 0.000000 0.002176 0.000000 0.001088 0.001088 0.000000 0.000000 1.001088 0.000000
376 0.000000 0.010135 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.003378 0.000000 0.001689 0.000000 0.000000 0.000000 1.001689 0.000000
377 0.011611 0.002903 0.000000 0.000000 0.002903 0.000000 0.000000 0.000000 0.000000 0.002903... 0.000000 0.000000 0.002903 0.000000 0.001451 0.000000 0.005806 0.000000 1.001451 0.000000
378 0.010613 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.002358 0.000000 0.001179 0.002358 0.014151 0.000000 1.001179 0.002358
379 0.010914 0.000000 0.000000 0.000000 0.001364 0.000000 0.000000 0.000000 0.000000 0.001364... 0.000000 0.000000 0.002729 0.000000 0.001364 0.002729 0.012278 0.000000 1.001364 0.000000
380 0.000000 0.000000 0.000000 0.000000 0.002128 0.000000 0.000000 0.000000 0.000000 0.008511... 0.000000 0.004255 0.002128 0.000000 0.001064 0.001064 0.029787 0.001064 1.001064 0.000000
381 0.000420 0.000840 0.000000 0.000000 0.000000 0.000000 0.000840 0.000000 0.000420 0.002940... 0.000420 0.001260 0.000840 0.000000 0.000420 0.004200 0.012180 0.000840 1.000420 0.000000
382 0.000000 0.000000 0.000000 0.000000 0.002090 0.000000 0.001045 0.000000 0.000000 0.000000... 0.000000 0.000000 0.002090 0.000000 0.001045 0.006270 0.000000 0.000000 1.001045 0.000000
383 0.000000 0.006090 0.000000 0.000000 0.001218 0.000000 0.002436 0.000000 0.000000 0.000000... 0.000000 0.000000 0.002436 0.000000 0.001218 0.003654 0.000000 0.000000 1.001218 0.000000
384 0.003911 0.002608 0.000000 0.000000 0.000000 0.000000 0.001304 0.000000 0.000000 0.001304... 0.001304 0.000000 0.002608 0.001304 0.001304 0.000000 0.027379 0.000000 1.001304 0.000000
385 0.000000 0.001414 0.000000 0.000000 0.000000 0.000000 0.002829 0.000000 0.000000 0.000000... 0.000000 0.000000 0.002829 0.000000 0.001414 0.000000 0.001414 0.000000 1.001414 0.002829
\n", + "

386 rows \u00d7 21 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 212, + "text": [ + " let end defn function fun return def \\\n", + "0 0.002066 0.000000 0.002066 0.000000 0.000000 0.000000 0.004545 \n", + "1 0.002699 0.000386 0.001928 0.000000 0.000000 0.000000 0.003470 \n", + "2 0.002695 0.000000 0.002021 0.000000 0.000000 0.000000 0.003705 \n", + "3 0.002471 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "4 0.002647 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "5 0.002865 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "6 0.000000 0.001228 0.000000 0.000000 0.000000 0.000737 0.000000 \n", + "7 0.000000 0.000000 0.000000 0.000000 0.000000 0.001894 0.000000 \n", + "8 0.000000 0.000000 0.000000 0.000000 0.000000 0.001391 0.000000 \n", + "9 0.000000 0.000000 0.000000 0.002193 0.002193 0.002924 0.000000 \n", + "10 0.000000 0.003210 0.000000 0.000000 0.000000 0.001605 0.001605 \n", + "11 0.000000 0.003506 0.000000 0.000000 0.000000 0.001403 0.001403 \n", + "12 0.000000 0.004751 0.000000 0.000000 0.000000 0.000000 0.001584 \n", + "13 0.000000 0.006533 0.000000 0.000000 0.000000 0.000000 0.002395 \n", + "14 0.012293 0.000000 0.000000 0.001229 0.001229 0.000000 0.000000 \n", + "15 0.009773 0.000000 0.000000 0.000888 0.002665 0.000000 0.000000 \n", + "16 0.010925 0.000000 0.000000 0.000728 0.000728 0.000000 0.000000 \n", + "17 0.000000 0.000000 0.000000 0.000000 0.000000 0.000746 0.000746 \n", + "18 0.000000 0.000000 0.000000 0.000000 0.000000 0.001906 0.000476 \n", + "19 0.000000 0.000000 0.000000 0.001267 0.001267 0.001901 0.000000 \n", + "20 0.000000 0.000000 0.000000 0.001387 0.001387 0.000693 0.000000 \n", + "21 0.000000 0.000000 0.000000 0.001355 0.001355 0.002033 0.000000 \n", + "22 0.000000 0.000258 0.000000 0.000515 0.000515 0.001289 0.000000 \n", + "23 0.000000 0.000557 0.000000 0.000557 0.000557 0.002784 0.002784 \n", + "24 0.002914 0.000000 0.000000 0.000000 0.000000 0.000000 0.004079 \n", + "25 0.003380 0.000000 0.000000 0.000000 0.000000 0.000000 0.005311 \n", + "26 0.001107 0.000000 0.000000 0.000000 0.000000 0.000000 0.009222 \n", + "27 0.000000 0.001931 0.000000 0.000000 0.000000 0.000000 0.004505 \n", + "28 0.000000 0.000608 0.000000 0.000000 0.000000 0.000000 0.003647 \n", + "29 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.003053 \n", + ".. ... ... ... ... ... ... ... \n", + "356 0.000000 0.000000 0.000000 0.000000 0.000000 0.004155 0.004848 \n", + "357 0.000000 0.000000 0.000000 0.000000 0.000000 0.003165 0.003956 \n", + "358 0.000000 0.000000 0.000000 0.000000 0.000000 0.000600 0.003001 \n", + "359 0.002172 0.000000 0.000000 0.000000 0.000000 0.000543 0.002714 \n", + "360 0.001901 0.000000 0.000000 0.000000 0.000000 0.000475 0.002376 \n", + "361 0.003863 0.000000 0.000000 0.000000 0.000000 0.000000 0.005311 \n", + "362 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.002508 \n", + "363 0.000000 0.002877 0.000000 0.000000 0.000000 0.000000 0.002877 \n", + "364 0.000248 0.000248 0.000000 0.000248 0.000248 0.000248 0.002475 \n", + "365 0.000458 0.000229 0.000000 0.000229 0.000229 0.000229 0.002521 \n", + "366 0.001794 0.002691 0.002691 0.000000 0.000000 0.000000 0.002691 \n", + "367 0.000000 0.004206 0.003155 0.001052 0.001052 0.001052 0.004206 \n", + "368 0.000000 0.000000 0.000000 0.000000 0.000000 0.001149 0.000000 \n", + "369 0.000000 0.000897 0.000000 0.000000 0.000000 0.000897 0.000000 \n", + "370 0.000000 0.000600 0.000000 0.000000 0.000000 0.000600 0.000000 \n", + "371 0.000000 0.001525 0.000000 0.000000 0.000000 0.000508 0.000000 \n", + "372 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "373 0.000000 0.001183 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "374 0.000000 0.000626 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "375 0.000000 0.010881 0.000000 0.000000 0.000000 0.000000 0.004353 \n", + "376 0.000000 0.010135 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "377 0.011611 0.002903 0.000000 0.000000 0.002903 0.000000 0.000000 \n", + "378 0.010613 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "379 0.010914 0.000000 0.000000 0.000000 0.001364 0.000000 0.000000 \n", + "380 0.000000 0.000000 0.000000 0.000000 0.002128 0.000000 0.000000 \n", + "381 0.000420 0.000840 0.000000 0.000000 0.000000 0.000000 0.000840 \n", + "382 0.000000 0.000000 0.000000 0.000000 0.002090 0.000000 0.001045 \n", + "383 0.000000 0.006090 0.000000 0.000000 0.001218 0.000000 0.002436 \n", + "384 0.003911 0.002608 0.000000 0.000000 0.000000 0.000000 0.001304 \n", + "385 0.000000 0.001414 0.000000 0.000000 0.000000 0.000000 0.002829 \n", + "\n", + " check make -> ... define :: $ \\\n", + "0 0.005372 0.000000 0.000000 ... 0.000000 0.000000 0.000826 \n", + "1 0.005012 0.002699 0.000000 ... 0.000000 0.000000 0.000771 \n", + "2 0.009094 0.000000 0.000000 ... 0.000000 0.000000 0.000674 \n", + "3 0.006794 0.005559 0.005559 ... 0.000000 0.002471 0.001235 \n", + "4 0.006882 0.004764 0.005823 ... 0.000000 0.002118 0.001059 \n", + "5 0.007450 0.005158 0.006304 ... 0.000000 0.002292 0.001146 \n", + "6 0.002947 0.000000 0.000000 ... 0.000000 0.000000 0.000491 \n", + "7 0.004261 0.000000 0.000000 ... 0.000000 0.000000 0.000947 \n", + "8 0.006027 0.000000 0.000000 ... 0.000000 0.000000 0.000927 \n", + "9 0.006579 0.000000 0.000000 ... 0.000000 0.000000 0.001462 \n", + "10 0.011236 0.000000 0.000000 ... 0.000000 0.000000 0.001605 \n", + "11 0.009818 0.000000 0.000000 ... 0.000000 0.000000 0.001403 \n", + "12 0.011085 0.000000 0.000000 ... 0.000000 0.000000 0.001584 \n", + "13 0.005444 0.000000 0.000000 ... 0.000000 0.000000 0.000436 \n", + "14 0.006146 0.004302 0.001229 ... 0.000000 0.000000 0.001229 \n", + "15 0.004442 0.003110 0.006664 ... 0.000000 0.000000 0.000888 \n", + "16 0.007283 0.005098 0.002185 ... 0.000000 0.000000 0.001457 \n", + "17 0.010440 0.000000 0.000000 ... 0.000000 0.000000 0.001491 \n", + "18 0.007623 0.000000 0.003335 ... 0.000000 0.000953 0.000953 \n", + "19 0.004436 0.000000 0.008872 ... 0.000000 0.000000 0.001267 \n", + "20 0.009015 0.000000 0.013870 ... 0.000000 0.000000 0.001387 \n", + "21 0.004743 0.000000 0.000000 ... 0.000000 0.000000 0.001355 \n", + "22 0.003866 0.000000 0.000000 ... 0.000000 0.000000 0.000515 \n", + "23 0.007238 0.005568 0.000000 ... 0.000000 0.000000 0.001114 \n", + "24 0.005828 0.004079 0.000583 ... 0.004079 0.000000 0.001166 \n", + "25 0.003863 0.005311 0.000483 ... 0.005311 0.000000 0.000966 \n", + "26 0.002951 0.004795 0.000369 ... 0.009222 0.000000 0.000738 \n", + "27 0.001931 0.000000 0.000000 ... 0.000000 0.000000 0.001287 \n", + "28 0.003040 0.000000 0.000000 ... 0.000000 0.000000 0.001216 \n", + "29 0.002290 0.000000 0.000000 ... 0.000000 0.000000 0.001527 \n", + ".. ... ... ... ... ... ... ... \n", + "356 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001385 \n", + "357 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001582 \n", + "358 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001200 \n", + "359 0.000000 0.001629 0.002714 ... 0.002714 0.000000 0.001086 \n", + "360 0.000000 0.001901 0.003327 ... 0.002376 0.000000 0.000951 \n", + "361 0.000000 0.001931 0.002414 ... 0.005311 0.000000 0.000966 \n", + "362 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001672 \n", + "363 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000822 \n", + "364 0.000000 0.000000 0.000000 ... 0.000000 0.000495 0.000495 \n", + "365 0.000000 0.000000 0.000000 ... 0.000000 0.000687 0.000458 \n", + "366 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001794 \n", + "367 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002103 \n", + "368 0.000000 0.001149 0.004598 ... 0.000000 0.001149 0.002299 \n", + "369 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000897 \n", + "370 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001200 \n", + "371 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000508 \n", + "372 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001504 \n", + "373 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000789 \n", + "374 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001252 \n", + "375 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002176 \n", + "376 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.003378 \n", + "377 0.000000 0.000000 0.002903 ... 0.000000 0.000000 0.002903 \n", + "378 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002358 \n", + "379 0.000000 0.000000 0.001364 ... 0.000000 0.000000 0.002729 \n", + "380 0.000000 0.000000 0.008511 ... 0.000000 0.004255 0.002128 \n", + "381 0.000000 0.000420 0.002940 ... 0.000420 0.001260 0.000840 \n", + "382 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002090 \n", + "383 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002436 \n", + "384 0.000000 0.000000 0.001304 ... 0.001304 0.000000 0.002608 \n", + "385 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002829 \n", + "\n", + " printf ^ , ; & | ! \n", + "0 0.000000 0.000413 0.000826 0.009091 0.000413 1.000413 0.000826 \n", + "1 0.000000 0.000386 0.000771 0.008096 0.000771 1.000386 0.000771 \n", + "2 0.000000 0.000337 0.001347 0.010104 0.000337 1.000337 0.000337 \n", + "3 0.000618 0.000618 0.006177 0.000618 0.000000 1.000618 0.002471 \n", + "4 0.000529 0.000529 0.005294 0.000529 0.000000 1.000529 0.003176 \n", + "5 0.000573 0.000573 0.005158 0.000573 0.000000 1.000573 0.002292 \n", + "6 0.000000 0.000246 0.001719 0.016208 0.000000 1.000246 0.000246 \n", + "7 0.000000 0.000473 0.005682 0.013258 0.000000 1.000473 0.000000 \n", + "8 0.000000 0.000464 0.004636 0.014372 0.000000 1.000464 0.000000 \n", + "9 0.000000 0.000731 0.010234 0.017544 0.000000 1.000731 0.000000 \n", + "10 0.000000 0.000803 0.011236 0.000000 0.000000 1.000803 0.000000 \n", + "11 0.000000 0.000701 0.011921 0.001403 0.000000 1.000701 0.000000 \n", + "12 0.000000 0.000792 0.011876 0.000000 0.000000 1.000792 0.000000 \n", + "13 0.000000 0.000218 0.011324 0.000000 0.003049 1.000218 0.000000 \n", + "14 0.001844 0.000615 0.002459 0.004302 0.000000 1.000615 0.000000 \n", + "15 0.001333 0.000444 0.004887 0.006219 0.000000 1.000444 0.000888 \n", + "16 0.002185 0.000728 0.004370 0.005098 0.000000 1.000728 0.001457 \n", + "17 0.000000 0.000746 0.013423 0.013423 0.000000 1.000746 0.000000 \n", + "18 0.000000 0.000476 0.014293 0.015722 0.000000 1.000476 0.000000 \n", + "19 0.001901 0.000634 0.009506 0.022180 0.000000 1.000634 0.000634 \n", + "20 0.002080 0.000693 0.009709 0.017337 0.000000 1.000693 0.000000 \n", + "21 0.002033 0.000678 0.012873 0.018970 0.000000 1.000678 0.000678 \n", + "22 0.000773 0.000258 0.015206 0.027320 0.001289 1.000258 0.001031 \n", + "23 0.000000 0.000557 0.017261 0.000000 0.000000 1.000557 0.000000 \n", + "24 0.001748 0.000583 0.000000 0.008159 0.000000 1.000583 0.000000 \n", + "25 0.001449 0.000483 0.000000 0.005794 0.000000 1.000483 0.000000 \n", + "26 0.001107 0.000369 0.000000 0.004426 0.000000 1.000369 0.000369 \n", + "27 0.000000 0.000644 0.018018 0.000000 0.000000 1.000644 0.000000 \n", + "28 0.000000 0.000608 0.015805 0.000608 0.000000 1.000608 0.000000 \n", + "29 0.000000 0.000763 0.016794 0.000000 0.000000 1.000763 0.000000 \n", + ".. ... ... ... ... ... ... ... \n", + "356 0.000000 0.000693 0.009003 0.000000 0.000000 1.000693 0.000000 \n", + "357 0.000000 0.000791 0.005538 0.000000 0.000000 1.000791 0.000000 \n", + "358 0.000000 0.000600 0.011405 0.000000 0.000000 1.000600 0.000000 \n", + "359 0.000543 0.000543 0.000543 0.014115 0.000000 1.000543 0.001086 \n", + "360 0.000475 0.000475 0.000475 0.013308 0.000000 1.000475 0.000951 \n", + "361 0.000000 0.000483 0.000000 0.004829 0.000000 1.000483 0.000966 \n", + "362 0.000836 0.000836 0.015050 0.000836 0.000836 1.000836 0.000000 \n", + "363 0.000000 0.000411 0.009453 0.000000 0.000000 1.000411 0.000000 \n", + "364 0.000000 0.000248 0.009406 0.000000 0.000000 1.000248 0.000000 \n", + "365 0.000000 0.000229 0.008249 0.000000 0.000000 1.000229 0.000000 \n", + "366 0.000000 0.000897 0.000897 0.008969 0.000897 1.000897 0.000897 \n", + "367 0.000000 0.001052 0.000000 0.011567 0.001052 1.001052 0.000000 \n", + "368 0.000000 0.001149 0.001149 0.000000 0.000000 1.001149 0.001149 \n", + "369 0.000000 0.000449 0.000897 0.018394 0.000000 1.000449 0.000449 \n", + "370 0.000000 0.000600 0.001801 0.017407 0.000000 1.000600 0.000600 \n", + "371 0.000000 0.000254 0.002542 0.014743 0.000000 1.000254 0.000000 \n", + "372 0.000000 0.000752 0.000000 0.015038 0.000000 1.000752 0.000752 \n", + "373 0.000000 0.000394 0.001577 0.011435 0.000000 1.000394 0.000000 \n", + "374 0.000000 0.000626 0.000000 0.019399 0.000000 1.000626 0.000000 \n", + "375 0.000000 0.001088 0.001088 0.000000 0.000000 1.001088 0.000000 \n", + "376 0.000000 0.001689 0.000000 0.000000 0.000000 1.001689 0.000000 \n", + "377 0.000000 0.001451 0.000000 0.005806 0.000000 1.001451 0.000000 \n", + "378 0.000000 0.001179 0.002358 0.014151 0.000000 1.001179 0.002358 \n", + "379 0.000000 0.001364 0.002729 0.012278 0.000000 1.001364 0.000000 \n", + "380 0.000000 0.001064 0.001064 0.029787 0.001064 1.001064 0.000000 \n", + "381 0.000000 0.000420 0.004200 0.012180 0.000840 1.000420 0.000000 \n", + "382 0.000000 0.001045 0.006270 0.000000 0.000000 1.001045 0.000000 \n", + "383 0.000000 0.001218 0.003654 0.000000 0.000000 1.001218 0.000000 \n", + "384 0.001304 0.001304 0.000000 0.027379 0.000000 1.001304 0.000000 \n", + "385 0.000000 0.001414 0.000000 0.001414 0.000000 1.001414 0.002829 \n", + "\n", + "[386 rows x 21 columns]" + ] + } + ], + "prompt_number": 212 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def run_classifier(clf, x_train, x_test, y_train, y_test):\n", + " clf.fit(x_train, y_train)\n", + " predicted = clf.predict(x_test)\n", + " print(metrics.classification_report(y_test, predicted))\n", + " print(metrics.confusion_matrix(y_test, predicted))\n", + " print(metrics.f1_score(y_test, predicted))" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 142 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn.cross_validation import cross_val_score\n", + "from sklearn.naive_bayes import GaussianNB\n", + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.ensemble import RandomForestClassifier" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 143 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "tree = DecisionTreeClassifier()\n", + "run_classifier(tree, x_train, x_test, y_train, y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " precision recall f1-score support\n", + "\n", + " clojure 0.33 0.25 0.29 4\n", + " haskell 0.20 0.33 0.25 3\n", + " java 0.00 0.00 0.00 2\n", + " javascript 0.25 0.25 0.25 4\n", " ocaml 0.00 0.00 0.00 2\n", - " perl 0.00 0.00 0.00 0\n", " php 0.00 0.00 0.00 3\n", " python 0.00 0.00 0.00 4\n", - " ruby 0.50 0.67 0.57 3\n", + " ruby 0.00 0.00 0.00 3\n", " scala 0.00 0.00 0.00 2\n", " scheme 0.00 0.00 0.00 3\n", "\n", - "avg / total 0.32 0.20 0.22 30\n", + "avg / total 0.10 0.10 0.10 30\n", "\n", - "[[3 1 0 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 2 1 0 0 0 0 0]\n", - " [0 0 0 0 0 0 2 0 0 0 0]\n", - " [0 0 1 1 0 0 0 0 2 0 0]\n", - " [0 0 0 0 0 0 0 0 0 2 0]\n", - " [0 0 0 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 0 0 0 0 0 1 2]\n", - " [0 2 2 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 1 0 0 0 2 0 0]\n", - " [0 0 0 0 0 0 0 1 0 0 1]\n", - " [0 0 0 0 0 1 2 0 0 0 0]]\n", - "0.224761904762\n" + "[[1 1 0 1 0 0 1 0 0 0]\n", + " [0 1 1 0 0 0 0 0 1 0]\n", + " [0 0 0 0 0 1 0 0 1 0]\n", + " [1 2 0 1 0 0 0 0 0 0]\n", + " [0 0 0 1 0 0 0 1 0 0]\n", + " [0 0 0 0 0 0 2 1 0 0]\n", + " [0 1 0 0 0 0 0 3 0 0]\n", + " [0 0 1 0 0 0 0 0 2 0]\n", + " [1 0 0 0 1 0 0 0 0 0]\n", + " [0 0 0 1 0 1 0 1 0 0]]\n", + "0.0964285714286\n" ] } ], - "prompt_number": 191 + "prompt_number": 213 }, { "cell_type": "code", @@ -3963,36 +6468,36 @@ "text": [ " precision recall f1-score support\n", "\n", - " clojure 1.00 0.75 0.86 4\n", + " clojure 0.33 0.25 0.29 4\n", " haskell 0.00 0.00 0.00 3\n", " java 0.00 0.00 0.00 2\n", - " javascript 1.00 0.25 0.40 4\n", + " javascript 0.00 0.00 0.00 4\n", " ocaml 0.00 0.00 0.00 2\n", " perl 0.00 0.00 0.00 0\n", " php 0.00 0.00 0.00 3\n", " python 0.00 0.00 0.00 4\n", - " ruby 0.40 0.67 0.50 3\n", + " ruby 0.00 0.00 0.00 3\n", " scala 0.00 0.00 0.00 2\n", " scheme 0.00 0.00 0.00 3\n", "\n", - "avg / total 0.31 0.20 0.22 30\n", + "avg / total 0.04 0.03 0.04 30\n", "\n", - "[[3 1 0 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 2 1 0 0 0 0 0]\n", - " [0 0 0 0 0 0 2 0 0 0 0]\n", - " [0 0 1 1 0 0 0 0 2 0 0]\n", - " [0 0 0 0 0 0 0 2 0 0 0]\n", + "[[1 0 0 2 0 0 1 0 0 0 0]\n", + " [0 0 0 1 0 0 0 0 1 1 0]\n", + " [0 0 0 0 1 0 1 0 0 0 0]\n", + " [1 0 0 0 0 2 1 0 0 0 0]\n", + " [0 0 0 1 0 0 0 0 1 0 0]\n", " [0 0 0 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 0 0 0 0 1 0 2]\n", - " [0 2 2 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 1 0 0 0 2 0 0]\n", - " [0 0 0 0 0 0 0 1 0 0 1]\n", - " [0 0 0 0 0 1 2 0 0 0 0]]\n", - "0.217619047619\n" + " [0 0 0 0 0 0 0 3 0 0 0]\n", + " [0 0 0 0 0 1 0 0 2 1 0]\n", + " [0 1 0 0 0 1 0 0 0 0 1]\n", + " [1 0 0 0 1 0 0 0 0 0 0]\n", + " [0 0 0 0 0 0 2 0 1 0 0]]\n", + "0.0380952380952\n" ] } ], - "prompt_number": 192 + "prompt_number": 214 } ], "metadata": {} From 090e492a758addb836dba979618e5900d1afa9ce Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Sat, 14 Feb 2015 21:34:50 -0500 Subject: [PATCH 5/9] working classifier at 73 --- plc/Code Classifier.ipynb | 391 ++- plc/features.py | 6 + plc/random_guesser.py | 29 + plc/test/{1 => 01} | 0 plc/test/{2 => 02} | 0 plc/test/{3 => 03} | 0 plc/test/{4 => 04} | 0 plc/test/{5 => 05} | 0 plc/test/{6 => 06} | 0 plc/test/{7 => 07} | 0 plc/test/{8 => 08} | 0 plc/test/{9 => 09} | 0 plc/tests/test_features.py | 5 + plc/workbook.ipynb | 6558 +++++++++--------------------------- 14 files changed, 1878 insertions(+), 5111 deletions(-) create mode 100644 plc/random_guesser.py rename plc/test/{1 => 01} (100%) rename plc/test/{2 => 02} (100%) rename plc/test/{3 => 03} (100%) rename plc/test/{4 => 04} (100%) rename plc/test/{5 => 05} (100%) rename plc/test/{6 => 06} (100%) rename plc/test/{7 => 07} (100%) rename plc/test/{8 => 08} (100%) rename plc/test/{9 => 09} (100%) diff --git a/plc/Code Classifier.ipynb b/plc/Code Classifier.ipynb index 6461510..a7595b7 100644 --- a/plc/Code Classifier.ipynb +++ b/plc/Code Classifier.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:506a4c7268842306b7c8e76a3a9556459f92507e332006299787ba26f077df1d" + "signature": "sha256:aa35d7283b86da81f1512e49ff7045892454a5dc1ee2c5c3be305e6c1133bdc3" }, "nbformat": 3, "nbformat_minor": 0, @@ -14,12 +14,13 @@ "input": [ "from data_load import*\n", "from features import*\n", - "from classifier import*" + "from classifier import*\n", + "from random_guesser import*" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 55 + "prompt_number": 82 }, { "cell_type": "code", @@ -27,25 +28,29 @@ "input": [ "import os\n", "import pandas as pd\n", - "import re" + "import re\n", + "import random" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 56 + "prompt_number": 83 }, { "cell_type": "code", "collapsed": false, "input": [ "word_list = ['let', 'end', 'defn', 'function', 'fun', 'return', 'def', 'return', 'check', 'make', '->', '.format',\n", - " 'define', '::', 'done', 'type', 'rescue']\n", - "symbol_list = ['$', '^', ',', ';', '&', '|', '!']" + " 'define', '::', 'done', 'type', 'rescue', 'print', 'elif', 'clone', 'display', '$format', 'echo', 'str',\n", + " 'join', '&&', 'val', 'Nil', 'object', '<-', '--', 'lambda', 'var', '//', 'tmpl', 'public function',\n", + " 'stdlib', '=>', ]\n", + "symbol_list = ['$', '^', ',', ';', '&', '|', '!', '*', '@', '#']\n", + "endings = ['end', ')', '}']" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 57 + "prompt_number": 84 }, { "cell_type": "code", @@ -68,12 +73,17 @@ " y = character_ratio(code, char)\n", " return y\n", " df[char] = df.Code.apply(sub_function2)\n", + " for ending in endings:\n", + " def sub_function3(code):\n", + " z = string_end(ending, code)\n", + " return z\n", + " df['_' + ending] = df.Code.apply(sub_function3)\n", " return df" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 58 + "prompt_number": 85 }, { "cell_type": "code", @@ -84,7 +94,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 59 + "prompt_number": 86 }, { "cell_type": "code", @@ -95,7 +105,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 60 + "prompt_number": 87 }, { "cell_type": "code", @@ -115,12 +125,17 @@ " y = character_ratio(code, char)\n", " return y\n", " df[char] = df.Code.apply(sub_function2)\n", + " for ending in endings:\n", + " def sub_function3(code):\n", + " z = string_end(ending, code)\n", + " return z\n", + " df['_' + ending] = df.Code.apply(sub_function3)\n", " return df" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 61 + "prompt_number": 88 }, { "cell_type": "code", @@ -131,41 +146,40 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 62 + "prompt_number": 89 }, { "cell_type": "code", "collapsed": false, "input": [ - "#test_df" + "x_train, x_test, y_train, y_test = create_xy(df, test_df, word_list[0], 'Language')" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 69 + "prompt_number": 90 }, { "cell_type": "code", "collapsed": false, - "input": [ - "x_train, x_test, y_train, y_test = create_xy(df, test_df, word_list[0], 'Language')" - ], + "input": [], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 64 + "prompt_number": 90 }, { "cell_type": "code", "collapsed": false, "input": [ "from sklearn.naive_bayes import GaussianNB\n", - "from sklearn.tree import DecisionTreeClassifier" + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.naive_bayes import MultinomialNB " ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 65 + "prompt_number": 91 }, { "cell_type": "code", @@ -183,34 +197,34 @@ "text": [ " precision recall f1-score support\n", "\n", - " clojure 0.33 0.25 0.29 4\n", - " haskell 0.25 0.33 0.29 3\n", - " java 0.00 0.00 0.00 2\n", - " javascript 0.25 0.25 0.25 4\n", - " ocaml 0.00 0.00 0.00 2\n", - " php 0.00 0.00 0.00 3\n", - " python 0.00 0.00 0.00 4\n", - " ruby 0.00 0.00 0.00 3\n", - " scala 0.00 0.00 0.00 2\n", + " clojure 1.00 0.75 0.86 4\n", + " haskell 0.75 1.00 0.86 3\n", + " java 1.00 1.00 1.00 2\n", + " javascript 0.50 0.75 0.60 4\n", + " ocaml 1.00 0.50 0.67 2\n", + " php 1.00 0.67 0.80 3\n", + " python 1.00 0.25 0.40 4\n", + " ruby 0.40 0.67 0.50 3\n", + " scala 0.50 1.00 0.67 2\n", " scheme 0.00 0.00 0.00 3\n", "\n", - "avg / total 0.10 0.10 0.10 30\n", + "avg / total 0.71 0.63 0.62 30\n", "\n", - "[[1 0 0 2 0 0 1 0 0 0]\n", - " [0 1 1 0 0 0 0 0 1 0]\n", - " [0 0 0 0 0 1 0 0 1 0]\n", - " [1 2 0 1 0 0 0 0 0 0]\n", - " [0 0 0 1 0 0 0 1 0 0]\n", - " [0 0 0 0 0 0 2 1 0 0]\n", - " [0 1 0 0 0 0 0 3 0 0]\n", - " [0 0 1 0 0 0 0 0 2 0]\n", - " [1 0 0 0 1 0 0 0 0 0]\n", - " [0 0 0 0 0 2 0 1 0 0]]\n", - "0.1\n" + "[[3 0 0 0 0 0 0 1 0 0]\n", + " [0 3 0 0 0 0 0 0 0 0]\n", + " [0 0 2 0 0 0 0 0 0 0]\n", + " [0 0 0 3 0 0 0 0 1 0]\n", + " [0 1 0 0 1 0 0 0 0 0]\n", + " [0 0 0 0 0 2 0 0 1 0]\n", + " [0 0 0 1 0 0 1 1 0 1]\n", + " [0 0 0 0 0 0 0 2 0 1]\n", + " [0 0 0 0 0 0 0 0 2 0]\n", + " [0 0 0 2 0 0 0 1 0 0]]\n", + "0.618888888889\n" ] } ], - "prompt_number": 66 + "prompt_number": 92 }, { "cell_type": "code", @@ -228,36 +242,283 @@ "text": [ " precision recall f1-score support\n", "\n", - " clojure 0.25 0.25 0.25 4\n", - " haskell 0.00 0.00 0.00 3\n", - " java 0.00 0.00 0.00 2\n", - " javascript 0.00 0.00 0.00 4\n", - " ocaml 0.00 0.00 0.00 2\n", + " clojure 1.00 1.00 1.00 4\n", + " haskell 1.00 0.67 0.80 3\n", + " java 1.00 1.00 1.00 2\n", + " javascript 1.00 0.25 0.40 4\n", + " ocaml 1.00 1.00 1.00 2\n", " perl 0.00 0.00 0.00 0\n", - " php 0.00 0.00 0.00 3\n", - " python 0.20 0.25 0.22 4\n", - " ruby 0.00 0.00 0.00 3\n", + " php 0.33 1.00 0.50 3\n", + " python 1.00 1.00 1.00 4\n", + " ruby 1.00 0.33 0.50 3\n", " scala 0.00 0.00 0.00 2\n", - " scheme 0.00 0.00 0.00 3\n", + " scheme 1.00 1.00 1.00 3\n", "\n", - "avg / total 0.06 0.07 0.06 30\n", + "avg / total 0.87 0.73 0.73 30\n", "\n", - "[[1 0 0 2 0 0 1 0 0 0 0]\n", - " [1 0 0 1 0 1 0 0 0 0 0]\n", - " [0 0 0 0 1 0 1 0 0 0 0]\n", - " [1 0 0 0 1 1 1 0 0 0 0]\n", - " [0 0 0 1 0 0 0 1 0 0 0]\n", + "[[4 0 0 0 0 0 0 0 0 0 0]\n", + " [0 2 0 0 0 0 0 0 0 1 0]\n", + " [0 0 2 0 0 0 0 0 0 0 0]\n", + " [0 0 0 1 0 0 3 0 0 0 0]\n", + " [0 0 0 0 2 0 0 0 0 0 0]\n", " [0 0 0 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 0 0 0 3 0 0 0]\n", - " [0 0 0 0 0 1 1 1 1 0 0]\n", - " [0 1 0 0 0 0 0 0 0 0 2]\n", - " [1 0 0 0 1 0 0 0 0 0 0]\n", - " [0 0 0 0 1 0 2 0 0 0 0]]\n", - "0.062962962963\n" + " [0 0 0 0 0 0 3 0 0 0 0]\n", + " [0 0 0 0 0 0 0 4 0 0 0]\n", + " [0 0 0 0 0 1 1 0 1 0 0]\n", + " [0 0 0 0 0 0 2 0 0 0 0]\n", + " [0 0 0 0 0 0 0 0 0 0 3]]\n", + "0.733333333333\n" + ] + } + ], + "prompt_number": 93 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_string = \"\"\"import re\n", + "\n", + "def character_counter(code, char):\n", + " counter = 0\n", + " for _ in code:\n", + " if _ == char:\n", + " counter+=1\n", + " return counter\n", + "\n", + "def character_ratio(code, char):\n", + " value = character_counter(code, char)/len(code)\n", + " return value\n", + "\n", + "def string_finder(string, code):\n", + " value = len(re.findall(string, code))\n", + " return value\n", + "\n", + "def string_ratio(string, code):\n", + " value = string_finder(string, code)/len(code)\n", + " return value\n", + "\n", + "def string_end(string, code):\n", + " if code.endswith(string):\n", + " return 10\n", + " else:\n", + " return 0\"\"\"" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 94 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_list=[test_string]" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 95 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "xdf = pd.DataFrame(test_list, index=range(1), columns=['Code'])" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 96 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 96 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def x_data_frame_generator(df):\n", + " for string in word_list:\n", + " def sub_function(code):\n", + " x = string_ratio(string, code)\n", + " return x\n", + " df[string] = df.Code.apply(sub_function)\n", + " for char in symbol_list:\n", + " def sub_function2(code):\n", + " y = character_ratio(code, char)\n", + " return y\n", + " df[char] = df.Code.apply(sub_function2)\n", + " for ending in endings:\n", + " def sub_function3(code):\n", + " z = string_end(ending, code)\n", + " return z\n", + " df['_' + ending] = df.Code.apply(sub_function3)\n", + " return df" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 97 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "xdf = x_data_frame_generator(xdf)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 98 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "xdf" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Codeletenddefnfunctionfunreturndefcheckmake...;&|!*@#_end_)_}
0 import re\\n\\ndef character_counter(code, char)... 0 0.003663 0 0 0 0.010989 0.009158 0 0... 0 0 0 0 0 0 0 0 0 0
\n", + "

1 rows \u00d7 51 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 99, + "text": [ + " Code let end defn \\\n", + "0 import re\\n\\ndef character_counter(code, char)... 0 0.003663 0 \n", + "\n", + " function fun return def check make ... ; & | ! * @ # \\\n", + "0 0 0 0.010989 0.009158 0 0 ... 0 0 0 0 0 0 0 \n", + "\n", + " _end _) _} \n", + "0 0 0 0 \n", + "\n", + "[1 rows x 51 columns]" + ] + } + ], + "prompt_number": 99 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "n = gauss.predict_proba(xdf.loc[:, 'let':])" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 100 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 101, + "text": [ + "array([[ 0.00000000e+000, 0.00000000e+000, 0.00000000e+000,\n", + " 0.00000000e+000, 0.00000000e+000, 9.05283150e-071,\n", + " 9.48911785e-060, 1.00000000e+000, 1.13311483e-064,\n", + " 1.47138138e-306, 0.00000000e+000]])" + ] + } + ], + "prompt_number": 101 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "random_guesser(y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 102, + "text": [ + "0.13333333333333333" ] } ], - "prompt_number": 67 + "prompt_number": 102 } ], "metadata": {} diff --git a/plc/features.py b/plc/features.py index 328db60..4df7f87 100644 --- a/plc/features.py +++ b/plc/features.py @@ -18,3 +18,9 @@ def string_finder(string, code): def string_ratio(string, code): value = string_finder(string, code)/len(code) return value + +def string_end(string, code): + if code.endswith(string): + return 10 + else: + return 0 diff --git a/plc/random_guesser.py b/plc/random_guesser.py new file mode 100644 index 0000000..d155743 --- /dev/null +++ b/plc/random_guesser.py @@ -0,0 +1,29 @@ +import random + +def random_guesser(y_test): + lang_list = ['clojure', 'python', 'javascript', 'ruby', 'haskell', 'scheme', 'java', 'scala', 'php', 'ocaml'] + correct_count = 0 + total_count = 0 + for answer in y_test: + if answer == random.choice(lang_list): + correct_count+=1 + total_count+=1 + else: + total_count+=1 + return correct_count/total_count + + +def average_of_random_guesser(y_test, number): + alist = [] + for num in range(number): + alist.append(random_guesser(y_test)) + x = sum(alist)/len(alist) + return x + + +def max_of_random_guesser(y_test, number): + alist = [] + for num in range(number): + alist.append(random_guesser(y_test)) + x = max(alist) + return x diff --git a/plc/test/1 b/plc/test/01 similarity index 100% rename from plc/test/1 rename to plc/test/01 diff --git a/plc/test/2 b/plc/test/02 similarity index 100% rename from plc/test/2 rename to plc/test/02 diff --git a/plc/test/3 b/plc/test/03 similarity index 100% rename from plc/test/3 rename to plc/test/03 diff --git a/plc/test/4 b/plc/test/04 similarity index 100% rename from plc/test/4 rename to plc/test/04 diff --git a/plc/test/5 b/plc/test/05 similarity index 100% rename from plc/test/5 rename to plc/test/05 diff --git a/plc/test/6 b/plc/test/06 similarity index 100% rename from plc/test/6 rename to plc/test/06 diff --git a/plc/test/7 b/plc/test/07 similarity index 100% rename from plc/test/7 rename to plc/test/07 diff --git a/plc/test/8 b/plc/test/08 similarity index 100% rename from plc/test/8 rename to plc/test/08 diff --git a/plc/test/9 b/plc/test/09 similarity index 100% rename from plc/test/9 rename to plc/test/09 diff --git a/plc/tests/test_features.py b/plc/tests/test_features.py index f8de69d..e297bf7 100644 --- a/plc/tests/test_features.py +++ b/plc/tests/test_features.py @@ -19,3 +19,8 @@ def test_string_finder(): max_depth = max (min_depth + 2) nlet stretch_depth = max_depth + 1""") assert string_finder("let", test2code) == 4 + +def test_string_end(): + test3code = "boring test string()" + assert string_end("ing()", test3code) == 10 + assert string_end("monkey", test3code) == 0 diff --git a/plc/workbook.ipynb b/plc/workbook.ipynb index c4b7079..6c4c68c 100644 --- a/plc/workbook.ipynb +++ b/plc/workbook.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:40570cfaf8cdd3aad2186afd0616a0c01503a5cc2774f3bbc4fa0964e6c3400d" + "signature": "sha256:026ede5bff2ce1025c2313e6c6dd589dcb79c50220a5e50673fd0d724593951e" }, "nbformat": 3, "nbformat_minor": 0, @@ -19,7 +19,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 119 + "prompt_number": 249 }, { "cell_type": "code", @@ -69,7 +69,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 20 + "prompt_number": 250 }, { "cell_type": "code", @@ -85,7 +85,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 21 + "prompt_number": 251 }, { "cell_type": "code", @@ -104,7 +104,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 22 + "prompt_number": 252 }, { "cell_type": "code", @@ -115,7 +115,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 23 + "prompt_number": 253 }, { "cell_type": "code", @@ -129,13 +129,13 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 24, + "prompt_number": 254, "text": [ "386" ] } ], - "prompt_number": 24 + "prompt_number": 254 }, { "cell_type": "code", @@ -156,7 +156,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 25 + "prompt_number": 255 }, { "cell_type": "code", @@ -167,7 +167,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 26 + "prompt_number": 256 }, { "cell_type": "code", @@ -181,13 +181,13 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 27, + "prompt_number": 257, "text": [ "386" ] } ], - "prompt_number": 27 + "prompt_number": 257 }, { "cell_type": "code", @@ -198,7 +198,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 28 + "prompt_number": 258 }, { "cell_type": "code", @@ -210,7 +210,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 29 + "prompt_number": 259 }, { "cell_type": "code", @@ -221,7 +221,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 30 + "prompt_number": 260 }, { "cell_type": "code", @@ -556,7 +556,7 @@ ], "metadata": {}, "output_type": "pyout", - "prompt_number": 31, + "prompt_number": 261, "text": [ " Language Code\n", "0 clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", @@ -625,7 +625,7 @@ ] } ], - "prompt_number": 31 + "prompt_number": 261 }, { "cell_type": "code", @@ -639,13 +639,13 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 32, + "prompt_number": 262, "text": [ "'--\\n-- The Computer Language Benchmarks Game\\n-- http://benchmarksgame.alioth.debian.org/\\n--\\n-- Contributed by Don Stewart\\n--\\n\\nimport System.Environment\\nimport Data.Bits\\nimport Text.Printf\\n\\n--\\n-- an artificially strict tree. \\n--\\n-- normally you would ensure the branches are lazy, but this benchmark\\n-- requires strict allocation.\\n--\\ndata Tree = Nil | Node !Int !Tree !Tree\\n\\nminN = 4\\n\\nio s n t = printf \"%s of depth %d\\\\t check: %d\\\\n\" s n t\\n\\nmain = do\\n n <- getArgs >>= readIO . head\\n let maxN = max (minN + 2) n\\n stretchN = maxN + 1\\n\\n -- stretch memory tree\\n let c = check (make 0 stretchN)\\n io \"stretch tree\" stretchN c\\n\\n -- allocate a long lived tree\\n let !long = make 0 maxN\\n\\n -- allocate, walk, and deallocate many bottom-up binary trees\\n let vs = depth minN maxN\\n mapM_ (\\\\((m,d,i)) -> io (show m ++ \"\\\\t trees\") d i) vs\\n\\n -- confirm the the long-lived binary tree still exists\\n io \"long lived tree\" maxN (check long)\\n\\n-- generate many trees\\ndepth :: Int -> Int -> [(Int,Int,Int)]\\ndepth d m\\n | d <= m = (2*n,d,sumT d n 0) : depth (d+2) m\\n | otherwise = []\\n where n = 1 `shiftL` (m - d + minN)\\n\\n-- allocate and check lots of trees\\nsumT :: Int -> Int -> Int -> Int\\nsumT d 0 t = t\\nsumT d i t = sumT d (i-1) (t + a + b)\\n where a = check (make i d)\\n b = check (make (-i) d)\\n\\n-- traverse the tree, counting up the nodes\\ncheck :: Tree -> Int\\ncheck Nil = 0\\ncheck (Node i l r) = i + check l - check r\\n\\n-- build a tree\\nmake :: Int -> Int -> Tree\\nmake i 0 = Node i Nil Nil\\nmake i d = Node i (make (i2-1) d2) (make i2 d2)\\n where i2 = 2*i; d2 = d-1\\n'" ] } ], - "prompt_number": 32 + "prompt_number": 262 }, { "cell_type": "code", @@ -657,7 +657,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 33 + "prompt_number": 263 }, { "cell_type": "code", @@ -678,7 +678,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 67 + "prompt_number": 264 }, { "cell_type": "code", @@ -701,7 +701,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 78 + "prompt_number": 265 }, { "cell_type": "code", @@ -718,7 +718,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 116 + "prompt_number": 266 }, { "cell_type": "code", @@ -729,7 +729,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 34 + "prompt_number": 267 }, { "cell_type": "code", @@ -741,7 +741,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 197 + "prompt_number": 268 }, { "cell_type": "code", @@ -764,7 +764,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 194 + "prompt_number": 269 }, { "cell_type": "code", @@ -775,13 +775,190 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 198 + "prompt_number": 270 }, { "cell_type": "code", "collapsed": false, "input": [ - "df" + "#df" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 271 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 271 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from textblob import TextBlob" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 272 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def code_lookup(df, num):\n", + " codeblob = TextBlob(df.iloc[num-1]['Code'])\n", + " print(df.iloc[num-1]['Language'])\n", + " print(\"\")\n", + " print(codeblob)\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 273 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "code_lookup(test_df, 13)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "ruby\n", + "\n", + "(define add1\n", + " (lambda (n) (+ n 1)))\n" + ] + } + ], + "prompt_number": 274 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def tcode_sucker():\n", + " codelist = []\n", + " for subdir, dirs, files in os.walk(\"test/\"):\n", + " for fname in files:\n", + " with open(os.path.join(subdir, fname)) as current_file:\n", + " codelist.append(current_file.read()) \n", + " return codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 275 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def tdata_frame_generator():\n", + " test_codelist = tcode_sucker()\n", + " df = pd.read_csv(\"test.csv\")\n", + " df[\"Code\"] = test_codelist\n", + " for string in word_list:\n", + " def sub_function(code):\n", + " x = string_ratio(string, code)\n", + " return x\n", + " df[string] = df.Code.apply(sub_function)\n", + " return df" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 276 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df = tdata_frame_generator()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 277 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "codelist=tcode_sucker()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 278 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 279, + "text": [ + "['(defn cf-settings\\n \"Setup settings for campfire. Required information is your api-token, ssl connection\\n true or false, and your campfire sub-domain.\"\\n [token ssl sub-domain]\\n {:api-token token, :ssl ssl, :sub-domain sub-domain})\\n\\n(defn room\\n \"Sets up the room to send events too. Pass in the settings created with cf-settings\\n and the room name\"\\n [settings room-name]\\n (cf/room-by-name settings room-name))\\n\\n(defn campfire_message\\n \"Formats an event into a string\"\\n [e]\\n (str (join \" \" [\"Riemann alert on\" (str (:host e)) \"-\" (str (:service e)) \"is\" (upper-case (str (:state e))) \"- Description:\" (str (:description e))])))\\n\\n(defn campfire\\n \"Creates an adaptor to forward events to campfire. The campfire event will\\n contain the host, state, service, metric and description.\\n Tested with:\\n (streams\\n (by [:host, :service]\\n (let [camp (campfire \\\\\"token\\\\\", true, \\\\\"sub-domain\\\\\", \\\\\"room\\\\\")]\\n camp)))\"\\n [token ssl sub-domain room-name]\\n (fn [e]\\n (let [message_string (campfire_message e)\\n settings (cf-settings token ssl sub-domain)]\\n (cf/message (room settings room-name) message_string))))',\n", + " '(ns my-cli.core)\\n\\n(defn -main [& args]\\n (println \"My CLI received arguments:\" args))\\n\\n(defn add-main [& args]\\n (->> (map #(Integer/parseInt %) args)\\n (reduce + 0)\\n (println \"The sum is:\")))',\n", + " '(extend-type String\\n Person\\n (first-name [s] (first (clojure.string/split s #\" \")))\\n (last-name [s] (second (clojure.string/split s #\" \"))))',\n", + " '(require \\'[overtone.live :as overtone])\\n\\n(defn note [timing pitch] {:time timing :pitch pitch})\\n\\n(def melody\\n (let [pitches\\n [0 0 0 1 2\\n ; Row, row, row your boat,\\n 2 1 2 3 4\\n ; Gently down the stream,\\n 7 7 7 4 4 4 2 2 2 0 0 0\\n ; (take 4 (repeat \"merrily\"))\\n 4 3 2 1 0]\\n ; Life is but a dream!\\n durations\\n [1 1 2/3 1/3 1\\n 2/3 1/3 2/3 1/3 2\\n 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3\\n 2/3 1/3 2/3 1/3 2]\\n times (reductions + 0 durations)]\\n (map note times pitches)))',\n", + " 'from pkgutil import iter_modules\\nfrom subprocess import call\\n\\ndependencies = {\\n \"Crypto\": \"crypto\",\\n \"dpkt\": \"dpkt\",\\n \"IPy\": \"ipy\",\\n \"pcap\": \"pypcap\"\\n}\\n\\ninstalled, missing_pkgs = [pkg[1] for pkg in iter_modules()], []\\n\\nfor module, pkg in dependencies.items():\\n if module not in installed:\\n print(\"dshell requires {}\".format(module))\\n missing_pkgs.append(\"python-{}\".format(pkg))\\n else:\\n print(\"{} is installed\".format(module))\\n\\nif missing_pkgs:\\n cmd = [\"sudo\", \"apt-get\", \"install\"] + missing_pkgs\\n\\n print(\" \".join(cmd))\\n call(cmd)\\n\\ncall([\"make\", \"all\"])',\n", + " \"import re\\nimport subprocess\\n\\ndef cmd_keymap_table():\\n return subprocess.Popen(\\n ['xmodmap','-pk'], stdout=subprocess.PIPE).communicate()[0]\\n\\ndef cmd_modifier_map():\\n return subprocess.Popen(\\n ['xmodmap','-pm'], stdout=subprocess.PIPE).communicate()[0]\\n\\ndef get_keymap_table():\\n keymap = {}\\n\\n keymap_table = cmd_keymap_table()\\n\\n re_line = re.compile(r'0x\\\\w+')\\n for line in keymap_table.split('\\\\n')[1:]:\\n if len(line) > 0:\\n keycode = re.search(r'\\\\s+(\\\\d+).*', line)\\n if keycode:\\n new_keysyms = []\\n keycode = int(keycode.group(1))\\n keysyms = re_line.findall(line)\\n # When you press only one key\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[0], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n # When you press a key plus Shift key\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[1], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n # When you press a key plus meta (dead keys)\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[4], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n # When you press a key plus meta plus Shift key\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[5], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n \\t\\t#keymap[keycode-8] = new_keysyms\\n \\t\\tkeymap[keycode] = new_keysyms\\n\\n return keymap\\n\\ndef get_modifier_map():\\n modifiers = {}\\n\\n modifier_map = cmd_modifier_map()\\n\\n re_line = re.compile(r'(0x\\\\w+)')\\n for line in modifier_map.split('\\\\n')[1:]:\\n if len(line) > 0:\\n mod_name = re.match(r'(\\\\w+).*', line)\\n if mod_name:\\n mod_name = mod_name.group(1)\\n keycodes = re_line.findall(line)\\n # Convert key codes from hex to dec for use them\\n # with the keymap table\\n keycodes =[ int(kc, 16) for kc in keycodes]\\n \\n modifiers[mod_name] = keycodes\\n\\n return modifiers\",\n", + " 'class NoSuchService(Exception):\\n def __init__(self, name):\\n self.name = name\\n self.msg = \"No such service: %s\" % self.name\\n\\n def __str__(self):\\n return self.msg\\n\\n\\nclass ConfigurationError(Exception):\\n def __init__(self, msg):\\n self.msg = msg\\n\\n def __str__(self):\\n return self.msg',\n", + " 'from collections import namedtuple\\nimport functools\\nimport heapq\\nimport itertools\\nimport logging\\nimport Queue\\nimport random\\nimport threading\\n\\n# data types\\nProposal = namedtuple(\\'Proposal\\', [\\'caller\\', \\'client_id\\', \\'input\\'])\\nBallot = namedtuple(\\'Ballot\\', [\\'n\\', \\'leader\\'])\\n\\n# message types\\nAccepted = namedtuple(\\'Accepted\\', [\\'slot\\', \\'ballot_num\\'])\\nAccept = namedtuple(\\'Accept\\', [\\'slot\\', \\'ballot_num\\', \\'proposal\\'])\\nDecision = namedtuple(\\'Decision\\', [\\'slot\\', \\'proposal\\'])\\nInvoked = namedtuple(\\'Invoked\\', [\\'client_id\\', \\'output\\'])\\nInvoke = namedtuple(\\'Invoke\\', [\\'caller\\', \\'client_id\\', \\'input_value\\'])\\nJoin = namedtuple(\\'Join\\', [])\\nActive = namedtuple(\\'Active\\', [])\\nPrepare = namedtuple(\\'Prepare\\', [\\'ballot_num\\'])\\nPromise = namedtuple(\\'Promise\\', [\\'ballot_num\\', \\'accepted_proposals\\'])\\nPropose = namedtuple(\\'Propose\\', [\\'slot\\', \\'proposal\\'])\\nWelcome = namedtuple(\\'Welcome\\', [\\'state\\', \\'slot\\', \\'decisions\\'])\\nDecided = namedtuple(\\'Decided\\', [\\'slot\\'])\\nPreempted = namedtuple(\\'Preempted\\', [\\'slot\\', \\'preempted_by\\'])\\nAdopted = namedtuple(\\'Adopted\\', [\\'ballot_num\\', \\'accepted_proposals\\'])\\nAccepting = namedtuple(\\'Accepting\\', [\\'leader\\'])\\n\\n# constants - these times should really be in terms of average round-trip time\\nJOIN_RETRANSMIT = 0.7\\nCATCHUP_INTERVAL = 0.6\\nACCEPT_RETRANSMIT = 1.0\\nPREPARE_RETRANSMIT = 1.0\\nINVOKE_RETRANSMIT = 0.5\\nLEADER_TIMEOUT = 1.0\\nNULL_BALLOT = Ballot(-1, -1) # sorts before all real ballots\\nNOOP_PROPOSAL = Proposal(None, None, None) # no-op to fill otherwise empty slots\\n\\nclass Node(object):\\n unique_ids = itertools.count()\\n\\n def __init__(self, network, address):\\n self.network = network\\n self.address = address or \\'N%d\\' % self.unique_ids.next()\\n self.logger = SimTimeLogger(logging.getLogger(self.address), {\\'network\\': self.network})\\n self.logger.info(\\'starting\\')\\n self.roles = []\\n self.send = functools.partial(self.network.send, self)\\n\\n def register(self, roles):\\n self.roles.append(roles)\\n\\n def unregister(self, roles):\\n self.roles.remove(roles)\\n\\n def receive(self, sender, message):\\n handler_name = \\'do_%s\\' % type(message).__name__\\n\\n for comp in self.roles[:]:\\n if not hasattr(comp, handler_name):\\n continue\\n comp.logger.debug(\"received %s from %s\", message, sender)\\n fn = getattr(comp, handler_name)\\n fn(sender=sender, **message._asdict())\\n\\nclass Timer(object):\\n\\n def __init__(self, expires, address, callback):\\n self.expires = expires\\n self.address = address\\n self.callback = callback\\n self.cancelled = False\\n\\n def __cmp__(self, other):\\n return cmp(self.expires, other.expires)\\n\\n def cancel(self):\\n self.cancelled = True\\n\\nclass Network(object):\\n PROP_DELAY = 0.03\\n PROP_JITTER = 0.02\\n DROP_PROB = 0.05\\n\\n def __init__(self, seed):\\n self.nodes = {}\\n self.rnd = random.Random(seed)\\n self.timers = []\\n self.now = 1000.0\\n\\n def new_node(self, address=None):\\n node = Node(self, address=address)\\n self.nodes[node.address] = node\\n return node\\n\\n def run(self):\\n while self.timers:\\n next_timer = self.timers[0]\\n if next_timer.expires > self.now:\\n self.now = next_timer.expires\\n heapq.heappop(self.timers)\\n if next_timer.cancelled:\\n continue\\n if not next_timer.address or next_timer.address in self.nodes:\\n next_timer.callback()\\n\\n def stop(self):\\n self.timers = []\\n\\n def set_timer(self, address, seconds, callback):\\n timer = Timer(self.now + seconds, address, callback)\\n heapq.heappush(self.timers, timer)\\n return timer\\n\\n def send(self, sender, destinations, message):\\n sender.logger.debug(\"sending %s to %s\", message, destinations)\\n for dest in (d for d in destinations if d in self.nodes):\\n if dest == sender.address:\\n # reliably deliver local messages with no delay\\n self.set_timer(sender.address, 0, lambda: sender.receive(sender.address, message))\\n elif self.rnd.uniform(0, 1.0) > self.DROP_PROB:\\n delay = self.PROP_DELAY + self.rnd.uniform(-self.PROP_JITTER, self.PROP_JITTER)\\n self.set_timer(dest, delay, functools.partial(self.nodes[dest].receive,\\n sender.address, message))\\n\\nclass SimTimeLogger(logging.LoggerAdapter):\\n\\n def process(self, msg, kwargs):\\n return \"T=%.3f %s\" % (self.extra[\\'network\\'].now, msg), kwargs\\n\\n def getChild(self, name):\\n return self.__class__(self.logger.getChild(name),\\n {\\'network\\': self.extra[\\'network\\']})\\n\\nclass Role(object):\\n\\n def __init__(self, node):\\n self.node = node\\n self.node.register(self)\\n self.running = True\\n self.logger = node.logger.getChild(type(self).__name__)\\n\\n def set_timer(self, seconds, callback):\\n return self.node.network.set_timer(self.node.address, seconds,\\n lambda: self.running and callback())\\n\\n def stop(self):\\n self.running = False\\n self.node.unregister(self)\\n\\nclass Acceptor(Role):\\n\\n def __init__(self, node):\\n super(Acceptor, self).__init__(node)\\n self.ballot_num = NULL_BALLOT\\n self.accepted_proposals = {} # {slot: (ballot_num, proposal)}\\n\\n def do_Prepare(self, sender, ballot_num):\\n if ballot_num > self.ballot_num:\\n self.ballot_num = ballot_num\\n # we\\'ve heard from a scout, so it might be the next leader\\n self.node.send([self.node.address], Accepting(leader=sender))\\n\\n self.node.send([sender], Promise(ballot_num=self.ballot_num, accepted_proposals=self.accepted_proposals))\\n\\n def do_Accept(self, sender, ballot_num, slot, proposal):\\n if ballot_num >= self.ballot_num:\\n self.ballot_num = ballot_num\\n acc = self.accepted_proposals\\n if slot not in acc or acc[slot][0] < ballot_num:\\n acc[slot] = (ballot_num, proposal)\\n\\n self.node.send([sender], Accepted(\\n slot=slot, ballot_num=self.ballot_num))\\n\\nclass Replica(Role):\\n\\n def __init__(self, node, execute_fn, state, slot, decisions, peers):\\n super(Replica, self).__init__(node)\\n self.execute_fn = execute_fn\\n self.state = state\\n self.slot = slot\\n self.decisions = decisions.copy()\\n self.peers = peers\\n self.proposals = {}\\n # next slot num for a proposal (may lead slot)\\n self.next_slot = slot\\n self.latest_leader = None\\n self.latest_leader_timeout = None\\n\\n # making proposals\\n\\n def do_Invoke(self, sender, caller, client_id, input_value):\\n proposal = Proposal(caller, client_id, input_value)\\n slot = next((s for s, p in self.proposals.iteritems() if p == proposal), None)\\n # propose, or re-propose if this proposal already has a slot\\n self.propose(proposal, slot)\\n\\n def propose(self, proposal, slot=None):\\n \"\"\"Send (or resend, if slot is specified) a proposal to the leader\"\"\"\\n if not slot:\\n slot, self.next_slot = self.next_slot, self.next_slot + 1\\n self.proposals[slot] = proposal\\n # find a leader we think is working - either the latest we know of, or\\n # ourselves (which may trigger a scout to make us the leader)\\n leader = self.latest_leader or self.node.address\\n self.logger.info(\"proposing %s at slot %d to leader %s\" % (proposal, slot, leader))\\n self.node.send([leader], Propose(slot=slot, proposal=proposal))\\n\\n # handling decided proposals\\n\\n def do_Decision(self, sender, slot, proposal):\\n assert not self.decisions.get(self.slot, None), \\\\\\n \"next slot to commit is already decided\"\\n if slot in self.decisions:\\n assert self.decisions[slot] == proposal, \\\\\\n \"slot %d already decided with %r!\" % (slot, self.decisions[slot])\\n return\\n self.decisions[slot] = proposal\\n self.next_slot = max(self.next_slot, slot + 1)\\n\\n # re-propose our proposal in a new slot if it lost its slot and wasn\\'t a no-op\\n our_proposal = self.proposals.get(slot)\\n if our_proposal is not None and our_proposal != proposal and our_proposal.caller:\\n self.propose(our_proposal)\\n\\n # execute any pending, decided proposals\\n while True:\\n commit_proposal = self.decisions.get(self.slot)\\n if not commit_proposal:\\n break # not decided yet\\n commit_slot, self.slot = self.slot, self.slot + 1\\n\\n self.commit(commit_slot, commit_proposal)\\n\\n def commit(self, slot, proposal):\\n \"\"\"Actually commit a proposal that is decided and in sequence\"\"\"\\n decided_proposals = [p for s, p in self.decisions.iteritems() if s < slot]\\n if proposal in decided_proposals:\\n self.logger.info(\"not committing duplicate proposal %r at slot %d\", proposal, slot)\\n return # duplicate\\n\\n self.logger.info(\"committing %r at slot %d\" % (proposal, slot))\\n if proposal.caller is not None:\\n # perform a client operation\\n self.state, output = self.execute_fn(self.state, proposal.input)\\n self.node.send([proposal.caller], Invoked(client_id=proposal.client_id, output=output))\\n\\n # tracking the leader\\n\\n def do_Adopted(self, sender, ballot_num, accepted_proposals):\\n self.latest_leader = self.node.address\\n self.leader_alive()\\n\\n def do_Accepting(self, sender, leader):\\n self.latest_leader = leader\\n self.leader_alive()\\n\\n def do_Active(self, sender):\\n if sender != self.latest_leader:\\n return\\n self.leader_alive()\\n\\n def leader_alive(self):\\n if self.latest_leader_timeout:\\n self.latest_leader_timeout.cancel()\\n\\n def reset_leader():\\n idx = self.peers.index(self.latest_leader)\\n self.latest_leader = self.peers[(idx + 1) % len(self.peers)]\\n self.logger.debug(\"leader timed out; tring the next one, %s\", self.latest_leader)\\n self.latest_leader_timeout = self.set_timer(LEADER_TIMEOUT, reset_leader)\\n\\n # adding new cluster members\\n\\n def do_Join(self, sender):\\n if sender in self.peers:\\n self.node.send([sender], Welcome(\\n state=self.state, slot=self.slot, decisions=self.decisions))\\n\\nclass Commander(Role):\\n\\n def __init__(self, node, ballot_num, slot, proposal, peers):\\n super(Commander, self).__init__(node)\\n self.ballot_num = ballot_num\\n self.slot = slot\\n self.proposal = proposal\\n self.acceptors = set([])\\n self.peers = peers\\n self.quorum = len(peers) / 2 + 1\\n\\n def start(self):\\n self.node.send(set(self.peers) - self.acceptors, Accept(\\n slot=self.slot, ballot_num=self.ballot_num, proposal=self.proposal))\\n self.set_timer(ACCEPT_RETRANSMIT, self.start)\\n\\n def finished(self, ballot_num, preempted):\\n if preempted:\\n self.node.send([self.node.address], Preempted(slot=self.slot, preempted_by=ballot_num))\\n else:\\n self.node.send([self.node.address], Decided(slot=self.slot))\\n self.stop()\\n\\n def do_Accepted(self, sender, slot, ballot_num):\\n if slot != self.slot:\\n return\\n if ballot_num == self.ballot_num:\\n self.acceptors.add(sender)\\n if len(self.acceptors) < self.quorum:\\n return\\n self.node.send(self.peers, Decision(slot=self.slot, proposal=self.proposal))\\n self.finished(ballot_num, False)\\n else:\\n self.finished(ballot_num, True)\\n\\nclass Scout(Role):\\n\\n def __init__(self, node, ballot_num, peers):\\n super(Scout, self).__init__(node)\\n self.ballot_num = ballot_num\\n self.accepted_proposals = {}\\n self.acceptors = set([])\\n self.peers = peers\\n self.quorum = len(peers) / 2 + 1\\n self.retransmit_timer = None\\n\\n def start(self):\\n self.logger.info(\"scout starting\")\\n self.send_prepare()\\n\\n def send_prepare(self):\\n self.node.send(self.peers, Prepare(ballot_num=self.ballot_num))\\n self.retransmit_timer = self.set_timer(PREPARE_RETRANSMIT, self.send_prepare)\\n\\n def update_accepted(self, accepted_proposals):\\n acc = self.accepted_proposals\\n for slot, (ballot_num, proposal) in accepted_proposals.iteritems():\\n if slot not in acc or acc[slot][0] < ballot_num:\\n acc[slot] = (ballot_num, proposal)\\n\\n def do_Promise(self, sender, ballot_num, accepted_proposals):\\n if ballot_num == self.ballot_num:\\n self.logger.info(\"got matching promise; need %d\" % self.quorum)\\n self.update_accepted(accepted_proposals)\\n self.acceptors.add(sender)\\n if len(self.acceptors) >= self.quorum:\\n # strip the ballot numbers from self.accepted_proposals, now that it\\n # represents a majority\\n accepted_proposals = dict((s, p) for s, (b, p) in self.accepted_proposals.iteritems())\\n # We\\'re adopted; note that this does *not* mean that no other leader is active.\\n # Any such conflicts will be handled by the commanders.\\n self.node.send([self.node.address],\\n Adopted(ballot_num=ballot_num, accepted_proposals=accepted_proposals))\\n self.stop()\\n else:\\n # this acceptor has promised another leader a higher ballot number, so we\\'ve lost\\n self.node.send([self.node.address], Preempted(slot=None, preempted_by=ballot_num))\\n self.stop()\\n\\nclass Leader(Role):\\n\\n def __init__(self, node, peers, commander_cls=Commander, scout_cls=Scout):\\n super(Leader, self).__init__(node)\\n self.ballot_num = Ballot(0, node.address)\\n self.active = False\\n self.proposals = {}\\n self.commander_cls = commander_cls\\n self.scout_cls = scout_cls\\n self.scouting = False\\n self.peers = peers\\n\\n def start(self):\\n # reminder others we\\'re active before LEADER_TIMEOUT expires\\n def active():\\n if self.active:\\n self.node.send(self.peers, Active())\\n self.set_timer(LEADER_TIMEOUT / 2.0, active)\\n active()\\n\\n def spawn_scout(self):\\n assert not self.scouting\\n self.scouting = True\\n self.scout_cls(self.node, self.ballot_num, self.peers).start()\\n\\n def do_Adopted(self, sender, ballot_num, accepted_proposals):\\n self.scouting = False\\n self.proposals.update(accepted_proposals)\\n # note that we don\\'t re-spawn commanders here; if there are undecided\\n # proposals, the replicas will re-propose\\n self.logger.info(\"leader becoming active\")\\n self.active = True\\n\\n def spawn_commander(self, ballot_num, slot):\\n proposal = self.proposals[slot]\\n self.commander_cls(self.node, ballot_num, slot, proposal, self.peers).start()\\n\\n def do_Preempted(self, sender, slot, preempted_by):\\n if not slot: # from the scout\\n self.scouting = False\\n self.logger.info(\"leader preempted by %s\", preempted_by.leader)\\n self.active = False\\n self.ballot_num = Ballot((preempted_by or self.ballot_num).n + 1, self.ballot_num.leader)\\n\\n def do_Propose(self, sender, slot, proposal):\\n if slot not in self.proposals:\\n if self.active:\\n self.proposals[slot] = proposal\\n self.logger.info(\"spawning commander for slot %d\" % (slot,))\\n self.spawn_commander(self.ballot_num, slot)\\n else:\\n if not self.scouting:\\n self.logger.info(\"got PROPOSE when not active - scouting\")\\n self.spawn_scout()\\n else:\\n self.logger.info(\"got PROPOSE while scouting; ignored\")\\n else:\\n self.logger.info(\"got PROPOSE for a slot already being proposed\")\\n\\nclass Bootstrap(Role):\\n\\n def __init__(self, node, peers, execute_fn,\\n replica_cls=Replica, acceptor_cls=Acceptor, leader_cls=Leader,\\n commander_cls=Commander, scout_cls=Scout):\\n super(Bootstrap, self).__init__(node)\\n self.execute_fn = execute_fn\\n self.peers = peers\\n self.peers_cycle = itertools.cycle(peers)\\n self.replica_cls = replica_cls\\n self.acceptor_cls = acceptor_cls\\n self.leader_cls = leader_cls\\n self.commander_cls = commander_cls\\n self.scout_cls = scout_cls\\n\\n def start(self):\\n self.join()\\n\\n def join(self):\\n self.node.send([next(self.peers_cycle)], Join())\\n self.set_timer(JOIN_RETRANSMIT, self.join)\\n\\n def do_Welcome(self, sender, state, slot, decisions):\\n self.acceptor_cls(self.node)\\n self.replica_cls(self.node, execute_fn=self.execute_fn, peers=self.peers,\\n state=state, slot=slot, decisions=decisions)\\n self.leader_cls(self.node, peers=self.peers, commander_cls=self.commander_cls,\\n scout_cls=self.scout_cls).start()\\n self.stop()\\n\\nclass Seed(Role):\\n\\n def __init__(self, node, initial_state, execute_fn, peers, bootstrap_cls=Bootstrap):\\n super(Seed, self).__init__(node)\\n self.initial_state = initial_state\\n self.execute_fn = execute_fn\\n self.peers = peers\\n self.bootstrap_cls = bootstrap_cls\\n self.seen_peers = set([])\\n self.exit_timer = None\\n\\n def do_Join(self, sender):\\n self.seen_peers.add(sender)\\n if len(self.seen_peers) <= len(self.peers) / 2:\\n return\\n\\n # cluster is ready - welcome everyone\\n self.node.send(list(self.seen_peers), Welcome(\\n state=self.initial_state, slot=1, decisions={}))\\n\\n # stick around for long enough that we don\\'t hear any new JOINs from\\n # the newly formed cluster\\n if self.exit_timer:\\n self.exit_timer.cancel()\\n self.exit_timer = self.set_timer(JOIN_RETRANSMIT * 2, self.finish)\\n\\n def finish(self):\\n # bootstrap this node into the cluster we just seeded\\n bs = self.bootstrap_cls(self.node, peers=self.peers, execute_fn=self.execute_fn)\\n bs.start()\\n self.stop()\\n\\nclass Requester(Role):\\n\\n client_ids = itertools.count(start=100000)\\n\\n def __init__(self, node, n, callback):\\n super(Requester, self).__init__(node)\\n self.client_id = self.client_ids.next()\\n self.n = n\\n self.output = None\\n self.callback = callback\\n\\n def start(self):\\n self.node.send([self.node.address], Invoke(caller=self.node.address,\\n client_id=self.client_id, input_value=self.n))\\n self.invoke_timer = self.set_timer(INVOKE_RETRANSMIT, self.start)\\n\\n def do_Invoked(self, sender, client_id, output):\\n if client_id != self.client_id:\\n return\\n self.logger.debug(\"received output %r\" % (output,))\\n self.invoke_timer.cancel()\\n self.callback(output)\\n self.stop()\\n\\nclass Member(object):\\n\\n def __init__(self, state_machine, network, peers, seed=None,\\n seed_cls=Seed, bootstrap_cls=Bootstrap):\\n self.network = network\\n self.node = network.new_node()\\n if seed is not None:\\n self.startup_role = seed_cls(self.node, initial_state=seed, peers=peers,\\n execute_fn=state_machine)\\n else:\\n self.startup_role = bootstrap_cls(self.node, execute_fn=state_machine, peers=peers)\\n self.requester = None\\n\\n def start(self):\\n self.startup_role.start()\\n self.thread = threading.Thread(target=self.network.run)\\n self.thread.start()\\n\\n def invoke(self, input_value, request_cls=Requester):\\n assert self.requester is None\\n q = Queue.Queue()\\n self.requester = request_cls(self.node, input_value, q.put)\\n self.requester.start()\\n output = q.get()\\n self.requester = None\\n return output',\n", + " \"function errorHandler(context) {\\n return function(error) {\\n trace('Failure in ' + context + ': ' + error.toString);\\n }\\n}\\n\\nfunction successHandler(context) {\\n return function() {\\n trace('Success in ' + context);\\n }\\n}\\n\\nfunction noAction() {\\n}\\n\\n\\nfunction VideoPipe(stream, handler) {\\n var servers = null;\\n var pc1 = new RTCPeerConnection(servers);\\n var pc2 = new RTCPeerConnection(servers);\\n\\n pc1.addStream(stream);\\n pc1.onicecandidate = function(event) {\\n if (event.candidate) {\\n pc2.addIceCandidate(new RTCIceCandidate(event.candidate),\\n noAction, errorHandler('AddIceCandidate'));\\n }\\n }\\n pc2.onicecandidate = function(event) {\\n if (event.candidate) {\\n pc1.addIceCandidate(new RTCIceCandidate(event.candidate),\\n noAction, errorHandler('AddIceCandidate'));\\n }\\n }\\n pc2.onaddstream = function(e) {\\n handler(e.stream);\\n }\\n pc1.createOffer(function(desc) {\\n pc1.setLocalDescription(desc);\\n pc2.setRemoteDescription(desc);\\n pc2.createAnswer(function(desc2) {\\n pc2.setLocalDescription(desc2);\\n pc1.setRemoteDescription(desc2);\\n }, errorHandler('pc2.createAnswer'));\\n }, errorHandler('pc1.createOffer'));\\n this.pc1 = pc1;\\n this.pc2 = pc2;\\n}\\n\\nVideoPipe.prototype.close = function() {\\n this.pc1.close();\\n this.pc2.close();\\n}\",\n", + " \"var _ = require('lodash'),\\n fs = require('fs'),\\n yaml = require('js-yaml');\\n\\nfunction getDefaultSettings() {\\n return yaml.safeLoad(fs.readFileSync('defaults.yml', 'utf8'));\\n}\\n\\nfunction getFileSettings() {\\n if (fs.existsSync('settings.yml')) {\\n return yaml.safeLoad(fs.readFileSync('settings.yml', 'utf8'));\\n }\\n return {};\\n}\\n\",\n", + " '/* Riot v2.0.8, @license MIT, (c) 2015 Muut Inc. + contributors */\\n\\n;(function() {\\n\\nvar riot = { version: \\'v2.0.8\\', settings: {} }\\n\\n\\'use strict\\'\\n\\nriot.observable = function(el) {\\n\\n el = el || {}\\n\\n var callbacks = {}\\n\\n el.on = function(events, fn) {\\n if (typeof fn == \\'function\\') {\\n events.replace(/\\\\S+/g, function(name, pos) {\\n (callbacks[name] = callbacks[name] || []).push(fn)\\n fn.typed = pos > 0\\n })\\n }\\n return el\\n }\\n\\n el.off = function(events, fn) {\\n if (events == \\'*\\') callbacks = {}\\n else if (fn) {\\n var arr = callbacks[events]\\n for (var i = 0, cb; (cb = arr && arr[i]); ++i) {\\n if (cb == fn) { arr.splice(i, 1); i-- }\\n }\\n } else {\\n events.replace(/\\\\S+/g, function(name) {\\n callbacks[name] = []\\n })\\n }\\n return el\\n }\\n\\n // only single event supported\\n el.one = function(name, fn) {\\n if (fn) fn.one = 1\\n return el.on(name, fn)\\n }\\n\\n el.trigger = function(name) {\\n var args = [].slice.call(arguments, 1),\\n fns = callbacks[name] || []\\n\\n for (var i = 0, fn; (fn = fns[i]); ++i) {\\n if (!fn.busy) {\\n fn.busy = 1\\n fn.apply(el, fn.typed ? [name].concat(args) : args)\\n if (fn.one) { fns.splice(i, 1); i-- }\\n else if (fns[i] !== fn) { i-- } // Makes self-removal possible during iteration\\n fn.busy = 0\\n }\\n }\\n\\n return el\\n }\\n\\n return el\\n\\n}\\n;(function(riot, evt) {\\n\\n // browsers only\\n if (!this.top) return\\n\\n var loc = location,\\n fns = riot.observable(),\\n current = hash(),\\n win = window\\n\\n function hash() {\\n return loc.hash.slice(1)\\n }\\n\\n function parser(path) {\\n return path.split(\\'/\\')\\n }\\n\\n function emit(path) {\\n if (path.type) path = hash()\\n\\n if (path != current) {\\n fns.trigger.apply(null, [\\'H\\'].concat(parser(path)))\\n current = path\\n }\\n }\\n\\n var r = riot.route = function(arg) {\\n // string\\n if (arg[0]) {\\n loc.hash = arg\\n emit(arg)\\n\\n // function\\n } else {\\n fns.on(\\'H\\', arg)\\n }\\n }\\n\\n r.exec = function(fn) {\\n fn.apply(null, parser(hash()))\\n }\\n\\n r.parser = function(fn) {\\n parser = fn\\n }\\n\\n win.addEventListener ? win.addEventListener(evt, emit, false) : win.attachEvent(\\'on\\' + evt, emit)\\n\\n})(riot, \\'hashchange\\')\\n/*\\n\\n//// How it works?\\n\\n\\nThree ways:\\n\\n1. Expressions: tmpl(\\'{ value }\\', data).\\n Returns the result of evaluated expression as a raw object.\\n\\n2. Templates: tmpl(\\'Hi { name } { surname }\\', data).\\n Returns a string with evaluated expressions.\\n\\n3. Filters: tmpl(\\'{ show: !done, highlight: active }\\', data).\\n Returns a space separated list of trueish keys (mainly\\n used for setting html classes), e.g. \"show highlight\".\\n\\n\\n// Template examples\\n\\ntmpl(\\'{ title || \"Untitled\" }\\', data)\\ntmpl(\\'Results are { results ? \"ready\" : \"loading\" }\\', data)\\ntmpl(\\'Today is { new Date() }\\', data)\\ntmpl(\\'{ message.length > 140 && \"Message is too long\" }\\', data)\\ntmpl(\\'This item got { Math.round(rating) } stars\\', data)\\ntmpl(\\'

{ title }

{ body }\\', data)\\n\\n\\n// Falsy expressions in templates\\n\\nIn templates (as opposed to single expressions) all falsy values\\nexcept zero (undefined/null/false) will default to empty string:\\n\\ntmpl(\\'{ undefined } - { false } - { null } - { 0 }\\', {})\\n// will return: \" - - - 0\"\\n\\n\\n// Customizable brackets\\n\\n riot.settings.brackets = \\'[ ]\\'\\n riot.settings.brackets = \\'<% %>\\'\\n\\n*/\\n\\nvar tmpl = (function() {\\n\\n var cache = {},\\n brackets,\\n re_expr,\\n re_vars = /(\"|\\').+?[^\\\\\\\\]\\\\1|\\\\.\\\\w*|\\\\w*:|\\\\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\\\\b|function *\\\\()|([a-z_]\\\\w*)/gi\\n // [ 1 ][ 2 ][ 3 ][ 4 ][ 5 ]\\n // find variable names:\\n // 1. skip quoted strings: \"a b\", \\'a b\\', \\'a \\\\\\'b\\\\\\'\\'\\n // 2. skip object properties: .name\\n // 3. skip object literals: name:\\n // 4. skip javascript keywords\\n // 5. match var name\\n\\n return function(str, data) {\\n\\n // make sure we use current brackets setting\\n var b = riot.settings.brackets || \\'{ }\\'\\n if(b != brackets){\\n brackets = b.split(\\' \\')\\n re_expr = re(/({[\\\\s\\\\S]*?})/)\\n }\\n\\n // build a template (or get it from cache), render with data\\n // (or just test if string has expression when called w/o data)\\n return data\\n ? str && (cache[str] = cache[str] || tmpl(str))(data)\\n : re_expr.test(str)\\n\\n }\\n\\n\\n // create a template instance\\n\\n function tmpl(s, p) {\\n\\n // default template string to {}\\n p = (s || brackets.join(\\'\\'))\\n\\n // temporarily convert \\\\{ and \\\\} to a non-character\\n .replace(re(/\\\\\\\\{/), \\'\\\\uFFF0\\')\\n .replace(re(/\\\\\\\\}/), \\'\\\\uFFF1\\')\\n \\n // split string to expression and non-expresion parts\\n .split(re_expr)\\n\\n return new Function(\\'d\\', \\'return \\' + (\\n\\n // is it a single expression or a template? i.e. {x} or {x}\\n !p[0] && !p[2] && !p[3]\\n\\n // if expression, evaluate it\\n ? expr(p[1])\\n\\n // if template, evaluate all expressions in it\\n : \\'[\\' + p.map(function(s, i) {\\n\\n // is it an expression or a string (every second part is an expression)\\n return i % 2\\n\\n // evaluate the expressions\\n ? expr(s, 1)\\n\\n // process string parts of the template:\\n : \\'\"\\' + s\\n\\n // preserve new lines\\n .replace(/\\\\n/g, \\'\\\\\\\\n\\')\\n\\n // escape quotes\\n .replace(/\"/g, \\'\\\\\\\\\"\\')\\n\\n + \\'\"\\'\\n\\n }).join(\\',\\') + \\'].join(\"\")\\'\\n )\\n\\n // bring escaped { and } back\\n .replace(/\\\\uFFF0/g, brackets[0])\\n .replace(/\\\\uFFF1/g, brackets[1])\\n\\n )\\n\\n }\\n\\n\\n // parse { ... } expression\\n\\n function expr(s, n) {\\n s = s\\n\\n // convert new lines to spaces\\n .replace(/\\\\n/g, \\' \\')\\n\\n // trim whitespace, curly brackets, strip comments\\n .replace(re(/^[{ ]+|[ }]+$|\\\\/\\\\*.+?\\\\*\\\\//g), \\'\\')\\n\\n // is it an object literal? i.e. { key : value }\\n return /^\\\\s*[\\\\w-\"\\']+ *:/.test(s)\\n\\n // if object literal, return trueish keys\\n // e.g.: { show: isOpen(), done: item.done } -> \"show done\"\\n ? \\'[\\' + s.replace(/\\\\W*([\\\\w-]+)\\\\W*:([^,]+)/g, function(_, k, v) {\\n\\n // safely execute vars to prevent undefined value errors\\n return v.replace(/\\\\w[^,|& ]*/g, function(v) { return wrap(v, n) }) + \\'?\"\\' + k + \\'\":\"\",\\'\\n\\n }) + \\'].join(\" \")\\'\\n\\n // if js expression, evaluate as javascript\\n : wrap(s, n)\\n\\n }\\n\\n\\n // execute js w/o breaking on errors or undefined vars\\n\\n function wrap(s, nonull) {\\n return \\'(function(v){try{v=\\'\\n\\n // prefix vars (name => data.name)\\n + (s.replace(re_vars, function(s, _, v) { return v ? \\'(d.\\'+v+\\'===undefined?window.\\'+v+\\':d.\\'+v+\\')\\' : s })\\n\\n // break the expression if its empty (resulting in undefined value)\\n || \\'x\\')\\n\\n + \\'}finally{return \\'\\n\\n // default to empty string for falsy values except zero\\n + (nonull ? \\'!v&&v!==0?\"\":v\\' : \\'v\\')\\n\\n + \\'}}).call(d)\\'\\n }\\n\\n\\n // change regexp to use custom brackets\\n\\n function re(r) {\\n return RegExp(r.source\\n .split(\\'{\\').join(\\'\\\\\\\\\\'+brackets[0])\\n .split(\\'}\\').join(\\'\\\\\\\\\\'+brackets[1]),\\n r.global ? \\'g\\' : \\'\\')\\n }\\n\\n})()\\n// { key, i in items} -> { key, i, items }\\nfunction loopKeys(expr) {\\n var ret = { val: expr },\\n els = expr.split(/\\\\s+in\\\\s+/)\\n\\n if (els[1]) {\\n ret.val = \\'{ \\' + els[1]\\n els = els[0].slice(1).trim().split(/,\\\\s*/)\\n ret.key = els[0]\\n ret.pos = els[1]\\n }\\n return ret\\n}\\n\\nfunction _each(dom, parent, expr) {\\n\\n remAttr(dom, \\'each\\')\\n\\n var template = dom.outerHTML,\\n prev = dom.previousSibling,\\n root = dom.parentNode,\\n rendered = [],\\n tags = [],\\n checksum\\n\\n expr = loopKeys(expr)\\n\\n // clean template code after update (and let walk finish it\\'s parse)\\n parent.one(\\'update\\', function() {\\n root.removeChild(dom)\\n\\n }).one(\\'mount\\', function() {\\n if (!hasParent(root)) root = parent.root\\n\\n }).on(\\'update\\', function() {\\n\\n var items = tmpl(expr.val, parent)\\n if (!items) return\\n\\n // object loop. any changes cause full redraw\\n if (!Array.isArray(items)) {\\n var testsum = JSON.stringify(items)\\n if (testsum == checksum) return\\n checksum = testsum\\n\\n // clear old items\\n tags.map(function(tag) {\\n tag.unmount()\\n })\\n\\n tags = rendered = []\\n\\n items = Object.keys(items).map(function(key, i) {\\n var obj = {}\\n obj[expr.key] = key\\n obj[expr.pos] = items[key]\\n return obj\\n })\\n\\n }\\n\\n // unmount redundant\\n arrDiff(rendered, items).map(function(item) {\\n var pos = rendered.indexOf(item),\\n tag = tags[pos]\\n\\n if (tag) {\\n tag.unmount()\\n rendered.splice(pos, 1)\\n tags.splice(pos, 1)\\n }\\n })\\n\\n // mount new\\n var nodes = root.childNodes,\\n prev_index = Array.prototype.indexOf.call(nodes, prev)\\n\\n arrDiff(items, rendered).map(function(item, i) {\\n\\n var pos = items.indexOf(item)\\n\\n if (!checksum && expr.key) {\\n var obj = {}\\n obj[expr.key] = item\\n obj[expr.pos] = pos\\n item = obj\\n }\\n\\n var tag = new Tag({ tmpl: template }, {\\n before: nodes[prev_index + 1 + pos],\\n parent: parent,\\n root: root,\\n loop: true,\\n item: item\\n })\\n\\n tags.splice(pos, 0, tag)\\n\\n })\\n\\n rendered = items.slice()\\n\\n })\\n\\n}\\nfunction parseNamedElements(root, tag, expressions) {\\n walk(root, function(dom) {\\n if (dom.nodeType != 1) return\\n\\n each(dom.attributes, function(attr) {\\n if (/^(name|id)$/.test(attr.name)) tag[attr.value] = dom\\n })\\n })\\n}\\n\\nfunction parseLayout(root, tag, expressions) {\\n\\n function addExpr(dom, value, data) {\\n if (tmpl(value) || data) {\\n var expr = { dom: dom, expr: value }\\n expressions.push(extend(expr, data || {}))\\n }\\n }\\n\\n walk(root, function(dom) {\\n\\n var type = dom.nodeType\\n\\n // text node\\n if (type == 3 && dom.parentNode.tagName != \\'STYLE\\') addExpr(dom, dom.nodeValue)\\n if (type != 1) return\\n\\n /* element */\\n\\n // loop\\n var attr = dom.getAttribute(\\'each\\')\\n if (attr) { _each(dom, tag, attr); return false }\\n\\n // child tag\\n var impl = tag_impl[dom.tagName.toLowerCase()]\\n if (impl) {\\n impl = new Tag(impl, { root: dom, parent: tag })\\n return false\\n }\\n\\n // attributes\\n each(dom.attributes, function(attr) {\\n var name = attr.name,\\n value = attr.value\\n\\n // expressions\\n var bool = name.split(\\'__\\')[1]\\n addExpr(dom, value, { attr: bool || name, bool: bool })\\n\\n if (bool) {\\n remAttr(dom, name)\\n return false\\n }\\n\\n })\\n\\n })\\n\\n}\\nfunction Tag(impl, conf) {\\n\\n var self = riot.observable(this),\\n expressions = [],\\n attributes = {},\\n parent = conf.parent,\\n is_loop = conf.loop,\\n root = conf.root,\\n opts = conf.opts,\\n item = conf.item\\n\\n // cannot initialize twice on the same root element\\n if (!is_loop && root.riot) return\\n root.riot = 1\\n\\n opts = opts || {}\\n\\n extend(this, { parent: parent, root: root, opts: opts, children: [] })\\n extend(this, item)\\n\\n\\n // attributes\\n each(root.attributes, function(attr) {\\n var name = attr.name,\\n val = attr.value\\n\\n attributes[name] = val\\n\\n // remove dynamic attributes from node\\n if (val.indexOf(\\'{\\') >= 0) {\\n remAttr(root, name)\\n return false\\n }\\n })\\n\\n // options\\n function updateOpts() {\\n Object.keys(attributes).map(function(name) {\\n opts[name] = tmpl(attributes[name], parent || self)\\n })\\n }\\n\\n updateOpts()\\n\\n // child\\n parent && parent.children.push(this)\\n\\n var dom = mkdom(impl.tmpl),\\n loop_dom\\n\\n // named elements\\n parseNamedElements(dom, this)\\n\\n this.update = function(data, init) {\\n extend(self, data)\\n extend(self, item)\\n self.trigger(\\'update\\')\\n updateOpts()\\n update(expressions, self, item)\\n self.trigger(\\'updated\\')\\n }\\n\\n this.unmount = function() {\\n\\n if (is_loop) {\\n root.removeChild(loop_dom)\\n\\n } else {\\n var p = root.parentNode\\n p && p.removeChild(root)\\n }\\n\\n // splice from parent.children[]\\n if (parent) {\\n var els = parent.children\\n els.splice(els.indexOf(self), 1)\\n }\\n\\n self.trigger(\\'unmount\\')\\n\\n // cleanup\\n parent && parent.off(\\'update\\', self.update)\\n mounted = false\\n }\\n\\n function mount() {\\n while (dom.firstChild) {\\n if (is_loop) {\\n loop_dom = dom.firstChild\\n root.insertBefore(dom.firstChild, conf.before || null) // null needed for IE8\\n\\n } else {\\n root.appendChild(dom.firstChild)\\n }\\n }\\n\\n if (!hasParent(root)) self.root = root = parent.root\\n\\n self.trigger(\\'mount\\')\\n\\n // one way data flow: propagate updates and unmounts downwards from parent to children\\n parent && parent.on(\\'update\\', self.update).one(\\'unmount\\', self.unmount)\\n\\n }\\n\\n // initialize\\n if (impl.fn) impl.fn.call(this, opts)\\n\\n // layout\\n parseLayout(dom, this, expressions)\\n\\n this.update()\\n mount()\\n\\n}\\n\\n\\nfunction setEventHandler(name, handler, dom, tag, item) {\\n\\n dom[name] = function(e) {\\n\\n // cross browser event fix\\n e = e || window.event\\n e.which = e.which || e.charCode || e.keyCode\\n e.target = e.target || e.srcElement\\n e.currentTarget = dom\\n e.item = item\\n\\n // prevent default behaviour (by default)\\n if (handler.call(tag, e) !== true) {\\n e.preventDefault && e.preventDefault()\\n e.returnValue = false\\n }\\n\\n tag.update()\\n }\\n\\n}\\n\\nfunction insertTo(root, node, before) {\\n if (root) {\\n root.insertBefore(before, node)\\n root.removeChild(node)\\n }\\n}\\n\\n// item = currently looped item\\nfunction update(expressions, tag, item) {\\n\\n each(expressions, function(expr) {\\n var dom = expr.dom,\\n attr_name = expr.attr,\\n value = tmpl(expr.expr, tag)\\n\\n if (value == null) value = \\'\\'\\n\\n // no change\\n if (expr.value === value) return\\n expr.value = value\\n\\n // text node\\n if (!attr_name) return dom.nodeValue = value\\n\\n // remove attribute\\n if (!value && expr.bool || /obj|func/.test(typeof value)) remAttr(dom, attr_name)\\n\\n // event handler\\n if (typeof value == \\'function\\') {\\n setEventHandler(attr_name, value, dom, tag, item)\\n\\n // if- conditional\\n } else if (attr_name == \\'if\\') {\\n\\n remAttr(dom, attr_name)\\n\\n var stub = expr.stub\\n\\n // add to DOM\\n if (value) {\\n stub && insertTo(stub.parentNode, stub, dom)\\n\\n // remove from DOM\\n } else {\\n stub = expr.stub = stub || document.createTextNode(\\'\\')\\n insertTo(dom.parentNode, dom, stub)\\n }\\n\\n // show / hide\\n } else if (/^(show|hide)$/.test(attr_name)) {\\n remAttr(dom, attr_name)\\n if (attr_name == \\'hide\\') value = !value\\n dom.style.display = value ? \\'\\' : \\'none\\'\\n\\n // normal attribute\\n } else {\\n if (expr.bool) {\\n dom[attr_name] = value\\n if (!value) return\\n value = attr_name\\n }\\n\\n dom.setAttribute(attr_name, value)\\n }\\n\\n })\\n\\n}\\nfunction each(nodes, fn) {\\n for (var i = 0; i < (nodes || []).length; i++) {\\n if (fn(nodes[i], i) === false) i--\\n }\\n}\\n\\nfunction remAttr(dom, name) {\\n dom.removeAttribute(name)\\n}\\n\\nfunction extend(obj, from) {\\n from && Object.keys(from).map(function(key) {\\n obj[key] = from[key]\\n })\\n return obj\\n}\\n\\nfunction mkdom(template) {\\n var tag_name = template.trim().slice(1, 3).toLowerCase(),\\n root_tag = /td|th/.test(tag_name) ? \\'tr\\' : tag_name == \\'tr\\' ? \\'tbody\\' : \\'div\\'\\n el = document.createElement(root_tag)\\n\\n el.stub = true\\n el.innerHTML = template\\n return el\\n}\\n\\nfunction walk(dom, fn) {\\n dom = fn(dom) === false ? dom.nextSibling : dom.firstChild\\n\\n while (dom) {\\n walk(dom, fn)\\n dom = dom.nextSibling\\n }\\n}\\n\\nfunction arrDiff(arr1, arr2) {\\n return arr1.filter(function(el) {\\n return arr2.indexOf(el) < 0\\n })\\n}\\n\\n// HTMLDocument == IE8 thing\\nfunction hasParent(el) {\\n var p = el.parentNode,\\n doc = window.HTMLDocument\\n\\n return p && !(doc && p instanceof doc)\\n}\\n\\n/*\\n Virtual dom is an array of custom tags on the document.\\n Each tag stores an array of child tags.\\n Updates and unmounts propagate downwards from parent to children.\\n*/\\n\\nvar virtual_dom = [],\\n tag_impl = {}\\n\\nriot.tag = function(name, html, fn) {\\n tag_impl[name] = { name: name, tmpl: html, fn: fn }\\n}\\n\\nvar mountTo = riot.mountTo = function(root, tagName, opts) {\\n var impl = tag_impl[tagName], tag\\n\\n if (impl) tag = new Tag(impl, { root: root, opts: opts })\\n\\n if (tag) {\\n virtual_dom.push(tag)\\n return tag.on(\\'unmount\\', function() {\\n virtual_dom.splice(virtual_dom.indexOf(tag), 1)\\n })\\n }\\n}\\n\\nriot.mount = function(selector, opts) {\\n if (selector == \\'*\\') selector = Object.keys(tag_impl).join(\\', \\')\\n\\n var tags = []\\n\\n each(document.querySelectorAll(selector), function(root) {\\n\\n var tagName = root.tagName.toLowerCase(),\\n tag = mountTo(root, tagName, opts)\\n\\n if (tag) tags.push(tag)\\n })\\n\\n return tags\\n}\\n\\n// update everything\\nriot.update = function() {\\n virtual_dom.map(function(tag) {\\n tag.update()\\n })\\n return virtual_dom\\n}\\n\\n\\n// support CommonJS\\nif (typeof exports === \\'object\\')\\n module.exports = riot\\n\\n// support AMD\\nelse if (typeof define === \\'function\\' && define.amd)\\n define(function() { return riot })\\n\\n// support browser\\nelse\\n this.riot = riot\\n\\n})();',\n", + " \" var r = riot.route = function(arg) {\\n // string\\n if (arg[0]) {\\n loc.hash = arg\\n emit(arg)\\n\\n // function\\n } else {\\n fns.on('H', arg)\\n }\\n }\",\n", + " \"module ActiveJob\\n module Core\\n extend ActiveSupport::Concern\\n\\n included do\\n # Job arguments\\n attr_accessor :arguments\\n attr_writer :serialized_arguments\\n\\n # Timestamp when the job should be performed\\n attr_accessor :scheduled_at\\n\\n # Job Identifier\\n attr_accessor :job_id\\n\\n # Queue in which the job will reside.\\n attr_writer :queue_name\\n end\\n\\n # These methods will be included into any Active Job object, adding\\n # helpers for de/serialization and creation of job instances.\\n module ClassMethods\\n # Creates a new job instance from a hash created with +serialize+\\n def deserialize(job_data)\\n job = job_data['job_class'].constantize.new\\n job.deserialize(job_data)\\n job\\n end\\n\\n # Creates a job preconfigured with the given options. You can call\\n # perform_later with the job arguments to enqueue the job with the\\n # preconfigured options\\n #\\n # ==== Options\\n # * :wait - Enqueues the job with the specified delay\\n # * :wait_until - Enqueues the job at the time specified\\n # * :queue - Enqueues the job on the specified queue\\n #\\n # ==== Examples\\n #\\n # VideoJob.set(queue: :some_queue).perform_later(Video.last)\\n # VideoJob.set(wait: 5.minutes).perform_later(Video.last)\\n # VideoJob.set(wait_until: Time.now.tomorrow).perform_later(Video.last)\\n # VideoJob.set(queue: :some_queue, wait: 5.minutes).perform_later(Video.last)\\n # VideoJob.set(queue: :some_queue, wait_until: Time.now.tomorrow).perform_later(Video.last)\\n def set(options={})\\n ConfiguredJob.new(self, options)\\n end\\n end\\n\\n # Creates a new job instance. Takes the arguments that will be\\n # passed to the perform method.\\n def initialize(*arguments)\\n @arguments = arguments\\n @job_id = SecureRandom.uuid\\n @queue_name = self.class.queue_name\\n end\\n\\n # Returns a hash with the job data that can safely be passed to the\\n # queueing adapter.\\n def serialize\\n {\\n 'job_class' => self.class.name,\\n 'job_id' => job_id,\\n 'queue_name' => queue_name,\\n 'arguments' => serialize_arguments(arguments)\\n }\\n end\\n\\n # Attaches the stored job data to the current instance. Receives a hash\\n # returned from +serialize+\\n #\\n # ==== Examples\\n #\\n # class DeliverWebhookJob < ActiveJob::Base\\n # def serialize\\n # super.merge('attempt_number' => (@attempt_number || 0) + 1)\\n # end\\n #\\n # def deserialize(job_data)\\n # super\\n # @attempt_number = job_data['attempt_number']\\n # end\\n #\\n # rescue_from(TimeoutError) do |exception|\\n # raise exception if @attempt_number > 5\\n # retry_job(wait: 10)\\n # end\\n # end\\n def deserialize(job_data)\\n self.job_id = job_data['job_id']\\n self.queue_name = job_data['queue_name']\\n self.serialized_arguments = job_data['arguments']\\n end\\n\\n private\\n def deserialize_arguments_if_needed\\n if defined?(@serialized_arguments) && @serialized_arguments.present?\\n @arguments = deserialize_arguments(@serialized_arguments)\\n @serialized_arguments = nil\\n end\\n end\\n\\n def serialize_arguments(serialized_args)\\n Arguments.serialize(serialized_args)\\n end\\n\\n def deserialize_arguments(serialized_args)\\n Arguments.deserialize(serialized_args)\\n end\\n end\\nend\",\n", + " 'require \\'formula\\'\\n\\nclass A52dec < Formula\\n homepage \\'http://liba52.sourceforge.net/\\'\\n url \\'http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz\\'\\n sha1 \\'79b33bd8d89dad7436f85b9154ad35667aa37321\\'\\n\\n def install\\n system \"./configure\", \"--disable-debug\",\\n \"--disable-dependency-tracking\",\\n \"--prefix=#{prefix}\",\\n \"--enable-shared\",\\n \"--mandir=#{man}\"\\n system \"make install\"\\n end\\nend',\n", + " \"module Fluent\\n class Input\\n include Configurable\\n include PluginId\\n include PluginLoggerMixin\\n\\n attr_accessor :router\\n\\n def initialize\\n super\\n end\\n\\n def configure(conf)\\n super\\n\\n if label_name = conf['@label']\\n label = Engine.root_agent.find_label(label_name)\\n @router = label.event_router\\n elsif @router.nil?\\n @router = Engine.root_agent.event_router\\n end\\n end\\n\\n def start\\n end\\n\\n def shutdown\\n end\\n end\\nend\",\n", + " '{-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-}\\n{-\\nCopyright (C) 2006-2014 John MacFarlane \\n\\nThis program is free software; you can redistribute it and/or modify\\nit under the terms of the GNU General Public License as published by\\nthe Free Software Foundation; either version 2 of the License, or\\n(at your option) any later version.\\n\\nThis program is distributed in the hope that it will be useful,\\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\\nGNU General Public License for more details.\\n\\nYou should have received a copy of the GNU General Public License\\nalong with this program; if not, write to the Free Software\\nFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\\n-}\\n\\n{- |\\n Module : Text.Pandoc\\n Copyright : Copyright (C) 2006-2014 John MacFarlane\\n License : GNU GPL, version 2 or above\\n\\n Maintainer : John MacFarlane \\n Stability : alpha\\n Portability : portable\\n\\nThis helper module exports the main writers, readers, and data\\nstructure definitions from the Pandoc libraries.\\n\\nA typical application will chain together a reader and a writer\\nto convert strings from one format to another. For example, the\\nfollowing simple program will act as a filter converting markdown\\nfragments to reStructuredText, using reference-style links instead of\\ninline links:\\n\\n> module Main where\\n> import Text.Pandoc\\n>\\n> markdownToRST :: String -> String\\n> markdownToRST =\\n> (writeRST def {writerReferenceLinks = True}) . readMarkdown def\\n>\\n> main = getContents >>= putStrLn . markdownToRST\\n\\nNote: all of the readers assume that the input text has @\\'\\\\n\\'@\\nline endings. So if you get your input text from a web form,\\nyou should remove @\\'\\\\r\\'@ characters using @filter (/=\\'\\\\r\\')@.\\n\\n-}\\n\\nmodule Text.Pandoc\\n (\\n -- * Definitions\\n module Text.Pandoc.Definition\\n -- * Generics\\n , module Text.Pandoc.Generic\\n -- * Options\\n , module Text.Pandoc.Options\\n -- * Lists of readers and writers\\n , readers\\n , writers\\n -- * Readers: converting /to/ Pandoc format\\n , Reader (..)\\n , mkStringReader\\n , readDocx\\n , readMarkdown\\n , readMediaWiki\\n , readRST\\n , readOrg\\n , readLaTeX\\n , readHtml\\n , readTextile\\n , readDocBook\\n , readOPML\\n , readHaddock\\n , readNative\\n , readJSON\\n , readTWiki\\n , readTxt2Tags\\n , readTxt2TagsNoMacros\\n , readEPUB\\n -- * Writers: converting /from/ Pandoc format\\n , Writer (..)\\n , writeNative\\n , writeJSON\\n , writeMarkdown\\n , writePlain\\n , writeRST\\n , writeLaTeX\\n , writeConTeXt\\n , writeTexinfo\\n , writeHtml\\n , writeHtmlString\\n , writeICML\\n , writeDocbook\\n , writeOPML\\n , writeOpenDocument\\n , writeMan\\n , writeMediaWiki\\n , writeDokuWiki\\n , writeTextile\\n , writeRTF\\n , writeODT\\n , writeDocx\\n , writeEPUB\\n , writeFB2\\n , writeOrg\\n , writeAsciiDoc\\n , writeHaddock\\n , writeCustom\\n -- * Rendering templates and default templates\\n , module Text.Pandoc.Templates\\n -- * Version\\n , pandocVersion\\n -- * Miscellaneous\\n , getReader\\n , getWriter\\n , ToJsonFilter(..)\\n ) where\\n\\nimport Text.Pandoc.Definition\\nimport Text.Pandoc.Generic\\nimport Text.Pandoc.JSON\\nimport Text.Pandoc.Readers.Markdown\\nimport Text.Pandoc.Readers.MediaWiki\\nimport Text.Pandoc.Readers.RST\\nimport Text.Pandoc.Readers.Org\\nimport Text.Pandoc.Readers.DocBook\\nimport Text.Pandoc.Readers.OPML\\nimport Text.Pandoc.Readers.LaTeX\\nimport Text.Pandoc.Readers.HTML\\nimport Text.Pandoc.Readers.Textile\\nimport Text.Pandoc.Readers.Native\\nimport Text.Pandoc.Readers.Haddock\\nimport Text.Pandoc.Readers.TWiki\\nimport Text.Pandoc.Readers.Docx\\nimport Text.Pandoc.Readers.Txt2Tags\\nimport Text.Pandoc.Readers.EPUB\\nimport Text.Pandoc.Writers.Native\\nimport Text.Pandoc.Writers.Markdown\\nimport Text.Pandoc.Writers.RST\\nimport Text.Pandoc.Writers.LaTeX\\nimport Text.Pandoc.Writers.ConTeXt\\nimport Text.Pandoc.Writers.Texinfo\\nimport Text.Pandoc.Writers.HTML\\nimport Text.Pandoc.Writers.ODT\\nimport Text.Pandoc.Writers.Docx\\nimport Text.Pandoc.Writers.EPUB\\nimport Text.Pandoc.Writers.FB2\\nimport Text.Pandoc.Writers.ICML\\nimport Text.Pandoc.Writers.Docbook\\nimport Text.Pandoc.Writers.OPML\\nimport Text.Pandoc.Writers.OpenDocument\\nimport Text.Pandoc.Writers.Man\\nimport Text.Pandoc.Writers.RTF\\nimport Text.Pandoc.Writers.MediaWiki\\nimport Text.Pandoc.Writers.DokuWiki\\nimport Text.Pandoc.Writers.Textile\\nimport Text.Pandoc.Writers.Org\\nimport Text.Pandoc.Writers.AsciiDoc\\nimport Text.Pandoc.Writers.Haddock\\nimport Text.Pandoc.Writers.Custom\\nimport Text.Pandoc.Templates\\nimport Text.Pandoc.Options\\nimport Text.Pandoc.Shared (safeRead, warn)\\nimport Text.Pandoc.MediaBag (MediaBag)\\nimport Data.Aeson\\nimport qualified Data.ByteString.Lazy as BL\\nimport Data.List (intercalate)\\nimport Data.Version (showVersion)\\nimport Data.Set (Set)\\nimport qualified Data.Set as Set\\nimport Text.Parsec\\nimport Text.Parsec.Error\\nimport qualified Text.Pandoc.UTF8 as UTF8\\nimport Paths_pandoc (version)\\n\\n-- | Version number of pandoc library.\\npandocVersion :: String\\npandocVersion = showVersion version\\n\\nparseFormatSpec :: String\\n -> Either ParseError (String, Set Extension -> Set Extension)\\nparseFormatSpec = parse formatSpec \"\"\\n where formatSpec = do\\n name <- formatName\\n extMods <- many extMod\\n return (name, foldl (.) id extMods)\\n formatName = many1 $ noneOf \"-+\"\\n extMod = do\\n polarity <- oneOf \"-+\"\\n name <- many $ noneOf \"-+\"\\n ext <- case safeRead (\"Ext_\" ++ name) of\\n Just n -> return n\\n Nothing\\n | name == \"lhs\" -> return Ext_literate_haskell\\n | otherwise -> fail $ \"Unknown extension: \" ++ name\\n return $ case polarity of\\n \\'-\\' -> Set.delete ext\\n _ -> Set.insert ext\\n\\ndata Reader = StringReader (ReaderOptions -> String -> IO Pandoc)\\n | ByteStringReader (ReaderOptions -> BL.ByteString -> IO (Pandoc, MediaBag))\\n\\nmkStringReader :: (ReaderOptions -> String -> Pandoc) -> Reader\\nmkStringReader r = StringReader (\\\\o s -> return $ r o s)\\n\\nmkStringReaderWithWarnings :: (ReaderOptions -> String -> (Pandoc, [String])) -> Reader\\nmkStringReaderWithWarnings r = StringReader $ \\\\o s -> do\\n let (doc, warnings) = r o s\\n mapM_ warn warnings\\n return doc\\n\\nmkBSReader :: (ReaderOptions -> BL.ByteString -> (Pandoc, MediaBag)) -> Reader\\nmkBSReader r = ByteStringReader (\\\\o s -> return $ r o s)\\n\\n-- | Association list of formats and readers.\\nreaders :: [(String, Reader)]\\nreaders = [ (\"native\" , StringReader $ \\\\_ s -> return $ readNative s)\\n ,(\"json\" , mkStringReader readJSON )\\n ,(\"markdown\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_strict\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_phpextra\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_github\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_mmd\", mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"rst\" , mkStringReaderWithWarnings readRSTWithWarnings )\\n ,(\"mediawiki\" , mkStringReader readMediaWiki)\\n ,(\"docbook\" , mkStringReader readDocBook)\\n ,(\"opml\" , mkStringReader readOPML)\\n ,(\"org\" , mkStringReader readOrg)\\n ,(\"textile\" , mkStringReader readTextile) -- TODO : textile+lhs\\n ,(\"html\" , mkStringReader readHtml)\\n ,(\"latex\" , mkStringReader readLaTeX)\\n ,(\"haddock\" , mkStringReader readHaddock)\\n ,(\"twiki\" , mkStringReader readTWiki)\\n ,(\"docx\" , mkBSReader readDocx)\\n ,(\"t2t\" , mkStringReader readTxt2TagsNoMacros)\\n ,(\"epub\" , mkBSReader readEPUB)\\n ]\\n\\ndata Writer = PureStringWriter (WriterOptions -> Pandoc -> String)\\n | IOStringWriter (WriterOptions -> Pandoc -> IO String)\\n | IOByteStringWriter (WriterOptions -> Pandoc -> IO BL.ByteString)\\n\\n-- | Association list of formats and writers.\\nwriters :: [ ( String, Writer ) ]\\nwriters = [\\n (\"native\" , PureStringWriter writeNative)\\n ,(\"json\" , PureStringWriter writeJSON)\\n ,(\"docx\" , IOByteStringWriter writeDocx)\\n ,(\"odt\" , IOByteStringWriter writeODT)\\n ,(\"epub\" , IOByteStringWriter $ \\\\o ->\\n writeEPUB o{ writerEpubVersion = Just EPUB2 })\\n ,(\"epub3\" , IOByteStringWriter $ \\\\o ->\\n writeEPUB o{ writerEpubVersion = Just EPUB3 })\\n ,(\"fb2\" , IOStringWriter writeFB2)\\n ,(\"html\" , PureStringWriter writeHtmlString)\\n ,(\"html5\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerHtml5 = True })\\n ,(\"icml\" , PureStringWriter writeICML)\\n ,(\"s5\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = S5Slides\\n , writerTableOfContents = False })\\n ,(\"slidy\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = SlidySlides })\\n ,(\"slideous\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = SlideousSlides })\\n ,(\"dzslides\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = DZSlides\\n , writerHtml5 = True })\\n ,(\"revealjs\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = RevealJsSlides\\n , writerHtml5 = True })\\n ,(\"docbook\" , PureStringWriter writeDocbook)\\n ,(\"opml\" , PureStringWriter writeOPML)\\n ,(\"opendocument\" , PureStringWriter writeOpenDocument)\\n ,(\"latex\" , PureStringWriter writeLaTeX)\\n ,(\"beamer\" , PureStringWriter $ \\\\o ->\\n writeLaTeX o{ writerBeamer = True })\\n ,(\"context\" , PureStringWriter writeConTeXt)\\n ,(\"texinfo\" , PureStringWriter writeTexinfo)\\n ,(\"man\" , PureStringWriter writeMan)\\n ,(\"markdown\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_strict\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_phpextra\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_github\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_mmd\" , PureStringWriter writeMarkdown)\\n ,(\"plain\" , PureStringWriter writePlain)\\n ,(\"rst\" , PureStringWriter writeRST)\\n ,(\"mediawiki\" , PureStringWriter writeMediaWiki)\\n ,(\"dokuwiki\" , PureStringWriter writeDokuWiki)\\n ,(\"textile\" , PureStringWriter writeTextile)\\n ,(\"rtf\" , IOStringWriter writeRTFWithEmbeddedImages)\\n ,(\"org\" , PureStringWriter writeOrg)\\n ,(\"asciidoc\" , PureStringWriter writeAsciiDoc)\\n ,(\"haddock\" , PureStringWriter writeHaddock)\\n ]\\n\\ngetDefaultExtensions :: String -> Set Extension\\ngetDefaultExtensions \"markdown_strict\" = strictExtensions\\ngetDefaultExtensions \"markdown_phpextra\" = phpMarkdownExtraExtensions\\ngetDefaultExtensions \"markdown_mmd\" = multimarkdownExtensions\\ngetDefaultExtensions \"markdown_github\" = githubMarkdownExtensions\\ngetDefaultExtensions \"markdown\" = pandocExtensions\\ngetDefaultExtensions \"plain\" = pandocExtensions\\ngetDefaultExtensions \"org\" = Set.fromList [Ext_citations]\\ngetDefaultExtensions \"textile\" = Set.fromList [Ext_auto_identifiers]\\ngetDefaultExtensions \"html\" = Set.fromList [Ext_auto_identifiers,\\n Ext_native_divs,\\n Ext_native_spans]\\ngetDefaultExtensions \"html5\" = getDefaultExtensions \"html\"\\ngetDefaultExtensions \"epub\" = Set.fromList [Ext_auto_identifiers,\\n Ext_raw_html,\\n Ext_native_divs,\\n Ext_native_spans,\\n Ext_epub_html_exts]\\ngetDefaultExtensions _ = Set.fromList [Ext_auto_identifiers]\\n\\n-- | Retrieve reader based on formatSpec (format+extensions).\\ngetReader :: String -> Either String Reader\\ngetReader s =\\n case parseFormatSpec s of\\n Left e -> Left $ intercalate \"\\\\n\" $ [m | Message m <- errorMessages e]\\n Right (readerName, setExts) ->\\n case lookup readerName readers of\\n Nothing -> Left $ \"Unknown reader: \" ++ readerName\\n Just (StringReader r) -> Right $ StringReader $ \\\\o ->\\n r o{ readerExtensions = setExts $\\n getDefaultExtensions readerName }\\n Just (ByteStringReader r) -> Right $ ByteStringReader $ \\\\o ->\\n r o{ readerExtensions = setExts $\\n getDefaultExtensions readerName }\\n\\n-- | Retrieve writer based on formatSpec (format+extensions).\\ngetWriter :: String -> Either String Writer\\ngetWriter s\\n = case parseFormatSpec s of\\n Left e -> Left $ intercalate \"\\\\n\" $ [m | Message m <- errorMessages e]\\n Right (writerName, setExts) ->\\n case lookup writerName writers of\\n Nothing -> Left $ \"Unknown writer: \" ++ writerName\\n Just (PureStringWriter r) -> Right $ PureStringWriter $\\n \\\\o -> r o{ writerExtensions = setExts $\\n getDefaultExtensions writerName }\\n Just (IOStringWriter r) -> Right $ IOStringWriter $\\n \\\\o -> r o{ writerExtensions = setExts $\\n getDefaultExtensions writerName }\\n Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $\\n \\\\o -> r o{ writerExtensions = setExts $\\n getDefaultExtensions writerName }\\n\\n{-# DEPRECATED toJsonFilter \"Use \\'toJSONFilter\\' from \\'Text.Pandoc.JSON\\' instead\" #-}\\n-- | Deprecated. Use @toJSONFilter@ from @Text.Pandoc.JSON@ instead.\\nclass ToJSONFilter a => ToJsonFilter a\\n where toJsonFilter :: a -> IO ()\\n toJsonFilter = toJSONFilter\\n\\nreadJSON :: ReaderOptions -> String -> Pandoc\\nreadJSON _ = either error id . eitherDecode\\' . UTF8.fromStringLazy\\n\\nwriteJSON :: WriterOptions -> Pandoc -> String\\nwriteJSON _ = UTF8.toStringLazy . encode',\n", + " 'reverseDependencies :: ModuleGraph -> M.Map ModuleName [ModuleName]\\nreverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ]\\n where\\n combine :: (Ord a) => [(a, b)] -> M.Map a [b]\\n combine = M.fromList . map ((fst . head) &&& map snd) . groupBy ((==) `on` fst) . sortBy (compare `on` fst)',\n", + " '{- git-annex extra config files\\n -\\n - Copyright 2012 Joey Hess \\n -\\n - Licensed under the GNU GPL version 3 or higher.\\n -}\\n\\nmodule Config.Files where\\n\\nimport Common\\nimport Utility.Tmp\\nimport Utility.FreeDesktop\\n\\n{- ~/.config/git-annex/file -}\\nuserConfigFile :: FilePath -> IO FilePath\\nuserConfigFile file = do\\n\\tdir <- userConfigDir\\n\\treturn $ dir \"git-annex\" file\\n\\nautoStartFile :: IO FilePath\\nautoStartFile = userConfigFile \"autostart\"\\n\\n{- Returns anything listed in the autostart file (which may not exist). -}\\nreadAutoStartFile :: IO [FilePath]\\nreadAutoStartFile = do\\n\\tf <- autoStartFile\\n\\tnub . map dropTrailingPathSeparator . lines\\n\\t\\t<$> catchDefaultIO \"\" (readFile f)\\n\\nmodifyAutoStartFile :: ([FilePath] -> [FilePath]) -> IO ()\\nmodifyAutoStartFile func = do\\n\\tdirs <- readAutoStartFile\\n\\tlet dirs\\' = nubBy equalFilePath $ func dirs\\n\\twhen (dirs\\' /= dirs) $ do\\n\\t\\tf <- autoStartFile\\n\\t\\tcreateDirectoryIfMissing True (parentDir f)\\n\\t\\tviaTmp writeFile f $ unlines dirs\\'\\n\\n{- Adds a directory to the autostart file. If the directory is already\\n - present, it\\'s moved to the top, so it will be used as the default\\n - when opening the webapp. -}\\naddAutoStartFile :: FilePath -> IO ()\\naddAutoStartFile path = modifyAutoStartFile $ (:) path\\n\\n{- Removes a directory from the autostart file. -}\\nremoveAutoStartFile :: FilePath -> IO ()\\nremoveAutoStartFile path = modifyAutoStartFile $\\n\\tfilter (not . equalFilePath path)\\n\\n{- The path to git-annex is written here; which is useful when cabal\\n - has installed it to some awful non-PATH location. -}\\nprogramFile :: IO FilePath\\nprogramFile = userConfigFile \"program\"\\n\\n{- Returns a command to run for git-annex. -}\\nreadProgramFile :: IO FilePath\\nreadProgramFile = do\\n\\tprogramfile <- programFile\\n\\tp <- catchDefaultIO cmd $ \\n\\t\\tfromMaybe cmd . headMaybe . lines <$> readFile programfile\\n\\tifM (inPath p)\\n\\t\\t( return p\\n\\t\\t, ifM (inPath cmd)\\n\\t\\t\\t( return cmd\\n\\t\\t\\t, error $ \"cannot find git-annex program in PATH or in the location listed in \" ++ programfile\\n\\t\\t\\t)\\n\\t\\t)\\n where\\n\\tcmd = \"git-annex\"',\n", + " \"(define subst-f\\n (lambda (new old l)\\n (cond\\n ((null? l) '())\\n ((eq? (car l) old)\\n (cons new (cdr l)))\\n (else\\n (cons (car l) (subst new old (cdr l)))))))\\n\\n; The seqS function is what subst does that neither insertL nor insertR do\\n;\\n(define seqS\\n (lambda (new old l)\\n (cons new l)))\\n\\n; subst is now just (insret-g seqS)\\n;\\n(define subst (insert-g seqS))\",\n", + " '(define add1\\n (lambda (n) (+ n 1)))',\n", + " '(define-lib-primitive (length lst)\\n (if (null? lst)\\n 0\\n (fxadd1 (length (cdr lst)))))\\n\\n(define-lib-primitive (fill args setop)\\n (letrec ([rec (lambda (index args)\\n (unless (null? args)\\n (setop index (car args))\\n (rec (fxadd1 index) (cdr args))))])\\n (rec 0 args)))\\n \\n(define-lib-primitive (vector . args)\\n (let ([v (make-vector (length args))])\\n (fill args (lambda (index arg) (vector-set! v index arg)))\\n v))\\n\\n(define-lib-primitive (string . args)\\n (let ([s (make-string (length args))])\\n (fill args (lambda (index arg) (string-set! s index arg)))\\n s))\\n\\n(define-lib-primitive (list . args)\\n args)\\n\\n(define-lib-primitive (make_cell value)\\n (cons value \\'()))\\n\\n(define-lib-primitive (cell_get cell)\\n (car cell))\\n\\n(define-lib-primitive (cell_set cell value)\\n (set-car! cell value))\\n\\n(define-lib-primitive __symbols__\\n (make_cell \\'()))\\n\\n(define-lib-primitive (string=? s1 s2)\\n (letrec ([rec (lambda (index)\\n (or (fx= index (string-length s1))\\n (and (char= (string-ref s1 index) (string-ref s2 index))\\n (rec (fxadd1 index)))))])\\n (and (string? s1) (string? s2) (fx= (string-length s1) (string-length s2)) (rec 0))))\\n \\n(define-lib-primitive (__find_symbol__ str)\\n (letrec ([rec (lambda (symbols)\\n (cond\\n [(null? symbols) #f]\\n [(string=? str (string-symbol (car symbols))) (car symbols)]\\n [else (rec (cdr symbols))]))])\\n (rec (cell_get __symbols__))))\\n\\n(define-lib-primitive (string->symbol str)\\n (or (__find_symbol__ str)\\n (let ([symbol (make-symbol str)])\\n (cell_set __symbols__ (cons symbol (cell_get __symbols__)))\\n symbol)))\\n\\n(define-lib-primitive (error . args)\\n (foreign-call \"ik_error\" args))\\n\\n(define-lib-primitive (log msg)\\n (foreign-call \"ik_log\" msg))\\n\\n(define-lib-primitive (string-set! s i c)\\n (cond\\n [(not (string? s)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (char? c)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)]\\n [else ($string-set! s i c)]))\\n\\n(define-lib-primitive (string-ref s i)\\n (cond\\n [(not (string? s)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)]\\n [else ($string-ref s i)]))\\n\\n(define-lib-primitive (vector-set! v i e)\\n (cond\\n [(not (vector? v)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)]\\n [else ($vector-set! v i e)]))\\n\\n(define-lib-primitive (vector-ref v i)\\n (cond\\n [(not (vector? v)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)]\\n [else ($vector-ref v i)]))\\n\\n(define-lib-primitive (liftneg f a b)\\n (cond\\n [(and (fx< a 0) (fx>= b 0))\\n (fx- 0 (f (fx- 0 a) b))]\\n [(and (fx>= a 0) (fx< b 0))\\n (fx- 0 (f a (fx- 0 b)))]\\n [(and (fx< a 0) (fx< b 0))\\n (f (fx- 0 a) (fx- 0 b))]\\n [else\\n (f a b)]))\\n\\n(define-lib-primitive (liftneg1 f a b)\\n (cond\\n [(and (fx< a 0) (fx>= b 0))\\n (fx- 0 (f (fx- 0 a) b))]\\n [(and (fx>= a 0) (fx< b 0))\\n (f a (fx- 0 b))]\\n [(and (fx< a 0) (fx< b 0))\\n (fx- 0 (f (fx- 0 a) (fx- 0 b)))]\\n [else\\n (f a b)]))\\n \\n(define-lib-primitive (fxquotient a b)\\n (liftneg (lambda (a b) ($fxquotient a b)) a b))\\n\\n(define-lib-primitive (fxremainder a b)\\n (liftneg1 (lambda (a b) ($fxremainder a b)) a b))\\n\\n(define-lib-primitive (exit . args)\\n (let ([status (if (null? args) 0 (car args))])\\n (foreign-call \"exit\" status)))\\n\\n(define-lib-primitive (s_write fd str len)\\n (foreign-call \"s_write\" fd str len))\\n\\n(define-lib-primitive stdout\\n (make-output-port \"\" 1))\\n\\n(define-lib-primitive (current-output-port)\\n stdout)\\n\\n(define-lib-primitive BUFFER_SIZE 4096)\\n\\n(define-lib-primitive (open-output-file fname . args)\\n (let ([fd (foreign-call \"s_open_write\" fname)])\\n (make-output-port fname fd)))\\n \\n(define-lib-primitive (make-output-port fname fd)\\n (vector \\'output-port fname fd (make-string BUFFER_SIZE) 0 BUFFER_SIZE))\\n\\n(define-lib-primitive (output-port-fname port)\\n (vector-ref port 1))\\n\\n(define-lib-primitive (output-port-fd port)\\n (vector-ref port 2))\\n\\n(define-lib-primitive (output-port-buffer port)\\n (vector-ref port 3))\\n\\n(define-lib-primitive (output-port-buffer-index port)\\n (vector-ref port 4))\\n\\n(define-lib-primitive (output-port-buffer-size port)\\n (vector-ref port 5))\\n\\n(define-lib-primitive (set-output-port-buffer-index! port index)\\n (vector-set! port 4 index))\\n\\n(define-lib-primitive (inc-output-port-buffer-index! port)\\n (set-output-port-buffer-index! port (fxadd1 (output-port-buffer-index port))))\\n\\n(define-lib-primitive (write-char c (port (current-output-port)))\\n (string-set! (output-port-buffer port) (output-port-buffer-index port) c)\\n (inc-output-port-buffer-index! port)\\n (when (fx= (output-port-buffer-index port) (output-port-buffer-size port))\\n\\t(output-port-write-buffer port)))\\n\\n(define-lib-primitive (output-port? x)\\n (and (vector? x) (fx= (vector-length x) 6) (eq? \\'output-port (vector-ref x 0))))\\n\\n(define-lib-primitive (output-port-write-buffer port)\\n (s_write (output-port-fd port)\\n\\t (output-port-buffer port)\\n\\t (output-port-buffer-index port))\\n (set-output-port-buffer-index! port 0))\\n\\n(define-lib-primitive (flush-output-port (port (current-output-port)))\\n (output-port-write-buffer port)\\n (foreign-call \"s_fflush\" (output-port-fd port)))\\n\\n(define-lib-primitive (close-output-port port)\\n (flush-output-port port)\\n (unless (string=? \"\" (output-port-fname port))\\n\\t (foreign-call \"s_close\" (output-port-fd port))))\\n\\n(define-lib-primitive (write x (port (current-output-port)))\\n (flush-output-port port)\\n ;; This is cheating... should write it in Scheme.\\n (foreign-call \"scheme_write\" (output-port-fd port) x 0)\\n (flush-output-port port))\\n\\n(define-lib-primitive (display x (port (current-output-port)))\\n (flush-output-port port)\\n (foreign-call \"scheme_write\" (output-port-fd port) x 2)\\n (flush-output-port port))\\n\\n(define-lib-primitive (open-input-file fname . args)\\n (let ([fd (foreign-call \"s_open_read\" fname)])\\n (make-input-port fname fd)))\\n \\n(define-lib-primitive (make-input-port fname fd)\\n (vector \\'input-port fname fd))\\n\\n(define-lib-primitive (input-port-fname port)\\n (vector-ref port 1))\\n\\n(define-lib-primitive (input-port-fd port)\\n (vector-ref port 2))\\n\\n(define-lib-primitive (input-port? x)\\n (and (vector? x) (fx= (vector-length x) 3) (eq? \\'input-port (vector-ref x 0))))\\n\\n(define-lib-primitive (read-char port)\\n (foreign-call \"s_read_char\" (input-port-fd port)))\\n\\n(define-lib-primitive (close-input-port port)\\n (foreign-call \"s_close\" (input-port-fd port)))',\n", + " \"/**\\n * Interface to represent a persistence store for archives\\n *\\n * @author James Kojo\\n * @author Vasanth Asokan\\n */\\npublic interface ArchiveRepository {\\n /**\\n * Get the ID of this repository\\n * @return the id string.\\n */\\n public String getRepositoryId();\\n\\n /**\\n * Get the default view into this repository.\\n * @return the default repository view.\\n */\\n public RepositoryView getDefaultView();\\n\\n /**\\n * Get a specific named view into this repository.\\n *\\n * @param view the name of the view.\\n * @return a {@link RepositoryView} that matches the given name or null if\\n * one wasn't found.\\n * @throws UnsupportedOperationException\\n * if this repository does not support named views.\\n */\\n public RepositoryView getView(String view);\\n\\n /**\\n * Insert a Jar into the repository\\n * @param jarScriptArchive script archive which describes the jar and\\n * the ModuleSpec which should be inserted\\n */\\n public void insertArchive(JarScriptArchive jarScriptArchive)\\n throws IOException;\\n\\n /**\\n * Insert a Jar into the repository\\n * @param jarScriptArchive script archive which describes the jar and\\n * the ModuleSpec which should be inserted\\n * @param initialDeploySpecs a set of initial deployment specs.\\n * @throws UnsupportedOperationException if this repository does not support\\n * adding deploy specs to a module.\\n */\\n public void insertArchive(JarScriptArchive jarScriptArchive, Map initialDeploySpecs)\\n throws IOException;\\n\\n /**\\n * Get all of the {@link ScriptArchive}s for the given set of moduleIds.\\n *\\n * @param moduleIds keys to search for\\n * @return set of ScriptArchives retrieved from the database\\n */\\n public Set getScriptArchives(Set moduleIds) throws IOException;\\n\\n /**\\n * Delete an archive by ID\\n * @param moduleId module id to delete\\n * @throws IOException\\n */\\n public void deleteArchive(ModuleId moduleId) throws IOException;\\n}\",\n", + " '/*\\n * Copyright 2002-2008 the original author or authors.\\n *\\n * Licensed under the Apache License, Version 2.0 (the \"License\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \"AS IS\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n */\\n\\npackage org.springframework.core;\\n\\n/**\\n * Common interface for managing aliases. Serves as super-interface for\\n * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}.\\n *\\n * @author Juergen Hoeller\\n * @since 2.5.2\\n */\\npublic interface AliasRegistry {\\n\\n\\t/**\\n\\t * Given a name, register an alias for it.\\n\\t * @param name the canonical name\\n\\t * @param alias the alias to be registered\\n\\t * @throws IllegalStateException if the alias is already in use\\n\\t * and may not be overridden\\n\\t */\\n\\tvoid registerAlias(String name, String alias);\\n\\n\\t/**\\n\\t * Remove the specified alias from this registry.\\n\\t * @param alias the alias to remove\\n\\t * @throws IllegalStateException if no such alias was found\\n\\t */\\n\\tvoid removeAlias(String alias);\\n\\n\\t/**\\n\\t * Determine whether this given name is defines as an alias\\n\\t * (as opposed to the name of an actually registered component).\\n\\t * @param beanName the bean name to check\\n\\t * @return whether the given name is an alias\\n\\t */\\n\\tboolean isAlias(String beanName);\\n\\n\\t/**\\n\\t * Return the aliases for the given name, if defined.\\n\\t * @param name the name to check for aliases\\n\\t * @return the aliases, or an empty array if none\\n\\t */\\n\\tString[] getAliases(String name);\\n\\n}',\n", + " 'package com.github.pathikrit\\n\\nimport scala.annotation.StaticAnnotation\\n\\nclass MetaRest extends StaticAnnotation {\\n def macroTransform(annottees: Any*): Any = macro MetaRest.impl\\n}\\n\\nobject MetaRest {\\n sealed trait MethodAnnotations extends StaticAnnotation\\n class get extends MethodAnnotations\\n class put extends MethodAnnotations\\n class post extends MethodAnnotations\\n class patch extends MethodAnnotations\\n object MethodAnnotations {\\n val values = List(\"get\", \"post\", \"put\", \"patch\") //TODO: use some enum/sealed trait macro to do this automatically\\n }\\n\\n def impl(c: macros.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {\\n import c.universe._\\n\\n def withCompileError[A](msg: String)(block: => A): A = try {\\n block\\n } catch {\\n case _: MatchError => c.abort(c.enclosingPosition, s\"@MetaRest: $msg\")\\n }\\n\\n def generateModels(fields: List[ValDef]) = {\\n val fieldsWithAnnotations = fields.map(_.mods.annotations).zip(fields)\\n val newFields = fieldsWithAnnotations flatMap { case (annotations, field) =>\\n annotations.map(_ -> field) collect {\\n case (q\"new patch\", q\"$accessor val $vname: $tpe\") => \"patch\" -> q\"$accessor val $vname: Option[$tpe] = None\"\\n case (q\"new $annotation\", f) if MethodAnnotations.values contains annotation.toString => annotation.toString -> f.duplicate\\n }\\n }\\n newFields.groupBy(_._1) map { case (annotation, values) =>\\n val (className, classFields) = (macros.toTypeName(c)(annotation.capitalize), values.map(_._2))\\n q\"@com.kifi.macros.json case class $className(..$classFields)\" //TODO: Switch back to jsonstrict once this is fixed: https://github.com/kifi/json-annotation/issues/7\\n }\\n }\\n\\n def modifiedDeclaration(classDecl: ClassDef, compDeclOpt: Option[ModuleDef] = None) = {\\n val (className, fields) = withCompileError(\"must annotate a case class\") {\\n val q\"case class $className(..$fields) extends ..$bases { ..$body }\" = classDecl\\n (className, fields)\\n }\\n\\n val compDecl = compDeclOpt map { compDecl =>\\n val q\"object $obj extends ..$bases { ..$body }\" = compDecl\\n q\"\"\"\\n object $obj extends ..$bases {\\n ..$body\\n ..${generateModels(fields)}\\n }\\n \"\"\"\\n } getOrElse {\\n q\"\"\"\\n object ${className.toTermName} {\\n ..${generateModels(fields)}\\n }\\n \"\"\"\\n }\\n\\n c.Expr(q\"\"\"\\n $classDecl\\n $compDecl\\n \"\"\")\\n }\\n\\n withCompileError(\"must annotate a class\") {\\n annottees.map(_.tree) match {\\n case (classDecl: ClassDef) :: Nil => modifiedDeclaration(classDecl)\\n case (classDecl: ClassDef) :: (compDecl: ModuleDef) :: Nil => modifiedDeclaration(classDecl, Some(compDecl))\\n }\\n }\\n }\\n}',\n", + " \"/* sbt -- Simple Build Tool\\n * Copyright 2010, 2011 Mark Harrah\\n */\\npackage object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtra with sbt.impl.DependencyBuilders\\n with sbt.PathExtra with sbt.ProjectExtra with sbt.DependencyFilterExtra with sbt.BuildExtra with sbt.TaskMacroExtra\\n with sbt.ScopeFilter.Make {\\n type Setting[T] = Def.Setting[T]\\n type ScopedKey[T] = Def.ScopedKey[T]\\n type SettingsDefinition = Def.SettingsDefinition\\n type File = java.io.File\\n type URI = java.net.URI\\n type URL = java.net.URL\\n\\n object CompileOrder {\\n val JavaThenScala = xsbti.compile.CompileOrder.JavaThenScala\\n val ScalaThenJava = xsbti.compile.CompileOrder.ScalaThenJava\\n val Mixed = xsbti.compile.CompileOrder.Mixed\\n }\\n type CompileOrder = xsbti.compile.CompileOrder\\n\\n implicit def maybeToOption[S](m: xsbti.Maybe[S]): Option[S] =\\n if (m.isDefined) Some(m.get) else None\\n def uri(s: String): URI = new URI(s)\\n def file(s: String): File = new File(s)\\n def url(s: String): URL = new URL(s)\\n\\n final val ThisScope = Scope.ThisScope\\n final val GlobalScope = Scope.GlobalScope\\n\\n import sbt.{ Configurations => C }\\n final val Compile = C.Compile\\n final val Test = C.Test\\n final val Runtime = C.Runtime\\n final val IntegrationTest = C.IntegrationTest\\n final val Default = C.Default\\n final val Docs = C.Docs\\n final val Sources = C.Sources\\n final val Provided = C.Provided\\n // java.lang.System is more important, so don't alias this one\\n //\\tfinal val System = C.System\\n final val Optional = C.Optional\\n def config(s: String): Configuration = Configurations.config(s)\\n\\n import language.experimental.macros\\n def settingKey[T](description: String): SettingKey[T] = macro std.KeyMacro.settingKeyImpl[T]\\n def taskKey[T](description: String): TaskKey[T] = macro std.KeyMacro.taskKeyImpl[T]\\n def inputKey[T](description: String): InputKey[T] = macro std.KeyMacro.inputKeyImpl[T]\\n}\",\n", + " 'class View\\n{\\n /**\\n * Data available to the view templates\\n * @var \\\\Slim\\\\Helper\\\\Set\\n */\\n protected $data;\\n /**\\n * Path to templates base directory (without trailing slash)\\n * @var string\\n */\\n protected $templatesDirectory;\\n /**\\n * Constructor\\n */\\n public function __construct()\\n {\\n $this->data = new \\\\Slim\\\\Helper\\\\Set();\\n }\\n /********************************************************************************\\n * Data methods\\n *******************************************************************************/\\n /**\\n * Does view data have value with key?\\n * @param string $key\\n * @return boolean\\n */\\n public function has($key)\\n {\\n return $this->data->has($key);\\n }\\n /**\\n * Return view data value with key\\n * @param string $key\\n * @return mixed\\n */\\n public function get($key)\\n {\\n return $this->data->get($key);\\n }\\n /**\\n * Set view data value with key\\n * @param string $key\\n * @param mixed $value\\n */\\n public function set($key, $value)\\n {\\n $this->data->set($key, $value);\\n }\\n /**\\n * Set view data value as Closure with key\\n * @param string $key\\n * @param mixed $value\\n */\\n public function keep($key, \\\\Closure $value)\\n {\\n $this->data->keep($key, $value);\\n }\\n /**\\n * Return view data\\n * @return array\\n */\\n public function all()\\n {\\n return $this->data->all();\\n }\\n /**\\n * Replace view data\\n * @param array $data\\n */\\n public function replace(array $data)\\n {\\n $this->data->replace($data);\\n }\\n /**\\n * Clear view data\\n */\\n public function clear()\\n {\\n $this->data->clear();\\n }\\n /********************************************************************************\\n * Legacy data methods\\n *******************************************************************************/\\n /**\\n * DEPRECATION WARNING! This method will be removed in the next major point release\\n *\\n * Get data from view\\n */\\n public function getData($key = null)\\n {\\n if (!is_null($key)) {\\n return isset($this->data[$key]) ? $this->data[$key] : null;\\n } else {\\n return $this->data->all();\\n }\\n }\\n /**\\n * DEPRECATION WARNING! This method will be removed in the next major point release\\n *\\n * Set data for view\\n */\\n public function setData()\\n {\\n $args = func_get_args();\\n if (count($args) === 1 && is_array($args[0])) {\\n $this->data->replace($args[0]);\\n } elseif (count($args) === 2) {\\n // Ensure original behavior is maintained. DO NOT invoke stored Closures.\\n if (is_object($args[1]) && method_exists($args[1], \\'__invoke\\')) {\\n $this->data->set($args[0], $this->data->protect($args[1]));\\n } else {\\n $this->data->set($args[0], $args[1]);\\n }\\n } else {\\n throw new \\\\InvalidArgumentException(\\'Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`\\');\\n }\\n }\\n /**\\n * DEPRECATION WARNING! This method will be removed in the next major point release\\n *\\n * Append data to view\\n * @param array $data\\n */\\n public function appendData($data)\\n {\\n if (!is_array($data)) {\\n throw new \\\\InvalidArgumentException(\\'Cannot append view data. Expected array argument.\\');\\n }\\n $this->data->replace($data);\\n }\\n /********************************************************************************\\n * Resolve template paths\\n *******************************************************************************/\\n /**\\n * Set the base directory that contains view templates\\n * @param string $directory\\n * @throws \\\\InvalidArgumentException If directory is not a directory\\n */\\n public function setTemplatesDirectory($directory)\\n {\\n $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR);\\n }\\n /**\\n * Get templates base directory\\n * @return string\\n */\\n public function getTemplatesDirectory()\\n {\\n return $this->templatesDirectory;\\n }\\n /**\\n * Get fully qualified path to template file using templates base directory\\n * @param string $file The template file pathname relative to templates base directory\\n * @return string\\n */\\n public function getTemplatePathname($file)\\n {\\n return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR);\\n }\\n /********************************************************************************\\n * Rendering\\n *******************************************************************************/\\n /**\\n * Display template\\n *\\n * This method echoes the rendered template to the current output buffer\\n *\\n * @param string $template Pathname of template file relative to templates directory\\n * @param array $data Any additonal data to be passed to the template.\\n */\\n public function display($template, $data = null)\\n {\\n echo $this->fetch($template, $data);\\n }\\n /**\\n * Return the contents of a rendered template file\\n *\\n * @param string $template The template pathname, relative to the template base directory\\n * @param array $data Any additonal data to be passed to the template.\\n * @return string The rendered template\\n */\\n public function fetch($template, $data = null)\\n {\\n return $this->render($template, $data);\\n }\\n /**\\n * Render a template file\\n *\\n * NOTE: This method should be overridden by custom view subclasses\\n *\\n * @param string $template The template pathname, relative to the template base directory\\n * @param array $data Any additonal data to be passed to the template.\\n * @return string The rendered template\\n * @throws \\\\RuntimeException If resolved template pathname is not a valid file\\n */\\n protected function render($template, $data = null)\\n {\\n $templatePathname = $this->getTemplatePathname($template);\\n if (!is_file($templatePathname)) {\\n throw new \\\\RuntimeException(\"View cannot render `$template` because the template does not exist\");\\n }\\n $data = array_merge($this->data->all(), (array) $data);\\n extract($data);\\n ob_start();\\n require $templatePathname;\\n return ob_get_clean();\\n }\\n}',\n", + " \" public function formatLocalized($format)\\n {\\n // Check for Windows to find and replace the %e\\n // modifier correctly\\n if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {\\n $format = preg_replace('#(?getContainer();\\n\\t\\t/**\\n\\t\\t * Controllers\\n\\t\\t */\\n\\t\\t$container->registerService('LostController', function(SimpleContainer $c) {\\n\\t\\t\\treturn new LostController(\\n\\t\\t\\t\\t$c->query('AppName'),\\n\\t\\t\\t\\t$c->query('Request'),\\n\\t\\t\\t\\t$c->query('URLGenerator'),\\n\\t\\t\\t\\t$c->query('UserManager'),\\n\\t\\t\\t\\t$c->query('Defaults'),\\n\\t\\t\\t\\t$c->query('L10N'),\\n\\t\\t\\t\\t$c->query('Config'),\\n\\t\\t\\t\\t$c->query('SecureRandom'),\\n\\t\\t\\t\\t$c->query('DefaultEmailAddress'),\\n\\t\\t\\t\\t$c->query('IsEncryptionEnabled')\\n\\t\\t\\t);\\n\\t\\t});\\n\\t\\t$container->registerService('UserController', function(SimpleContainer $c) {\\n\\t\\t\\treturn new UserController(\\n\\t\\t\\t\\t$c->query('AppName'),\\n\\t\\t\\t\\t$c->query('Request'),\\n\\t\\t\\t\\t$c->query('UserManager'),\\n\\t\\t\\t\\t$c->query('Defaults')\\n\\t\\t\\t);\\n\\t\\t});\\n\\t\\t/**\\n\\t\\t * Core class wrappers\\n\\t\\t */\\n\\t\\t$container->registerService('IsEncryptionEnabled', function() {\\n\\t\\t\\treturn \\\\OC_App::isEnabled('files_encryption');\\n\\t\\t});\\n\\t\\t$container->registerService('URLGenerator', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getURLGenerator();\\n\\t\\t});\\n\\t\\t$container->registerService('UserManager', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getUserManager();\\n\\t\\t});\\n\\t\\t$container->registerService('Config', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getConfig();\\n\\t\\t});\\n\\t\\t$container->registerService('L10N', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getL10N('core');\\n\\t\\t});\\n\\t\\t$container->registerService('SecureRandom', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getSecureRandom();\\n\\t\\t});\\n\\t\\t$container->registerService('Defaults', function() {\\n\\t\\t\\treturn new \\\\OC_Defaults;\\n\\t\\t});\\n\\t\\t$container->registerService('DefaultEmailAddress', function() {\\n\\t\\t\\treturn Util::getDefaultEmailAddress('lostpassword-noreply');\\n\\t\\t});\\n\\t}\\n}\",\n", + " 'type name = string\\n\\nlet compare_label label1 label2 =\\n\\tlet compare_length = compare (String.length label1) (String.length label2) in\\n\\tif compare_length = 0 then\\n\\t\\tString.compare label1 label2\\n\\telse compare_length\\n\\n\\nmodule LabelMap = Map.Make(\\n\\tstruct\\n\\t\\ttype t = name\\n\\t\\tlet compare = compare_label\\n\\tend)\\n\\ntype expr =\\n\\t| Var of name (* variable *)\\n\\t| Call of expr * expr list (* application *)\\n\\t| Fun of name list * expr (* abstraction *)\\n\\t| Let of name * expr * expr (* let *)\\n\\t| RecordSelect of expr * name (* selecting value of label: `r.a` *)\\n\\t| RecordExtend of (expr list) LabelMap.t * expr (* extending a record: `{a = 1, b = 2 | r}` *)\\n\\t| RecordRestrict of expr * name (* deleting a label: `{r - a}` *)\\n\\t| RecordEmpty (* empty record: `{}` *)\\n\\t| Variant of name * expr (* new variant value: `:X a` *)\\n\\t| Case of expr * (name * name * expr) list * (name * expr) option\\n\\t\\t\\t(* a pattern-matching case expression:\\n\\t\\t\\t\\t\\tmatch e {\\n\\t\\t\\t\\t\\t\\t\\t:X a -> expr1\\n\\t\\t\\t\\t\\t\\t| :Y b -> expr2\\n\\t\\t\\t\\t\\t\\t...\\n\\t\\t\\t\\t\\t\\t| z -> default_expr (optional)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t*)\\n\\ntype id = int\\ntype level = int\\n\\ntype ty =\\n\\t| TConst of name (* type constant: `int` or `bool` *)\\n\\t| TApp of ty * ty list (* type application: `list[int]` *)\\n\\t| TArrow of ty list * ty (* function type: `(int, int) -> int` *)\\n\\t| TVar of tvar ref (* type variable *)\\n\\t| TRecord of row (* record type: `{...}` *)\\n\\t| TVariant of row (* variant type: `[...]` *)\\n\\t| TRowEmpty (* empty row: `<>` *)\\n\\t| TRowExtend of (ty list) LabelMap.t * row (* row extension: `
` *)\\n\\nand row = ty (* the kind of rows - empty row, row variable, or row extension *)\\n\\nand tvar =\\n\\t| Unbound of id * level\\n\\t| Link of ty\\n\\t| Generic of id\\n\\n\\nlet rec real_ty = function\\n\\t| TVar {contents = Link ty} -> real_ty ty\\n\\t| ty -> ty\\n\\nlet merge_label_maps label_map1 label_map2 =\\n\\tLabelMap.merge\\n\\t\\t(fun label maybe_ty_list1 maybe_ty_list2 ->\\n\\t\\t\\tmatch maybe_ty_list1, maybe_ty_list2 with\\n\\t\\t\\t\\t| None, None -> assert false\\n\\t\\t\\t\\t| None, (Some ty_list2) -> Some ty_list2\\n\\t\\t\\t\\t| (Some ty_list1), None -> Some ty_list1\\n\\t\\t\\t\\t| (Some ty_list1), (Some ty_list2) -> Some (ty_list1 @ ty_list2))\\n\\t\\tlabel_map1 label_map2\\n\\n(* Returns a label map with all field types and the type of the \"rest\",\\n which is either a type var or an empty row. *)\\nlet rec match_row_ty = function\\n\\t| TRowExtend(label_ty_map, rest_ty) -> begin\\n\\t\\t\\tmatch match_row_ty rest_ty with\\n\\t\\t\\t\\t| (rest_label_ty_map, rest_ty) when LabelMap.is_empty rest_label_ty_map ->\\n\\t\\t\\t\\t\\t\\t(label_ty_map, rest_ty)\\n\\t\\t\\t\\t| (rest_label_ty_map, rest_ty) ->\\n\\t\\t\\t\\t\\t\\t(merge_label_maps label_ty_map rest_label_ty_map, rest_ty)\\n\\t\\tend\\n\\t| TVar {contents = Link ty} -> match_row_ty ty\\n\\t| TVar _ as var -> (LabelMap.empty, var)\\n\\t| TRowEmpty -> (LabelMap.empty, TRowEmpty)\\n\\t| ty -> raise (Failure \"not a row\")\\n\\n(* Adds new bindings to a label map. Assumes all bindings (both\\n new and existing) are distinct. *)\\nlet add_distinct_labels label_el_map label_el_list =\\n\\tList.fold_left\\n\\t\\t(fun label_el_map (label, el) ->\\n\\t\\t\\tassert (not (LabelMap.mem label label_el_map)) ;\\n\\t\\t\\tLabelMap.add label el label_el_map)\\n\\tlabel_el_map label_el_list\\n\\nlet label_map_from_list label_el_list =\\n\\tadd_distinct_labels LabelMap.empty label_el_list\\n\\n\\n\\nlet string_of_expr expr : string =\\n\\tlet rec f is_simple = function\\n\\t\\t| Var name -> name\\n\\t\\t| Call(fn_expr, arg_list) ->\\n\\t\\t\\t\\tf true fn_expr ^ \"(\" ^ String.concat \", \" (List.map (f false) arg_list) ^ \")\"\\n\\t\\t| Fun(param_list, body_expr) ->\\n\\t\\t\\t\\tlet fun_str =\\n\\t\\t\\t\\t\\t\"fun \" ^ String.concat \" \" param_list ^ \" -> \" ^ f false body_expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tif is_simple then \"(\" ^ fun_str ^ \")\" else fun_str\\n\\t\\t| Let(var_name, value_expr, body_expr) ->\\n\\t\\t\\t\\tlet let_str =\\n\\t\\t\\t\\t\\t\"let \" ^ var_name ^ \" = \" ^ f false value_expr ^ \" in \" ^ f false body_expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tif is_simple then \"(\" ^ let_str ^ \")\" else let_str\\n\\t\\t| RecordEmpty -> \"{}\"\\n\\t\\t| RecordSelect(record_expr, label) -> f true record_expr ^ \".\" ^ label\\n\\t\\t| RecordRestrict(record_expr, label) -> \"{\" ^ f false record_expr ^ \" - \" ^ label ^ \"}\"\\n\\t\\t| RecordExtend(label_expr_map, rest_expr) ->\\n\\t\\t\\t\\tlet label_expr_str =\\n\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t(List.map\\n\\t\\t\\t\\t\\t\\t\\t(fun (label, expr_list) ->\\n\\t\\t\\t\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t(List.map (fun expr -> label ^ \" = \" ^ f false expr) expr_list))\\n\\t\\t\\t\\t\\t\\t\\t(LabelMap.bindings label_expr_map))\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlet rest_expr_str = match rest_expr with\\n\\t\\t\\t\\t\\t| RecordEmpty -> \"\"\\n\\t\\t\\t\\t\\t| expr -> \" | \" ^ f false expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\t\"{\" ^ label_expr_str ^ rest_expr_str ^ \"}\"\\n\\t\\t| Variant(label, value) ->\\n\\t\\t\\t\\tlet variant_str = \":\" ^ label ^ \" \" ^ f true value in\\n\\t\\t\\t\\tif is_simple then \"(\" ^ variant_str ^ \")\" else variant_str\\n\\t\\t| Case(expr, cases, maybe_default_case) ->\\n\\t\\t\\t\\tlet cases_str_list = List.map\\n\\t\\t\\t\\t\\t(fun (label, var_name, expr) ->\\n\\t\\t\\t\\t\\t\\t\"| :\" ^ label ^ \" \" ^ var_name ^ \" -> \" ^ f false expr)\\n\\t\\t\\t\\t\\tcases\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlet all_cases_str = match (cases_str_list, maybe_default_case) with\\n\\t\\t\\t\\t\\t| ([], Some (var_name, expr)) -> var_name ^ \" -> \" ^ f false expr\\n\\t\\t\\t\\t\\t| (cases_str_list, None) -> String.concat \"\" cases_str_list\\n\\t\\t\\t\\t\\t| (cases_str_list, Some (var_name, expr)) ->\\n\\t\\t\\t\\t\\t\\t\\tString.concat \"\" cases_str_list ^ \" | \" ^ var_name ^ \" -> \" ^ f false expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\t\"match \" ^ f false expr ^ \" { \" ^ all_cases_str ^ \" } \"\\n\\tin\\n\\tf false expr\\n\\nlet string_of_ty ty : string =\\n\\tlet id_name_map = Hashtbl.create 10 in\\n\\tlet count = ref 0 in\\n\\tlet next_name () =\\n\\t\\tlet i = !count in\\n\\t\\tincr count ;\\n\\t\\tlet name = String.make 1 (Char.chr (97 + i mod 26)) ^\\n\\t\\t\\tif i >= 26 then string_of_int (i / 26) else \"\"\\n\\t\\tin\\n\\t\\tname\\n\\tin\\n\\tlet rec f is_simple = function\\n\\t\\t| TConst name -> name\\n\\t\\t| TApp(ty, ty_arg_list) ->\\n\\t\\t\\t\\tf true ty ^ \"[\" ^ String.concat \", \" (List.map (f false) ty_arg_list) ^ \"]\"\\n\\t\\t| TArrow(param_ty_list, return_ty) ->\\n\\t\\t\\t\\tlet arrow_ty_str = match param_ty_list with\\n\\t\\t\\t\\t\\t| [param_ty] ->\\n\\t\\t\\t\\t\\t\\t\\tlet param_ty_str = f true param_ty in\\n\\t\\t\\t\\t\\t\\t\\tlet return_ty_str = f false return_ty in\\n\\t\\t\\t\\t\\t\\t\\tparam_ty_str ^ \" -> \" ^ return_ty_str\\n\\t\\t\\t\\t\\t| _ ->\\n\\t\\t\\t\\t\\t\\t\\tlet param_ty_list_str = String.concat \", \" (List.map (f false) param_ty_list) in\\n\\t\\t\\t\\t\\t\\t\\tlet return_ty_str = f false return_ty in\\n\\t\\t\\t\\t\\t\\t\\t\"(\" ^ param_ty_list_str ^ \") -> \" ^ return_ty_str\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tif is_simple then \"(\" ^ arrow_ty_str ^ \")\" else arrow_ty_str\\n\\t\\t| TVar {contents = Generic id} -> begin\\n\\t\\t\\t\\t\\ttry\\n\\t\\t\\t\\t\\t\\tHashtbl.find id_name_map id\\n\\t\\t\\t\\t\\twith Not_found ->\\n\\t\\t\\t\\t\\t\\tlet name = next_name () in\\n\\t\\t\\t\\t\\t\\tHashtbl.add id_name_map id name ;\\n\\t\\t\\t\\t\\t\\tname\\n\\t\\t\\t\\tend\\n\\t\\t| TVar {contents = Unbound(id, _)} -> \"_\" ^ string_of_int id\\n\\t\\t| TVar {contents = Link ty} -> f is_simple ty\\n\\t\\t| TRecord row_ty -> \"{\" ^ f false row_ty ^ \"}\"\\n\\t\\t| TVariant row_ty -> \"[\" ^ f false row_ty ^ \"]\"\\n\\t\\t| TRowEmpty -> \"\"\\n\\t\\t| TRowExtend _ as row_ty ->\\n\\t\\t\\t\\tlet (label_ty_map, rest_ty) = match_row_ty row_ty in\\n\\t\\t\\t\\tlet label_ty_str =\\n\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t(List.map\\n\\t\\t\\t\\t\\t\\t\\t(fun (label, ty_list) ->\\n\\t\\t\\t\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t(List.map (fun ty -> label ^ \" : \" ^ f false ty) ty_list))\\n\\t\\t\\t\\t\\t\\t\\t(LabelMap.bindings label_ty_map))\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlet rest_ty_str = match real_ty rest_ty with\\n\\t\\t\\t\\t\\t| TRowEmpty -> \"\"\\n\\t\\t\\t\\t\\t| TRowExtend _ -> assert false\\n\\t\\t\\t\\t\\t| other_ty -> \" | \" ^ f false other_ty\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlabel_ty_str ^ rest_ty_str\\n\\tin\\n\\tlet ty_str = f false ty in\\n\\tif !count > 0 then\\n\\t\\tlet var_names = Hashtbl.fold (fun _ value acc -> value :: acc) id_name_map [] in\\n\\t\\t\"forall[\" ^ String.concat \" \" (List.sort String.compare var_names) ^ \"] \" ^ ty_str\\n\\telse\\n\\t\\tty_str',\n", + " 'let search_compiler_libs () =\\n prerr_endline \"I: Searching for OCaml compiler libraries\";\\n let stdlib = BaseEnv.var_get \"standard_library\" in\\n let ( / ) = Filename.concat in\\n try\\n List.find (fun path -> Sys.file_exists (path / \"types.cmi\") || Sys.file_exists (path / \"typing\" / \"types.cmi\")) [\\n stdlib;\\n stdlib / \"compiler-libs\";\\n stdlib / \"compiler-lib\";\\n stdlib / \"..\" / \"compiler-libs\";\\n stdlib / \"..\" / \"compiler-lib\";\\n ]\\n with Not_found ->\\n prerr_endline \"E: Cannot find compiler libraries! See the README for details.\";\\n exit 1']" + ] + } + ], + "prompt_number": 279 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df" ], "language": "python", "metadata": {}, @@ -793,6 +970,7 @@ " \n", " \n", " \n", + " Filename\n", " Language\n", " Code\n", " let\n", @@ -802,12 +980,11 @@ " fun\n", " return\n", " def\n", - " check\n", " ...\n", + " .format\n", " define\n", " ::\n", " $\n", - " printf\n", " ^\n", " ,\n", " ;\n", @@ -818,5564 +995,1925 @@ " \n", " \n", " \n", - " 0 \n", + " 0 \n", + " 1\n", " clojure\n", - " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 0.002066\n", - " 0.000000\n", - " 0.002066\n", + " (defn cf-settings\\n \"Setup settings for campf...\n", + " 0.001759\n", + " 0.000880\n", + " 0.003518\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.004545\n", - " 0.005372\n", + " 0.003518\n", " ...\n", + " 0.000880\n", " 0.000000\n", " 0.000000\n", - " 0.000826\n", + " 0.000880\n", + " 0.000880\n", + " 0.009675\n", + " 0.000000\n", + " 0.000000\n", + " 1.000880\n", " 0.000000\n", - " 0.000413\n", - " 0.000826\n", - " 0.009091\n", - " 0.000413\n", - " 1.000413\n", - " 0.000826\n", " \n", " \n", - " 1 \n", + " 1 \n", + " 2\n", " clojure\n", - " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 0.002699\n", - " 0.000386\n", - " 0.001928\n", + " (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p...\n", " 0.000000\n", " 0.000000\n", + " 0.009852\n", " 0.000000\n", - " 0.003470\n", - " 0.005012\n", + " 0.000000\n", + " 0.000000\n", + " 0.009852\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000771\n", " 0.000000\n", - " 0.000386\n", - " 0.000771\n", - " 0.008096\n", - " 0.000771\n", - " 1.000386\n", - " 0.000771\n", + " 0.004926\n", + " 0.004926\n", + " 0.000000\n", + " 0.000000\n", + " 0.009852\n", + " 1.004926\n", + " 0.000000\n", " \n", " \n", - " 2 \n", + " 2 \n", + " 3\n", " clojure\n", - " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 0.002695\n", + " (extend-type String\\n Person\\n (first-name [...\n", + " 0.000000\n", + " 0.006993\n", + " 0.000000\n", " 0.000000\n", - " 0.002021\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.003705\n", - " 0.009094\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000674\n", " 0.000000\n", - " 0.000337\n", - " 0.001347\n", - " 0.010104\n", - " 0.000337\n", - " 1.000337\n", - " 0.000337\n", + " 0.006993\n", + " 0.006993\n", + " 0.000000\n", + " 0.000000\n", + " 0.000000\n", + " 1.006993\n", + " 0.000000\n", " \n", " \n", - " 3 \n", - " haskell\n", - " --\\n-- The Computer Language Benchmarks Game\\n...\n", - " 0.002471\n", + " 3 \n", + " 4\n", + " clojure\n", + " (require '[overtone.live :as overtone])\\n\\n(de...\n", + " 0.001675\n", " 0.000000\n", + " 0.001675\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.003350\n", + " ...\n", " 0.000000\n", " 0.000000\n", - " 0.006794\n", - " ...\n", " 0.000000\n", - " 0.002471\n", - " 0.001235\n", - " 0.000618\n", - " 0.000618\n", - " 0.006177\n", - " 0.000618\n", + " 0.001675\n", + " 0.001675\n", + " 0.006700\n", + " 0.006700\n", " 0.000000\n", - " 1.000618\n", - " 0.002471\n", + " 1.001675\n", + " 0.001675\n", " \n", " \n", - " 4 \n", - " haskell\n", - " --\\n-- The Computer Language Benchmarks Game\\n...\n", - " 0.002647\n", + " 4 \n", + " 5\n", + " python\n", + " from pkgutil import iter_modules\\nfrom subproc...\n", " 0.000000\n", + " 0.004983\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.006882\n", " ...\n", + " 0.004983\n", " 0.000000\n", - " 0.002118\n", - " 0.001059\n", - " 0.000529\n", - " 0.000529\n", - " 0.005294\n", - " 0.000529\n", " 0.000000\n", - " 1.000529\n", - " 0.003176\n", - " \n", - " \n", - " 5 \n", - " haskell\n", - " --\\n-- The Computer Language Benchmarks Game\\n...\n", - " 0.002865\n", + " 0.001661\n", + " 0.001661\n", + " 0.014950\n", " 0.000000\n", " 0.000000\n", + " 1.001661\n", " 0.000000\n", + " \n", + " \n", + " 5 \n", + " 6\n", + " python\n", + " import re\\nimport subprocess\\n\\ndef cmd_keymap...\n", " 0.000000\n", + " 0.001403\n", " 0.000000\n", " 0.000000\n", - " 0.007450\n", + " 0.000000\n", + " 0.001403\n", + " 0.001403\n", " ...\n", " 0.000000\n", - " 0.002292\n", - " 0.001146\n", - " 0.000573\n", - " 0.000573\n", - " 0.005158\n", - " 0.000573\n", " 0.000000\n", - " 1.000573\n", - " 0.002292\n", + " 0.000000\n", + " 0.000351\n", + " 0.000351\n", + " 0.003857\n", + " 0.000000\n", + " 0.000000\n", + " 1.000351\n", + " 0.000000\n", " \n", " \n", - " 6 \n", - " java\n", - " /* The Computer Language Benchmarks Game\\n h...\n", + " 6 \n", + " 7\n", + " python\n", + " class NoSuchService(Exception):\\n def __ini...\n", " 0.000000\n", - " 0.001228\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.000737\n", " 0.000000\n", - " 0.002947\n", + " 0.006135\n", + " 0.012270\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000491\n", - " 0.000000\n", - " 0.000246\n", - " 0.001719\n", - " 0.016208\n", " 0.000000\n", - " 1.000246\n", - " 0.000246\n", - " \n", - " \n", - " 7 \n", - " java\n", - " /* The Computer Language Benchmarks Game\\n h...\n", + " 0.003067\n", + " 0.003067\n", + " 0.006135\n", " 0.000000\n", " 0.000000\n", + " 1.003067\n", " 0.000000\n", + " \n", + " \n", + " 7 \n", + " 8\n", + " python\n", + " from collections import namedtuple\\nimport fun...\n", " 0.000000\n", + " 0.003158\n", " 0.000000\n", - " 0.001894\n", " 0.000000\n", - " 0.004261\n", + " 0.000148\n", + " 0.000691\n", + " 0.003059\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000947\n", - " 0.000000\n", - " 0.000473\n", - " 0.005682\n", - " 0.013258\n", " 0.000000\n", - " 1.000473\n", + " 0.000049\n", + " 0.000049\n", + " 0.014952\n", + " 0.000247\n", " 0.000000\n", + " 1.000049\n", + " 0.000247\n", " \n", " \n", - " 8 \n", - " java\n", - " /* The Computer Language Benchmarks Game\\n * h...\n", - " 0.000000\n", - " 0.000000\n", + " 8 \n", + " 9\n", + " javascript\n", + " function errorHandler(context) {\\n return fun...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.001391\n", + " 0.008982\n", + " 0.008982\n", + " 0.001497\n", " 0.000000\n", - " 0.006027\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000927\n", " 0.000000\n", - " 0.000464\n", - " 0.004636\n", - " 0.014372\n", + " 0.000749\n", + " 0.000749\n", + " 0.005240\n", + " 0.014222\n", " 0.000000\n", - " 1.000464\n", + " 1.000749\n", " 0.000000\n", " \n", " \n", - " 9 \n", + " 9 \n", + " 10\n", " javascript\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000000\n", + " var _ = require('lodash'),\\n fs = require('...\n", " 0.000000\n", " 0.000000\n", - " 0.002193\n", - " 0.002193\n", - " 0.002924\n", " 0.000000\n", - " 0.006579\n", + " 0.005731\n", + " 0.005731\n", + " 0.008596\n", + " 0.002865\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001462\n", " 0.000000\n", - " 0.000731\n", - " 0.010234\n", - " 0.017544\n", + " 0.005731\n", + " 0.002865\n", + " 0.011461\n", + " 0.011461\n", " 0.000000\n", - " 1.000731\n", + " 1.002865\n", " 0.000000\n", " \n", " \n", - " 10 \n", - " ruby\n", - " # The Computer Language Shootout Benchmarks\\n#...\n", + " 10\n", + " 11\n", + " javascript\n", + " /* Riot v2.0.8, @license MIT, (c) 2015 Muut In...\n", + " 0.000058\n", + " 0.000864\n", + " 0.000000\n", + " 0.004377\n", + " 0.004435\n", + " 0.002649\n", + " 0.000864\n", + " ...\n", + " 0.000000\n", + " 0.000576\n", + " 0.000000\n", + " 0.000058\n", + " 0.000058\n", + " 0.012844\n", + " 0.000691\n", + " 0.002361\n", + " 1.000058\n", + " 0.001498\n", + " \n", + " \n", + " 11\n", + " 12\n", + " javascript\n", + " var r = riot.route = function(arg) {\\n //...\n", " 0.000000\n", - " 0.003210\n", " 0.000000\n", " 0.000000\n", + " 0.011765\n", + " 0.011765\n", + " 0.000000\n", " 0.000000\n", - " 0.001605\n", - " 0.001605\n", - " 0.011236\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001605\n", " 0.000000\n", - " 0.000803\n", - " 0.011236\n", + " 0.005882\n", + " 0.005882\n", + " 0.005882\n", " 0.000000\n", " 0.000000\n", - " 1.000803\n", + " 1.005882\n", " 0.000000\n", " \n", " \n", - " 11 \n", + " 12\n", + " 13\n", " ruby\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", + " module ActiveJob\\n module Core\\n extend Ac...\n", " 0.000000\n", - " 0.003506\n", + " 0.005049\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.001403\n", - " 0.001403\n", - " 0.009818\n", + " 0.000281\n", + " 0.003086\n", " ...\n", " 0.000000\n", + " 0.000281\n", + " 0.000561\n", + " 0.000281\n", + " 0.000281\n", + " 0.001964\n", " 0.000000\n", - " 0.001403\n", - " 0.000000\n", - " 0.000701\n", - " 0.011921\n", - " 0.001403\n", - " 0.000000\n", - " 1.000701\n", + " 0.000561\n", + " 1.000281\n", " 0.000000\n", " \n", " \n", - " 12 \n", + " 13\n", + " 14\n", " ruby\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", + " require 'formula'\\n\\nclass A52dec < Formula\\n ...\n", " 0.000000\n", - " 0.004751\n", + " 0.006110\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.001584\n", - " 0.011085\n", + " 0.002037\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001584\n", " 0.000000\n", - " 0.000792\n", - " 0.011876\n", + " 0.002037\n", + " 0.002037\n", + " 0.010183\n", " 0.000000\n", " 0.000000\n", - " 1.000792\n", + " 1.002037\n", " 0.000000\n", " \n", " \n", - " 13 \n", + " 14\n", + " 15\n", " ruby\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", + " module Fluent\\n class Input\\n include Conf...\n", " 0.000000\n", - " 0.006533\n", + " 0.014286\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.002395\n", - " 0.005444\n", + " 0.008163\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000436\n", " 0.000000\n", - " 0.000218\n", - " 0.011324\n", + " 0.002041\n", + " 0.002041\n", " 0.000000\n", - " 0.003049\n", - " 1.000218\n", + " 0.000000\n", + " 0.000000\n", + " 1.002041\n", " 0.000000\n", " \n", " \n", - " 14 \n", - " ocaml\n", - " (* The Computer Language Benchmarks Game\\n * h...\n", - " 0.012293\n", - " 0.000000\n", + " 15\n", + " 16\n", + " haskell\n", + " {-# LANGUAGE ScopedTypeVariables, FlexibleInst...\n", + " 0.000131\n", + " 0.000196\n", " 0.000000\n", - " 0.001229\n", - " 0.001229\n", " 0.000000\n", " 0.000000\n", - " 0.006146\n", + " 0.000523\n", + " 0.000261\n", " ...\n", + " 0.000849\n", " 0.000000\n", + " 0.000915\n", + " 0.000065\n", + " 0.000065\n", + " 0.013264\n", + " 0.000261\n", " 0.000000\n", - " 0.001229\n", - " 0.001844\n", - " 0.000615\n", - " 0.002459\n", - " 0.004302\n", - " 0.000000\n", - " 1.000615\n", + " 1.000065\n", " 0.000000\n", " \n", " \n", - " 15 \n", - " ocaml\n", - " (* The Computer Language Benchmarks Game\\n * h...\n", - " 0.009773\n", + " 16\n", + " 17\n", + " haskell\n", + " reverseDependencies :: ModuleGraph -> M.Map Mo...\n", + " 0.000000\n", + " 0.006452\n", + " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.000888\n", - " 0.002665\n", " 0.000000\n", " 0.000000\n", - " 0.004442\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.000888\n", - " 0.001333\n", - " 0.000444\n", - " 0.004887\n", - " 0.006219\n", + " 0.006452\n", + " 0.003226\n", + " 0.003226\n", + " 0.012903\n", + " 0.000000\n", + " 0.009677\n", + " 1.003226\n", " 0.000000\n", - " 1.000444\n", - " 0.000888\n", " \n", " \n", - " 16 \n", - " ocaml\n", - " (* The Computer Language Benchmarks Game\\n * h...\n", - " 0.010925\n", - " 0.000000\n", + " 17\n", + " 18\n", + " haskell\n", + " {- git-annex extra config files\\n -\\n - Copyri...\n", + " 0.000491\n", " 0.000000\n", - " 0.000728\n", - " 0.000728\n", " 0.000000\n", " 0.000000\n", - " 0.007283\n", + " 0.000982\n", + " 0.001473\n", + " 0.000491\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001457\n", - " 0.002185\n", - " 0.000728\n", - " 0.004370\n", - " 0.005098\n", + " 0.003929\n", + " 0.000491\n", + " 0.000491\n", + " 0.001965\n", + " 0.000491\n", + " 0.000000\n", + " 1.000491\n", " 0.000000\n", - " 1.000728\n", - " 0.001457\n", " \n", " \n", - " 17 \n", - " perl\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", + " 18\n", + " 19\n", + " scheme\n", + " (define subst-f\\n (lambda (new old l)\\n (c...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.002591\n", + " 0.002591\n", " 0.000000\n", - " 0.000746\n", - " 0.000746\n", - " 0.010440\n", + " 0.007772\n", " ...\n", " 0.000000\n", + " 0.007772\n", " 0.000000\n", - " 0.001491\n", + " 0.002591\n", + " 0.002591\n", " 0.000000\n", - " 0.000746\n", - " 0.013423\n", - " 0.013423\n", + " 0.010363\n", " 0.000000\n", - " 1.000746\n", + " 1.002591\n", " 0.000000\n", " \n", " \n", - " 18 \n", - " perl\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", + " 19\n", + " 20\n", + " scheme\n", + " (define add1\\n (lambda (n) (+ n 1)))\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.001906\n", - " 0.000476\n", - " 0.007623\n", + " 0.000000\n", + " 0.027778\n", " ...\n", " 0.000000\n", - " 0.000953\n", - " 0.000953\n", + " 0.027778\n", + " 0.000000\n", + " 0.027778\n", + " 0.027778\n", " 0.000000\n", - " 0.000476\n", - " 0.014293\n", - " 0.015722\n", " 0.000000\n", - " 1.000476\n", + " 0.000000\n", + " 1.027778\n", " 0.000000\n", " \n", " \n", - " 19 \n", - " php\n", - " <?php \\n/* The Computer Language Benchmarks Ga...\n", + " 20\n", + " 21\n", + " scheme\n", + " (define-lib-primitive (length lst)\\n (if (nul...\n", + " 0.001341\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.001267\n", - " 0.001267\n", - " 0.001901\n", " 0.000000\n", - " 0.004436\n", + " 0.000000\n", + " 0.007449\n", " ...\n", " 0.000000\n", + " 0.007449\n", " 0.000000\n", - " 0.001267\n", - " 0.001901\n", - " 0.000634\n", - " 0.009506\n", - " 0.022180\n", + " 0.000149\n", + " 0.000149\n", + " 0.000000\n", + " 0.000298\n", " 0.000000\n", - " 1.000634\n", - " 0.000634\n", + " 1.000149\n", + " 0.002086\n", " \n", " \n", - " 20 \n", - " php\n", - " <?php \\n/* The Computer Language Benchmarks Ga...\n", + " 21\n", + " 22\n", + " java\n", + " /**\\n * Interface to represent a persistence s...\n", + " 0.001424\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.001387\n", - " 0.001387\n", - " 0.000693\n", " 0.000000\n", - " 0.009015\n", + " 0.001898\n", + " 0.000949\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001387\n", - " 0.002080\n", - " 0.000693\n", - " 0.009709\n", - " 0.017337\n", " 0.000000\n", - " 1.000693\n", + " 0.000475\n", + " 0.000475\n", + " 0.000949\n", + " 0.003322\n", + " 0.000000\n", + " 1.000475\n", " 0.000000\n", " \n", " \n", - " 21 \n", - " php\n", - " <?php \\n/* The Computer Language Benchmarks Ga...\n", + " 22\n", + " 23\n", + " java\n", + " /*\\n * Copyright 2002-2008 the original author...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.001355\n", - " 0.001355\n", - " 0.002033\n", " 0.000000\n", - " 0.004743\n", + " 0.000000\n", + " 0.001095\n", + " 0.001095\n", " ...\n", " 0.000000\n", + " 0.001095\n", " 0.000000\n", - " 0.001355\n", - " 0.002033\n", - " 0.000678\n", - " 0.012873\n", - " 0.018970\n", + " 0.000548\n", + " 0.000548\n", + " 0.004381\n", + " 0.003286\n", + " 0.000000\n", + " 1.000548\n", " 0.000000\n", - " 1.000678\n", - " 0.000678\n", " \n", " \n", - " 22 \n", - " php\n", - " <?php \\n/* The Computer Language Benchmarks Ga...\n", - " 0.000000\n", - " 0.000258\n", - " 0.000000\n", - " 0.000515\n", - " 0.000515\n", - " 0.001289\n", + " 23\n", + " 24\n", + " scala\n", + " package com.github.pathikrit\\n\\nimport scala.a...\n", " 0.000000\n", - " 0.003866\n", - " ...\n", + " 0.003219\n", " 0.000000\n", " 0.000000\n", - " 0.000515\n", - " 0.000773\n", - " 0.000258\n", - " 0.015206\n", - " 0.027320\n", - " 0.001289\n", - " 1.000258\n", - " 0.001031\n", - " \n", - " \n", - " 23 \n", - " python\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", " 0.000000\n", - " 0.000557\n", " 0.000000\n", - " 0.000557\n", - " 0.000557\n", - " 0.002784\n", - " 0.002784\n", - " 0.007238\n", + " 0.001788\n", " ...\n", " 0.000000\n", " 0.000000\n", - " 0.001114\n", - " 0.000000\n", - " 0.000557\n", - " 0.017261\n", + " 0.001073\n", + " 0.000358\n", + " 0.000358\n", + " 0.005007\n", " 0.000000\n", " 0.000000\n", - " 1.000557\n", + " 1.000358\n", " 0.000000\n", " \n", " \n", - " 24 \n", - " scheme\n", - " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 0.002914\n", + " 24\n", + " 25\n", + " scala\n", + " /* sbt -- Simple Build Tool\\n * Copyright 2010...\n", " 0.000000\n", + " 0.001565\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", - " 0.004079\n", - " 0.005828\n", + " 0.004173\n", " ...\n", - " 0.004079\n", " 0.000000\n", - " 0.001166\n", - " 0.001748\n", - " 0.000583\n", " 0.000000\n", - " 0.008159\n", " 0.000000\n", - " 1.000583\n", + " 0.000522\n", + " 0.000522\n", + " 0.001043\n", " 0.000000\n", - " \n", - " \n", - " 25 \n", - " scheme\n", - " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 0.003380\n", " 0.000000\n", + " 1.000522\n", " 0.000000\n", + " \n", + " \n", + " 25\n", + " 28\n", + " php\n", + " class View\\n{\\n /**\\n * Data available ...\n", " 0.000000\n", + " 0.001805\n", " 0.000000\n", + " 0.002557\n", + " 0.002708\n", + " 0.002407\n", " 0.000000\n", - " 0.005311\n", - " 0.003863\n", " ...\n", - " 0.005311\n", " 0.000000\n", - " 0.000966\n", - " 0.001449\n", - " 0.000483\n", - " 0.000000\n", - " 0.005794\n", - " 0.000000\n", - " 1.000483\n", " 0.000000\n", + " 0.000301\n", + " 0.000150\n", + " 0.000150\n", + " 0.002858\n", + " 0.004964\n", + " 0.000602\n", + " 1.000150\n", + " 0.000903\n", " \n", " \n", - " 26 \n", - " scheme\n", - " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 0.001107\n", - " 0.000000\n", + " 26\n", + " 29\n", + " php\n", + " public function formatLocalized($format)\\n...\n", " 0.000000\n", " 0.000000\n", " 0.000000\n", + " 0.002950\n", + " 0.002950\n", + " 0.002950\n", " 0.000000\n", - " 0.009222\n", - " 0.002951\n", " ...\n", - " 0.009222\n", + " 0.014749\n", " 0.000000\n", - " 0.000738\n", - " 0.001107\n", - " 0.000369\n", " 0.000000\n", - " 0.004426\n", + " 0.002950\n", + " 0.002950\n", + " 0.014749\n", + " 0.005900\n", " 0.000000\n", - " 1.000369\n", - " 0.000369\n", - " \n", - " \n", - " 27 \n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000000\n", - " 0.001931\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.004505\n", - " 0.001931\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001287\n", - " 0.000000\n", - " 0.000644\n", - " 0.018018\n", - " 0.000000\n", - " 0.000000\n", - " 1.000644\n", - " 0.000000\n", - " \n", - " \n", - " 28 \n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000000\n", - " 0.000608\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.003647\n", - " 0.003040\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001216\n", - " 0.000000\n", - " 0.000608\n", - " 0.015805\n", - " 0.000608\n", - " 0.000000\n", - " 1.000608\n", - " 0.000000\n", - " \n", - " \n", - " 29 \n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.003053\n", - " 0.002290\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001527\n", - " 0.000000\n", - " 0.000763\n", - " 0.016794\n", - " 0.000000\n", - " 0.000000\n", - " 1.000763\n", - " 0.000000\n", - " \n", - " \n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " \n", - " \n", - " 356\n", - " python\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.004155\n", - " 0.004848\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001385\n", - " 0.000000\n", - " 0.000693\n", - " 0.009003\n", - " 0.000000\n", - " 0.000000\n", - " 1.000693\n", - " 0.000000\n", - " \n", - " \n", - " 357\n", - " python\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.003165\n", - " 0.003956\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001582\n", - " 0.000000\n", - " 0.000791\n", - " 0.005538\n", - " 0.000000\n", - " 0.000000\n", - " 1.000791\n", - " 0.000000\n", - " \n", - " \n", - " 358\n", - " python\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000600\n", - " 0.003001\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001200\n", - " 0.000000\n", - " 0.000600\n", - " 0.011405\n", - " 0.000000\n", - " 0.000000\n", - " 1.000600\n", - " 0.000000\n", - " \n", - " \n", - " 359\n", - " scheme\n", - " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 0.002172\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000543\n", - " 0.002714\n", - " 0.000000\n", - " ...\n", - " 0.002714\n", - " 0.000000\n", - " 0.001086\n", - " 0.000543\n", - " 0.000543\n", - " 0.000543\n", - " 0.014115\n", - " 0.000000\n", - " 1.000543\n", - " 0.001086\n", - " \n", - " \n", - " 360\n", - " scheme\n", - " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 0.001901\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000475\n", - " 0.002376\n", - " 0.000000\n", - " ...\n", - " 0.002376\n", - " 0.000000\n", - " 0.000951\n", - " 0.000475\n", - " 0.000475\n", - " 0.000475\n", - " 0.013308\n", - " 0.000000\n", - " 1.000475\n", - " 0.000951\n", - " \n", - " \n", - " 361\n", - " scheme\n", - " #lang racket/base\\n;; The Computer Language Be...\n", - " 0.003863\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.005311\n", - " 0.000000\n", - " ...\n", - " 0.005311\n", - " 0.000000\n", - " 0.000966\n", - " 0.000000\n", - " 0.000483\n", - " 0.000000\n", - " 0.004829\n", - " 0.000000\n", - " 1.000483\n", - " 0.000966\n", - " \n", - " \n", - " 362\n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.002508\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001672\n", - " 0.000836\n", - " 0.000836\n", - " 0.015050\n", - " 0.000836\n", - " 0.000836\n", - " 1.000836\n", - " 0.000000\n", - " \n", - " \n", - " 363\n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000000\n", - " 0.002877\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.002877\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000822\n", - " 0.000000\n", - " 0.000411\n", - " 0.009453\n", - " 0.000000\n", - " 0.000000\n", - " 1.000411\n", - " 0.000000\n", - " \n", - " \n", - " 364\n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000248\n", - " 0.000248\n", - " 0.000000\n", - " 0.000248\n", - " 0.000248\n", - " 0.000248\n", - " 0.002475\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000495\n", - " 0.000495\n", - " 0.000000\n", - " 0.000248\n", - " 0.009406\n", - " 0.000000\n", - " 0.000000\n", - " 1.000248\n", - " 0.000000\n", - " \n", - " \n", - " 365\n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000458\n", - " 0.000229\n", - " 0.000000\n", - " 0.000229\n", - " 0.000229\n", - " 0.000229\n", - " 0.002521\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000687\n", - " 0.000458\n", - " 0.000000\n", - " 0.000229\n", - " 0.008249\n", - " 0.000000\n", - " 0.000000\n", - " 1.000229\n", - " 0.000000\n", - " \n", - " \n", - " 366\n", - " clojure\n", - " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 0.001794\n", - " 0.002691\n", - " 0.002691\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.002691\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001794\n", - " 0.000000\n", - " 0.000897\n", - " 0.000897\n", - " 0.008969\n", - " 0.000897\n", - " 1.000897\n", - " 0.000897\n", - " \n", - " \n", - " 367\n", - " clojure\n", - " ;; The Computer Language Benchmarks Game\\n;; h...\n", - " 0.000000\n", - " 0.004206\n", - " 0.003155\n", - " 0.001052\n", - " 0.001052\n", - " 0.001052\n", - " 0.004206\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002103\n", - " 0.000000\n", - " 0.001052\n", - " 0.000000\n", - " 0.011567\n", - " 0.001052\n", - " 1.001052\n", - " 0.000000\n", - " \n", - " \n", - " 368\n", - " haskell\n", - " -- The Computer Language Benchmarks Game\\n-- h...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.001149\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.001149\n", - " 0.002299\n", - " 0.000000\n", - " 0.001149\n", - " 0.001149\n", - " 0.000000\n", - " 0.000000\n", - " 1.001149\n", - " 0.001149\n", - " \n", - " \n", - " 369\n", - " java\n", - " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 0.000000\n", - " 0.000897\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000897\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000897\n", - " 0.000000\n", - " 0.000449\n", - " 0.000897\n", - " 0.018394\n", - " 0.000000\n", - " 1.000449\n", - " 0.000449\n", - " \n", - " \n", - " 370\n", - " java\n", - " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 0.000000\n", - " 0.000600\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000600\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001200\n", - " 0.000000\n", - " 0.000600\n", - " 0.001801\n", - " 0.017407\n", - " 0.000000\n", - " 1.000600\n", - " 0.000600\n", - " \n", - " \n", - " 371\n", - " java\n", - " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 0.000000\n", - " 0.001525\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000508\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000508\n", - " 0.000000\n", - " 0.000254\n", - " 0.002542\n", - " 0.014743\n", - " 0.000000\n", - " 1.000254\n", - " 0.000000\n", - " \n", - " \n", - " 372\n", - " java\n", - " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001504\n", - " 0.000000\n", - " 0.000752\n", - " 0.000000\n", - " 0.015038\n", - " 0.000000\n", - " 1.000752\n", - " 0.000752\n", - " \n", - " \n", - " 373\n", - " java\n", - " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 0.000000\n", - " 0.001183\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000789\n", - " 0.000000\n", - " 0.000394\n", - " 0.001577\n", - " 0.011435\n", - " 0.000000\n", - " 1.000394\n", - " 0.000000\n", - " \n", - " \n", - " 374\n", - " java\n", - " /**\\n * The Computer Language Benchmarks Game\\...\n", - " 0.000000\n", - " 0.000626\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.001252\n", - " 0.000000\n", - " 0.000626\n", - " 0.000000\n", - " 0.019399\n", - " 0.000000\n", - " 1.000626\n", - " 0.000000\n", - " \n", - " \n", - " 375\n", - " ruby\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.010881\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.004353\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002176\n", - " 0.000000\n", - " 0.001088\n", - " 0.001088\n", - " 0.000000\n", - " 0.000000\n", - " 1.001088\n", - " 0.000000\n", - " \n", - " \n", - " 376\n", - " ruby\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.010135\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.003378\n", - " 0.000000\n", - " 0.001689\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 1.001689\n", - " 0.000000\n", - " \n", - " \n", - " 377\n", - " ocaml\n", - " (* The Computer Language Benchmarks Game\\n * h...\n", - " 0.011611\n", - " 0.002903\n", - " 0.000000\n", - " 0.000000\n", - " 0.002903\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002903\n", - " 0.000000\n", - " 0.001451\n", - " 0.000000\n", - " 0.005806\n", - " 0.000000\n", - " 1.001451\n", - " 0.000000\n", - " \n", - " \n", - " 378\n", - " ocaml\n", - " (* The Computer Language Benchmarks Game\\n * h...\n", - " 0.010613\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002358\n", - " 0.000000\n", - " 0.001179\n", - " 0.002358\n", - " 0.014151\n", - " 0.000000\n", - " 1.001179\n", - " 0.002358\n", - " \n", - " \n", - " 379\n", - " ocaml\n", - " (* The Computer Language Benchmarks Game\\n * h...\n", - " 0.010914\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.001364\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002729\n", - " 0.000000\n", - " 0.001364\n", - " 0.002729\n", - " 0.012278\n", - " 0.000000\n", - " 1.001364\n", - " 0.000000\n", - " \n", - " \n", - " 380\n", - " perl\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.002128\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.004255\n", - " 0.002128\n", - " 0.000000\n", - " 0.001064\n", - " 0.001064\n", - " 0.029787\n", - " 0.001064\n", - " 1.001064\n", - " 0.000000\n", - " \n", - " \n", - " 381\n", - " perl\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000420\n", - " 0.000840\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000840\n", - " 0.000000\n", - " ...\n", - " 0.000420\n", - " 0.001260\n", - " 0.000840\n", - " 0.000000\n", - " 0.000420\n", - " 0.004200\n", - " 0.012180\n", - " 0.000840\n", - " 1.000420\n", - " 0.000000\n", - " \n", - " \n", - " 382\n", - " python\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.002090\n", - " 0.000000\n", - " 0.001045\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002090\n", - " 0.000000\n", - " 0.001045\n", - " 0.006270\n", - " 0.000000\n", - " 0.000000\n", - " 1.001045\n", - " 0.000000\n", - " \n", - " \n", - " 383\n", - " python\n", - " # The Computer Language Benchmarks Game\\n# htt...\n", - " 0.000000\n", - " 0.006090\n", - " 0.000000\n", - " 0.000000\n", - " 0.001218\n", - " 0.000000\n", - " 0.002436\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002436\n", - " 0.000000\n", - " 0.001218\n", - " 0.003654\n", - " 0.000000\n", - " 0.000000\n", - " 1.001218\n", - " 0.000000\n", - " \n", - " \n", - " 384\n", - " scheme\n", - " #lang racket/base\\n\\n;;; The Computer Language...\n", - " 0.003911\n", - " 0.002608\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.001304\n", - " 0.000000\n", - " ...\n", - " 0.001304\n", - " 0.000000\n", - " 0.002608\n", - " 0.001304\n", - " 0.001304\n", - " 0.000000\n", - " 0.027379\n", - " 0.000000\n", - " 1.001304\n", - " 0.000000\n", - " \n", - " \n", - " 385\n", - " scala\n", - " /* The Computer Language Benchmarks Game\\n h...\n", - " 0.000000\n", - " 0.001414\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.000000\n", - " 0.002829\n", - " 0.000000\n", - " ...\n", - " 0.000000\n", - " 0.000000\n", - " 0.002829\n", - " 0.000000\n", - " 0.001414\n", - " 0.000000\n", - " 0.001414\n", - " 0.000000\n", - " 1.001414\n", - " 0.002829\n", - " \n", - " \n", - "\n", - "

386 rows \u00d7 23 columns

\n", - "" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 199, - "text": [ - " Language Code let \\\n", - "0 clojure ;; The Computer Language Benchmarks Game\\n;; h... 0.002066 \n", - "1 clojure ;; The Computer Language Benchmarks Game\\n;; h... 0.002699 \n", - "2 clojure ;; The Computer Language Benchmarks Game\\n;; h... 0.002695 \n", - "3 haskell --\\n-- The Computer Language Benchmarks Game\\n... 0.002471 \n", - "4 haskell --\\n-- The Computer Language Benchmarks Game\\n... 0.002647 \n", - "5 haskell --\\n-- The Computer Language Benchmarks Game\\n... 0.002865 \n", - "6 java /* The Computer Language Benchmarks Game\\n h... 0.000000 \n", - "7 java /* The Computer Language Benchmarks Game\\n h... 0.000000 \n", - "8 java /* The Computer Language Benchmarks Game\\n * h... 0.000000 \n", - "9 javascript /* The Computer Language Benchmarks Game\\n h... 0.000000 \n", - "10 ruby # The Computer Language Shootout Benchmarks\\n#... 0.000000 \n", - "11 ruby # The Computer Language Benchmarks Game\\n# htt... 0.000000 \n", - "12 ruby # The Computer Language Benchmarks Game\\n# htt... 0.000000 \n", - "13 ruby # The Computer Language Benchmarks Game\\n# htt... 0.000000 \n", - "14 ocaml (* The Computer Language Benchmarks Game\\n * h... 0.012293 \n", - "15 ocaml (* The Computer Language Benchmarks Game\\n * h... 0.009773 \n", - "16 ocaml (* The Computer Language Benchmarks Game\\n * h... 0.010925 \n", - "17 perl # The Computer Language Benchmarks Game\\n# htt... 0.000000 \n", - "18 perl # The Computer Language Benchmarks Game\\n# htt... 0.000000 \n", - "19 php item = $item;\n", - " if (!$depth) return $node;\n", - " $item2 = $item + $item;\n", - " $depth--;\n", - " $node->l = bottomUpTree($item2-1,$depth);\n", - " $node->r = bottomUpTree($item2,$depth);\n", - " return $node;\n", - "}\n", - "\n", - "function itemCheck($treeNode) { \n", - " return $treeNode->item\n", - " + ($treeNode->l->l === null ? itemCheck($treeNode->l) : $treeNode->l->item)\n", - " - ($treeNode->r->l === null ? itemCheck($treeNode->r) : $treeNode->r->item);\n", - "}\n", - "\n", - "$minDepth = 4;\n", - "\n", - "$n = ($argc == 2) ? $argv[1] : 1;\n", - "$maxDepth = max($minDepth + 2, $n);\n", - "$stretchDepth = $maxDepth + 1;\n", - "\n", - "$stretchTree = bottomUpTree(0, $stretchDepth);\n", - "printf(\"stretch tree of depth %d\\t check: %d\\n\", $stretchDepth, itemCheck($stretchTree));\n", - "unset($stretchTree);\n", - "\n", - "$longLivedTree = bottomUpTree(0, $maxDepth);\n", - "\n", - "$iterations = 1 << ($maxDepth);\n", - "do\n", - "{\n", - " $check = 0;\n", - " for($i = 1; $i <= $iterations; ++$i)\n", - " {\n", - " $t = bottomUpTree($i, $minDepth);\n", - " $check += itemCheck($t);\n", - " unset($t);\n", - " $t = bottomUpTree(-$i, $minDepth);\n", - " $check += itemCheck($t);\n", - " unset($t);\n", - " }\n", - " \n", - " printf(\"%d\\t trees of depth %d\\t check: %d\\n\", $iterations<<1, $minDepth, $check);\n", - " \n", - " $minDepth += 2;\n", - " $iterations >>= 2;\n", - "}\n", - "while($minDepth <= $maxDepth);\n", - "\n", - "printf(\"long lived tree of depth %d\\t check: %d\\n\",\n", - "$maxDepth, itemCheck($longLivedTree));\n", - "\n", - "\n" - ] - } - ], - "prompt_number": 184 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def tcode_sucker():\n", - " codelist = []\n", - " for subdir, dirs, files in os.walk(\"test/\"):\n", - " for fname in files:\n", - " with open(os.path.join(subdir, fname)) as current_file:\n", - " codelist.append(current_file.read()) \n", - " return codelist" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 39 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def tdata_frame_generator():\n", - " test_codelist = tcode_sucker()\n", - " df = pd.read_csv(\"test.csv\")\n", - " df[\"Code\"] = test_codelist\n", - " for string in word_list:\n", - " def sub_function(code):\n", - " x = string_ratio(string, code)\n", - " return x\n", - " df[string] = df.Code.apply(sub_function)\n", - " return df" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 200 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df = tdata_frame_generator()" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 203 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
FilenameLanguageCodeletenddefnfunctionfunreturndef...define::$printf^,;&|!
0 1 clojure (defn cf-settings\\n \"Setup settings for campf... 0.001759 0.000880 0.003518 0.000000 0.000000 0.000000 0.003518... 0.000000 0.000000 0.000880 0 0.000880 0.009675 0.000000 0.000000 1.000880 0.000000
1 2 clojure var _ = require('lodash'),\\n fs = require('... 0.000000 0.000000 0.000000 0.005731 0.005731 0.008596 0.002865... 0.000000 0.000000 0.005731 0 0.002865 0.011461 0.011461 0.000000 1.002865 0.000000
2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... 0.000058 0.000864 0.000000 0.004377 0.004435 0.002649 0.000864... 0.000576 0.000000 0.000058 0 0.000058 0.012844 0.000691 0.002361 1.000058 0.001498
3 4 clojure var r = riot.route = function(arg) {\\n //... 0.000000 0.000000 0.000000 0.011765 0.011765 0.000000 0.000000... 0.000000 0.000000 0.005882 0 0.005882 0.005882 0.000000 0.000000 1.005882 0.000000
4 5 python module ActiveJob\\n module Core\\n extend Ac... 0.000000 0.005049 0.000000 0.000000 0.000000 0.000281 0.003086... 0.000281 0.000561 0.000281 0 0.000281 0.001964 0.000000 0.000561 1.000281 0.000000
5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... 0.000000 0.006110 0.000000 0.000000 0.000000 0.000000 0.002037... 0.000000 0.000000 0.002037 0 0.002037 0.010183 0.000000 0.000000 1.002037 0.000000
6 7 python module Fluent\\n class Input\\n include Conf... 0.000000 0.014286 0.000000 0.000000 0.000000 0.000000 0.008163... 0.000000 0.000000 0.002041 0 0.002041 0.000000 0.000000 0.000000 1.002041 0.000000
7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... 0.000131 0.000196 0.000000 0.000000 0.000000 0.000523 0.000261... 0.000000 0.000915 0.000065 0 0.000065 0.013264 0.000261 0.000000 1.000065 0.000000
8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... 0.000000 0.006452 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.006452 0.003226 0 0.003226 0.012903 0.000000 0.009677 1.003226 0.000000
9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... 0.000491 0.000000 0.000000 0.000000 0.000982 0.001473 0.000491... 0.000000 0.003929 0.000491 0 0.000491 0.001965 0.000491 0.000000 1.000491 0.000000
10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... 0.000000 0.000000 0.000000 0.002591 0.002591 0.000000 0.007772... 0.007772 0.000000 0.002591 0 0.002591 0.000000 0.010363 0.000000 1.002591 0.000000
11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... 0.000000 0.000000 0.009852 0.000000 0.000000 0.000000 0.009852... 0.000000 0.000000 0.004926 0 0.004926 0.000000 0.000000 0.009852 1.004926 0.000000
12 13 ruby (define add1\\n (lambda (n) (+ n 1))) 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.027778... 0.027778 0.000000 0.027778 0 0.027778 0.000000 0.000000 0.000000 1.027778 0.000000
13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... 0.001341 0.000000 0.000000 0.000000 0.000000 0.000000 0.007449... 0.007449 0.000000 0.000149 0 0.000149 0.000000 0.000298 0.000000 1.000149 0.002086
14 15 ruby /**\\n * Interface to represent a persistence s... 0.001424 0.000000 0.000000 0.000000 0.000000 0.001898 0.000949... 0.000000 0.000000 0.000475 0 0.000475 0.000949 0.003322 0.000000 1.000475 0.000000
15 16 haskell /*\\n * Copyright 2002-2008 the original author... 0.000000 0.000000 0.000000 0.000000 0.000000 0.001095 0.001095... 0.001095 0.000000 0.000548 0 0.000548 0.004381 0.003286 0.000000 1.000548 0.000000
16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... 0.000000 0.003219 0.000000 0.000000 0.000000 0.000000 0.001788... 0.000000 0.001073 0.000358 0 0.000358 0.005007 0.000000 0.000000 1.000358 0.000000
17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... 0.000000 0.001565 0.000000 0.000000 0.000000 0.000000 0.004173... 0.000000 0.000000 0.000522 0 0.000522 0.001043 0.000000 0.000000 1.000522 0.000000
18 19 scheme class View\\n{\\n /**\\n * Data available ... 0.000000 0.001805 0.000000 0.002557 0.002708 0.002407 0.000000... 0.000000 0.000301 0.000150 0 0.000150 0.002858 0.004964 0.000602 1.000150 0.000903
19 20 scheme public function formatLocalized($format)\\n... 0.000000 0.000000 0.000000 0.002950 0.002950 0.002950 0.000000... 0.000000 0.000000 0.002950 0 0.002950 0.014749 0.005900 0.000000 1.002950 0.002950
20 21 scheme (extend-type String\\n Person\\n (first-name [... 0.000000 0.006993 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.006993 0 0.006993 0.000000 0.000000 0.000000 1.006993 0.000000
21 22 java class Application extends App {\\n\\t/**\\n\\t * @... 0.000000 0.000512 0.000000 0.005629 0.005629 0.005118 0.000000... 0.000000 0.001535 0.000512 0 0.000512 0.011771 0.011259 0.000000 1.000512 0.000000
22 23 java type name = string\\n\\nlet compare_label label1... 0.005422 0.001322 0.000000 0.000661 0.002248 0.000926 0.000397... 0.000000 0.000132 0.000132 0 0.000132 0.006612 0.000397 0.000000 1.000132 0.000264
23 24 scala let search_compiler_libs () =\\n prerr_endline... 0.005217 0.003478 0.000000 0.000000 0.001739 0.000000 0.000000... 0.000000 0.000000 0.001739 0 0.001739 0.000000 0.012174 0.000000 1.001739 0.001739
24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... 0.001675 0.000000 0.001675 0.000000 0.000000 0.000000 0.003350... 0.000000 0.000000 0.001675 0 0.001675 0.006700 0.006700 0.000000 1.001675 0.001675
25 28 php from pkgutil import iter_modules\\nfrom subproc... 0.000000 0.004983 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001661 0 0.001661 0.014950 0.000000 0.000000 1.001661 0.000000
26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... 0.000000 0.001403 0.000000 0.000000 0.000000 0.001403 0.001403... 0.000000 0.000000 0.000351 0 0.000351 0.003857 0.000000 0.000000 1.000351 0.000000
27 30 php class NoSuchService(Exception):\\n def __ini... 0.000000 0.000000 0.000000 0.000000 0.000000 0.006135 0.012270... 0.000000 0.000000 0.003067 0 0.003067 0.006135 0.000000 0.000000 1.003067 0.000000
28 31 ocaml from collections import namedtuple\\nimport fun... 0.000000 0.003158 0.000000 0.000000 0.000148 0.000691 0.003059... 0.000000 0.000000 0.000049 0 0.000049 0.014952 0.000247 0.000000 1.000049 0.000247
29 32 ocaml function errorHandler(context) {\\n return fun... 0.000000 0.000000 0.000000 0.008982 0.008982 0.001497 0.000000... 0.000000 0.000000 0.000749 0 0.000749 0.005240 0.014222 0.000000 1.000749 0.000000
\n", - "

30 rows \u00d7 24 columns

\n", - "
" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 204, - "text": [ - " Filename Language Code \\\n", - "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", - "1 2 clojure var _ = require('lodash'),\\n fs = require('... \n", - "2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", - "3 4 clojure var r = riot.route = function(arg) {\\n //... \n", - "4 5 python module ActiveJob\\n module Core\\n extend Ac... \n", - "5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", - "6 7 python module Fluent\\n class Input\\n include Conf... \n", - "7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", - "8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... \n", - "9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... \n", - "10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... \n", - "11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", - "12 13 ruby (define add1\\n (lambda (n) (+ n 1))) \n", - "13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... \n", - "14 15 ruby /**\\n * Interface to represent a persistence s... \n", - "15 16 haskell /*\\n * Copyright 2002-2008 the original author... \n", - "16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... \n", - "17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", - "18 19 scheme class View\\n{\\n /**\\n * Data available ... \n", - "19 20 scheme public function formatLocalized($format)\\n... \n", - "20 21 scheme (extend-type String\\n Person\\n (first-name [... \n", - "21 22 java class Application extends App {\\n\\t/**\\n\\t * @... \n", - "22 23 java type name = string\\n\\nlet compare_label label1... \n", - "23 24 scala let search_compiler_libs () =\\n prerr_endline... \n", - "24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... \n", - "25 28 php from pkgutil import iter_modules\\nfrom subproc... \n", - "26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", - "27 30 php class NoSuchService(Exception):\\n def __ini... \n", - "28 31 ocaml from collections import namedtuple\\nimport fun... \n", - "29 32 ocaml function errorHandler(context) {\\n return fun... \n", - "\n", - " let end defn function fun return def \\\n", - "0 0.001759 0.000880 0.003518 0.000000 0.000000 0.000000 0.003518 \n", - "1 0.000000 0.000000 0.000000 0.005731 0.005731 0.008596 0.002865 \n", - "2 0.000058 0.000864 0.000000 0.004377 0.004435 0.002649 0.000864 \n", - "3 0.000000 0.000000 0.000000 0.011765 0.011765 0.000000 0.000000 \n", - "4 0.000000 0.005049 0.000000 0.000000 0.000000 0.000281 0.003086 \n", - "5 0.000000 0.006110 0.000000 0.000000 0.000000 0.000000 0.002037 \n", - "6 0.000000 0.014286 0.000000 0.000000 0.000000 0.000000 0.008163 \n", - "7 0.000131 0.000196 0.000000 0.000000 0.000000 0.000523 0.000261 \n", - "8 0.000000 0.006452 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "9 0.000491 0.000000 0.000000 0.000000 0.000982 0.001473 0.000491 \n", - "10 0.000000 0.000000 0.000000 0.002591 0.002591 0.000000 0.007772 \n", - "11 0.000000 0.000000 0.009852 0.000000 0.000000 0.000000 0.009852 \n", - "12 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.027778 \n", - "13 0.001341 0.000000 0.000000 0.000000 0.000000 0.000000 0.007449 \n", - "14 0.001424 0.000000 0.000000 0.000000 0.000000 0.001898 0.000949 \n", - "15 0.000000 0.000000 0.000000 0.000000 0.000000 0.001095 0.001095 \n", - "16 0.000000 0.003219 0.000000 0.000000 0.000000 0.000000 0.001788 \n", - "17 0.000000 0.001565 0.000000 0.000000 0.000000 0.000000 0.004173 \n", - "18 0.000000 0.001805 0.000000 0.002557 0.002708 0.002407 0.000000 \n", - "19 0.000000 0.000000 0.000000 0.002950 0.002950 0.002950 0.000000 \n", - "20 0.000000 0.006993 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "21 0.000000 0.000512 0.000000 0.005629 0.005629 0.005118 0.000000 \n", - "22 0.005422 0.001322 0.000000 0.000661 0.002248 0.000926 0.000397 \n", - "23 0.005217 0.003478 0.000000 0.000000 0.001739 0.000000 0.000000 \n", - "24 0.001675 0.000000 0.001675 0.000000 0.000000 0.000000 0.003350 \n", - "25 0.000000 0.004983 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "26 0.000000 0.001403 0.000000 0.000000 0.000000 0.001403 0.001403 \n", - "27 0.000000 0.000000 0.000000 0.000000 0.000000 0.006135 0.012270 \n", - "28 0.000000 0.003158 0.000000 0.000000 0.000148 0.000691 0.003059 \n", - "29 0.000000 0.000000 0.000000 0.008982 0.008982 0.001497 0.000000 \n", - "\n", - " ... define :: $ printf ^ , \\\n", - "0 ... 0.000000 0.000000 0.000880 0 0.000880 0.009675 \n", - "1 ... 0.000000 0.000000 0.005731 0 0.002865 0.011461 \n", - "2 ... 0.000576 0.000000 0.000058 0 0.000058 0.012844 \n", - "3 ... 0.000000 0.000000 0.005882 0 0.005882 0.005882 \n", - "4 ... 0.000281 0.000561 0.000281 0 0.000281 0.001964 \n", - "5 ... 0.000000 0.000000 0.002037 0 0.002037 0.010183 \n", - "6 ... 0.000000 0.000000 0.002041 0 0.002041 0.000000 \n", - "7 ... 0.000000 0.000915 0.000065 0 0.000065 0.013264 \n", - "8 ... 0.000000 0.006452 0.003226 0 0.003226 0.012903 \n", - "9 ... 0.000000 0.003929 0.000491 0 0.000491 0.001965 \n", - "10 ... 0.007772 0.000000 0.002591 0 0.002591 0.000000 \n", - "11 ... 0.000000 0.000000 0.004926 0 0.004926 0.000000 \n", - "12 ... 0.027778 0.000000 0.027778 0 0.027778 0.000000 \n", - "13 ... 0.007449 0.000000 0.000149 0 0.000149 0.000000 \n", - "14 ... 0.000000 0.000000 0.000475 0 0.000475 0.000949 \n", - "15 ... 0.001095 0.000000 0.000548 0 0.000548 0.004381 \n", - "16 ... 0.000000 0.001073 0.000358 0 0.000358 0.005007 \n", - "17 ... 0.000000 0.000000 0.000522 0 0.000522 0.001043 \n", - "18 ... 0.000000 0.000301 0.000150 0 0.000150 0.002858 \n", - "19 ... 0.000000 0.000000 0.002950 0 0.002950 0.014749 \n", - "20 ... 0.000000 0.000000 0.006993 0 0.006993 0.000000 \n", - "21 ... 0.000000 0.001535 0.000512 0 0.000512 0.011771 \n", - "22 ... 0.000000 0.000132 0.000132 0 0.000132 0.006612 \n", - "23 ... 0.000000 0.000000 0.001739 0 0.001739 0.000000 \n", - "24 ... 0.000000 0.000000 0.001675 0 0.001675 0.006700 \n", - "25 ... 0.000000 0.000000 0.001661 0 0.001661 0.014950 \n", - "26 ... 0.000000 0.000000 0.000351 0 0.000351 0.003857 \n", - "27 ... 0.000000 0.000000 0.003067 0 0.003067 0.006135 \n", - "28 ... 0.000000 0.000000 0.000049 0 0.000049 0.014952 \n", - "29 ... 0.000000 0.000000 0.000749 0 0.000749 0.005240 \n", - "\n", - " ; & | ! \n", - "0 0.000000 0.000000 1.000880 0.000000 \n", - "1 0.011461 0.000000 1.002865 0.000000 \n", - "2 0.000691 0.002361 1.000058 0.001498 \n", - "3 0.000000 0.000000 1.005882 0.000000 \n", - "4 0.000000 0.000561 1.000281 0.000000 \n", - "5 0.000000 0.000000 1.002037 0.000000 \n", - "6 0.000000 0.000000 1.002041 0.000000 \n", - "7 0.000261 0.000000 1.000065 0.000000 \n", - "8 0.000000 0.009677 1.003226 0.000000 \n", - "9 0.000491 0.000000 1.000491 0.000000 \n", - "10 0.010363 0.000000 1.002591 0.000000 \n", - "11 0.000000 0.009852 1.004926 0.000000 \n", - "12 0.000000 0.000000 1.027778 0.000000 \n", - "13 0.000298 0.000000 1.000149 0.002086 \n", - "14 0.003322 0.000000 1.000475 0.000000 \n", - "15 0.003286 0.000000 1.000548 0.000000 \n", - "16 0.000000 0.000000 1.000358 0.000000 \n", - "17 0.000000 0.000000 1.000522 0.000000 \n", - "18 0.004964 0.000602 1.000150 0.000903 \n", - "19 0.005900 0.000000 1.002950 0.002950 \n", - "20 0.000000 0.000000 1.006993 0.000000 \n", - "21 0.011259 0.000000 1.000512 0.000000 \n", - "22 0.000397 0.000000 1.000132 0.000264 \n", - "23 0.012174 0.000000 1.001739 0.001739 \n", - "24 0.006700 0.000000 1.001675 0.001675 \n", - "25 0.000000 0.000000 1.001661 0.000000 \n", - "26 0.000000 0.000000 1.000351 0.000000 \n", - "27 0.000000 0.000000 1.003067 0.000000 \n", - "28 0.000247 0.000000 1.000049 0.000247 \n", - "29 0.014222 0.000000 1.000749 0.000000 \n", - "\n", - "[30 rows x 24 columns]" - ] - } - ], - "prompt_number": 204 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_codelist = tcode_sucker()" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 40 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df = pd.read_csv(\"test.csv\")" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 41 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df[\"Testcode\"] = test_codelist" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 42 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df['code length'] = test_df.Testcode.apply(length_getter)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 59 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df['^'] = df.Code.apply(carat)\n", - "test_df[';'] = df.Code.apply(semicolon)\n", - "test_df[','] = df.Code.apply(comma)\n", - "test_df['&'] = df.Code.apply(carat)\n", - "test_df['!'] = df.Code.apply(semicolon)\n", - "test_df['|'] = df.Code.apply(comma)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 105 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df['let'] = df.Code.apply(let_ratio)\n", - "test_df['end'] = df.Code.apply(end_ratio)\n", - "test_df['fun'] = df.Code.apply(fun_ratio)\n", - "test_df['defn'] = df.Code.apply(defn_ratio)\n", - "test_df['def'] = df.Code.apply(def_ratio)\n", - "test_df['function'] = df.Code.apply(function_ratio)\n", - "test_df['slice'] = df.Code.apply(slice_ratio)\n", - "test_df['return'] = df.Code.apply(return_ratio)\n", - "test_df['define'] = df.Code.apply(define_ratio)\n", - "test_df['doublecolon'] = df.Code.apply(doublecolon_ratio)\n", - "test_df['check'] = df.Code.apply(check_ratio)\n", - "test_df['make'] = df.Code.apply(make_ratio)\n", - "test_df['.format'] = df.Code.apply(format_ratio)\n", - "test_df['->'] = df.Code.apply(arrow_ratio)\n", - "test_df['$'] = df.Code.apply(dollar_ratio)\n", - "test_df['printf'] = df.Code.apply(printf_ratio)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 189 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_df" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
FilenameLanguageTestcodecode length^;,&!|...defndeffunctionslicereturndefinedoublecoloncheckmake.format
0 1 clojure (defn cf-settings\\n \"Setup settings for campf... 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826... 0.002066 0.004545 0.000000 0 0.000000 0.000000 0.000000 0.005372 0.000000 0.001240
1 2 clojure var _ = require('lodash'),\\n fs = require('... 349 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771... 0.001928 0.003470 0.000000 0 0.000000 0.000000 0.000000 0.005012 0.002699 0.001157
2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... 17362 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347... 0.002021 0.003705 0.000000 0 0.000000 0.000000 0.000000 0.009094 0.000000 0.001010
3 4 clojure var r = riot.route = function(arg) {\\n //... 170 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002471 0.006794 0.005559 0.000000
4 5 python module ActiveJob\\n module Core\\n extend Ac... 3565 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002118 0.006882 0.004764 0.000000
5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... 491 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158... 0.000000 0.000000 0.000000 0 0.000000 0.000000 0.002292 0.007450 0.005158 0.000000
6 7 python module Fluent\\n class Input\\n include Conf... 490 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719... 0.000000 0.000000 0.000000 0 0.000737 0.000000 0.000000 0.002947 0.000000 0.000000
7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... 15305 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682... 0.000000 0.000000 0.000000 0 0.001894 0.000000 0.000000 0.004261 0.000000 0.000000
8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... 310 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636... 0.000000 0.000000 0.000000 0 0.001391 0.000000 0.000000 0.006027 0.000000 0.000000
9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... 2036 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234... 0.000000 0.000000 0.002193 0 0.002924 0.000000 0.000000 0.006579 0.000000 0.000000
10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... 386 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236... 0.000000 0.001605 0.000000 0 0.001605 0.000000 0.000000 0.011236 0.000000 0.000000
11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... 203 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921... 0.000000 0.001403 0.000000 0 0.001403 0.000000 0.000000 0.009818 0.000000 0.000000
12 13 ruby (define add1\\n (lambda (n) (+ n 1))) 36 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876... 0.000000 0.001584 0.000000 0 0.000000 0.000000 0.000000 0.011085 0.000000 0.000000
13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... 6712 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324... 0.000000 0.002395 0.000000 0 0.000000 0.000000 0.000000 0.005444 0.000000 0.000000
14 15 ruby /**\\n * Interface to represent a persistence s... 2107 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459... 0.000000 0.000000 0.001229 0 0.000000 0.000000 0.000000 0.006146 0.004302 0.000000
15 16 haskell /*\\n * Copyright 2002-2008 the original author... 1826 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887... 0.000000 0.000000 0.000888 0 0.000000 0.000000 0.000000 0.004442 0.003110 0.000000
16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... 2796 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370... 0.000000 0.000000 0.000728 0 0.000000 0.000000 0.000000 0.007283 0.005098 0.000000
17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... 1917 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423... 0.000000 0.000746 0.000000 0 0.000746 0.000000 0.000000 0.010440 0.000000 0.000000
18 19 scheme class View\\n{\\n /**\\n * Data available ... 6648 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293... 0.000000 0.000476 0.000000 0 0.001906 0.000000 0.000953 0.007623 0.000000 0.000000
19 20 scheme public function formatLocalized($format)\\n... 339 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506... 0.000000 0.000000 0.001267 0 0.001901 0.000000 0.000000 0.004436 0.000000 0.000000
20 21 scheme (extend-type String\\n Person\\n (first-name [... 143 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709... 0.000000 0.000000 0.001387 0 0.000693 0.000000 0.000000 0.009015 0.000000 0.000000
21 22 java class Application extends App {\\n\\t/**\\n\\t * @... 1954 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873... 0.000000 0.000000 0.001355 0 0.002033 0.000000 0.000000 0.004743 0.000000 0.000000
22 23 java type name = string\\n\\nlet compare_label label1... 7562 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206... 0.000000 0.000000 0.000515 0 0.001289 0.000000 0.000000 0.003866 0.000000 0.000000
23 24 scala let search_compiler_libs () =\\n prerr_endline... 575 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261... 0.000000 0.002784 0.000557 0 0.002784 0.000000 0.000000 0.007238 0.005568 0.001670
24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... 597 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000... 0.000000 0.004079 0.000000 0 0.000000 0.004079 0.000000 0.005828 0.004079 0.000000
25 28 php from pkgutil import iter_modules\\nfrom subproc... 602 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000... 0.000000 0.005311 0.000000 0 0.000000 0.005311 0.000000 0.003863 0.005311 0.000000
26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... 2852 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000... 0.000000 0.009222 0.000000 0 0.000000 0.009222 0.000000 0.002951 0.004795 0.000000
27 30 php class NoSuchService(Exception):\\n def __ini... 326 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018... 0.000000 0.004505 0.000000 0 0.000000 0.000000 0.000000 0.001931 0.000000 0.000000
28 31 ocaml from collections import namedtuple\\nimport fun... 20265 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805... 0.000000 0.003647 0.000000 0 0.000000 0.000000 0.000000 0.003040 0.000000 0.000000
29 32 ocaml function errorHandler(context) {\\n return fun... 1336 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794... 0.000000 0.003053 0.000000 0 0.000000 0.000000 0.000000 0.002290 0.000000 0.000000
\n", - "

30 rows \u00d7 23 columns

\n", - "
" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 173, - "text": [ - " Filename Language Testcode \\\n", - "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", - "1 2 clojure var _ = require('lodash'),\\n fs = require('... \n", - "2 3 clojure /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", - "3 4 clojure var r = riot.route = function(arg) {\\n //... \n", - "4 5 python module ActiveJob\\n module Core\\n extend Ac... \n", - "5 6 python require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", - "6 7 python module Fluent\\n class Input\\n include Conf... \n", - "7 8 python {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", - "8 9 javascript reverseDependencies :: ModuleGraph -> M.Map Mo... \n", - "9 10 javascript {- git-annex extra config files\\n -\\n - Copyri... \n", - "10 11 javascript (define subst-f\\n (lambda (new old l)\\n (c... \n", - "11 12 javascript (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", - "12 13 ruby (define add1\\n (lambda (n) (+ n 1))) \n", - "13 14 ruby (define-lib-primitive (length lst)\\n (if (nul... \n", - "14 15 ruby /**\\n * Interface to represent a persistence s... \n", - "15 16 haskell /*\\n * Copyright 2002-2008 the original author... \n", - "16 17 haskell package com.github.pathikrit\\n\\nimport scala.a... \n", - "17 18 haskell /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", - "18 19 scheme class View\\n{\\n /**\\n * Data available ... \n", - "19 20 scheme public function formatLocalized($format)\\n... \n", - "20 21 scheme (extend-type String\\n Person\\n (first-name [... \n", - "21 22 java class Application extends App {\\n\\t/**\\n\\t * @... \n", - "22 23 java type name = string\\n\\nlet compare_label label1... \n", - "23 24 scala let search_compiler_libs () =\\n prerr_endline... \n", - "24 25 scala (require '[overtone.live :as overtone])\\n\\n(de... \n", - "25 28 php from pkgutil import iter_modules\\nfrom subproc... \n", - "26 29 php import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", - "27 30 php class NoSuchService(Exception):\\n def __ini... \n", - "28 31 ocaml from collections import namedtuple\\nimport fun... \n", - "29 32 ocaml function errorHandler(context) {\\n return fun... \n", - "\n", - " code length ^ ; , & ! | \\\n", - "0 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826 \n", - "1 349 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771 \n", - "2 17362 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347 \n", - "3 170 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177 \n", - "4 3565 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294 \n", - "5 491 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158 \n", - "6 490 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719 \n", - "7 15305 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682 \n", - "8 310 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636 \n", - "9 2036 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234 \n", - "10 386 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236 \n", - "11 203 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921 \n", - "12 36 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876 \n", - "13 6712 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324 \n", - "14 2107 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459 \n", - "15 1826 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887 \n", - "16 2796 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370 \n", - "17 1917 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423 \n", - "18 6648 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293 \n", - "19 339 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506 \n", - "20 143 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709 \n", - "21 1954 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873 \n", - "22 7562 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206 \n", - "23 575 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261 \n", - "24 597 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 \n", - "25 602 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000 \n", - "26 2852 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000 \n", - "27 326 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018 \n", - "28 20265 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805 \n", - "29 1336 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794 \n", - "\n", - " ... defn def function slice return define \\\n", - "0 ... 0.002066 0.004545 0.000000 0 0.000000 0.000000 \n", - "1 ... 0.001928 0.003470 0.000000 0 0.000000 0.000000 \n", - "2 ... 0.002021 0.003705 0.000000 0 0.000000 0.000000 \n", - "3 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", - "4 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", - "5 ... 0.000000 0.000000 0.000000 0 0.000000 0.000000 \n", - "6 ... 0.000000 0.000000 0.000000 0 0.000737 0.000000 \n", - "7 ... 0.000000 0.000000 0.000000 0 0.001894 0.000000 \n", - "8 ... 0.000000 0.000000 0.000000 0 0.001391 0.000000 \n", - "9 ... 0.000000 0.000000 0.002193 0 0.002924 0.000000 \n", - "10 ... 0.000000 0.001605 0.000000 0 0.001605 0.000000 \n", - "11 ... 0.000000 0.001403 0.000000 0 0.001403 0.000000 \n", - "12 ... 0.000000 0.001584 0.000000 0 0.000000 0.000000 \n", - "13 ... 0.000000 0.002395 0.000000 0 0.000000 0.000000 \n", - "14 ... 0.000000 0.000000 0.001229 0 0.000000 0.000000 \n", - "15 ... 0.000000 0.000000 0.000888 0 0.000000 0.000000 \n", - "16 ... 0.000000 0.000000 0.000728 0 0.000000 0.000000 \n", - "17 ... 0.000000 0.000746 0.000000 0 0.000746 0.000000 \n", - "18 ... 0.000000 0.000476 0.000000 0 0.001906 0.000000 \n", - "19 ... 0.000000 0.000000 0.001267 0 0.001901 0.000000 \n", - "20 ... 0.000000 0.000000 0.001387 0 0.000693 0.000000 \n", - "21 ... 0.000000 0.000000 0.001355 0 0.002033 0.000000 \n", - "22 ... 0.000000 0.000000 0.000515 0 0.001289 0.000000 \n", - "23 ... 0.000000 0.002784 0.000557 0 0.002784 0.000000 \n", - "24 ... 0.000000 0.004079 0.000000 0 0.000000 0.004079 \n", - "25 ... 0.000000 0.005311 0.000000 0 0.000000 0.005311 \n", - "26 ... 0.000000 0.009222 0.000000 0 0.000000 0.009222 \n", - "27 ... 0.000000 0.004505 0.000000 0 0.000000 0.000000 \n", - "28 ... 0.000000 0.003647 0.000000 0 0.000000 0.000000 \n", - "29 ... 0.000000 0.003053 0.000000 0 0.000000 0.000000 \n", - "\n", - " doublecolon check make .format \n", - "0 0.000000 0.005372 0.000000 0.001240 \n", - "1 0.000000 0.005012 0.002699 0.001157 \n", - "2 0.000000 0.009094 0.000000 0.001010 \n", - "3 0.002471 0.006794 0.005559 0.000000 \n", - "4 0.002118 0.006882 0.004764 0.000000 \n", - "5 0.002292 0.007450 0.005158 0.000000 \n", - "6 0.000000 0.002947 0.000000 0.000000 \n", - "7 0.000000 0.004261 0.000000 0.000000 \n", - "8 0.000000 0.006027 0.000000 0.000000 \n", - "9 0.000000 0.006579 0.000000 0.000000 \n", - "10 0.000000 0.011236 0.000000 0.000000 \n", - "11 0.000000 0.009818 0.000000 0.000000 \n", - "12 0.000000 0.011085 0.000000 0.000000 \n", - "13 0.000000 0.005444 0.000000 0.000000 \n", - "14 0.000000 0.006146 0.004302 0.000000 \n", - "15 0.000000 0.004442 0.003110 0.000000 \n", - "16 0.000000 0.007283 0.005098 0.000000 \n", - "17 0.000000 0.010440 0.000000 0.000000 \n", - "18 0.000953 0.007623 0.000000 0.000000 \n", - "19 0.000000 0.004436 0.000000 0.000000 \n", - "20 0.000000 0.009015 0.000000 0.000000 \n", - "21 0.000000 0.004743 0.000000 0.000000 \n", - "22 0.000000 0.003866 0.000000 0.000000 \n", - "23 0.000000 0.007238 0.005568 0.001670 \n", - "24 0.000000 0.005828 0.004079 0.000000 \n", - "25 0.000000 0.003863 0.005311 0.000000 \n", - "26 0.000000 0.002951 0.004795 0.000000 \n", - "27 0.000000 0.001931 0.000000 0.000000 \n", - "28 0.000000 0.003040 0.000000 0.000000 \n", - "29 0.000000 0.002290 0.000000 0.000000 \n", - "\n", - "[30 rows x 23 columns]" - ] - } - ], - "prompt_number": 173 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from sklearn import metrics" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 44 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def create_xy(df, test_df startx, columny):\n", - " x_train = df.loc[:, startx:]\n", - " x_test = test_df.loc[:, startx:]\n", - " y_train = df[columny]\n", - " y_test = test_df[columny]\n", - " return x_train, x_test, y_train, y_test" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 208 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "x_train = df.loc[:,\"^\":]\n", - "x_test = test_df.loc[:, \"^\":]\n", - "y_train = df.Language\n", - "y_test = test_df.Language" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 190 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "x_train, x_test, y_train, y_test = create_xy('let', 'Language')" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 211 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "x_train" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", " \n", + " \n", + " \n", " \n", - " \n", + " \n", " \n", + " \n", + " \n", " \n", - " \n", + " \n", + "
letenddefnfunctionfunreturndefcheckmake->...define::$printf^,;&|!
0 0.002066 0.000000 0.002066 0.000000 0.000000 0.000000 0.004545 0.005372 0.000000 0.000000... 0.000000 0.000000 0.000826 0.000000 0.000413 0.000826 0.009091 0.000413 1.000413 0.000826
1 0.002699 0.000386 0.001928 0.000000 0.000000 0.000000 0.003470 0.005012 0.002699 0.000000... 0.000000 0.000000 0.000771 0.000000 0.000386 0.000771 0.008096 0.000771 1.000386 0.000771
2 0.002695 0.000000 0.002021 0.000000 0.000000 0.000000 0.003705 0.009094 0.000000 0.000000... 0.000000 0.000000 0.000674 0.000000 0.000337 0.001347 0.010104 0.000337 1.000337 0.000337
3 0.002471 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.006794 0.005559 0.005559... 0.000000 0.002471 0.001235 0.000618 0.000618 0.006177 0.000618 0.000000 1.000618 0.002471
4 0.002647 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.006882 0.004764 0.005823... 0.000000 0.002118 0.001059 0.000529 0.000529 0.005294 0.000529 0.000000 1.000529 0.003176
5 0.002865 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.007450 0.005158 0.006304... 0.000000 0.002292 0.001146 0.000573 0.000573 0.005158 0.000573 0.000000 1.000573 0.002292
6 0.000000 0.001228 0.000000 0.000000 0.000000 0.000737 0.000000 0.002947 0.000000 0.000000... 0.000000 0.000000 0.000491 0.000000 0.000246 0.001719 0.016208 0.000000 1.000246 0.000246
7 0.000000 0.000000 0.000000 0.000000 0.000000 0.001894 0.000000 0.004261 0.000000 0.000000... 0.000000 0.000000 0.000947 0.000000 0.000473 0.005682 0.013258 0.000000 1.000473 0.000000
8 0.000000 0.000000 0.000000 0.000000 0.000000 0.001391 0.000000 0.006027 0.000000 0.000000... 0.000000 0.000000 0.000927 0.000000 0.000464 0.004636 0.014372 0.000000 1.000464 0.000000
9 0.000000 0.000000 0.000000 0.002193 0.002193 0.002924 0.000000 0.006579 0.000000 0.000000... 0.000000 0.000000 0.001462 0.000000 0.000731 0.010234 0.017544 0.000000 1.000731 0.000000
10 0.000000 0.003210 0.000000 0.000000 0.000000 0.001605 0.001605 0.011236 0.000000 0.000000... 0.000000 0.000000 0.001605 0.000000 0.000803 0.011236 0.000000 0.000000 1.000803 0.000000
11 0.000000 0.003506 0.000000 0.000000 0.000000 0.001403 0.001403 0.009818 0.000000 0.000000... 0.000000 0.000000 0.001403 0.000000 0.000701 0.011921 0.001403 0.000000 1.000701 0.000000
12 0.000000 0.004751 0.000000 0.000000 0.000000 0.000000 0.001584 0.011085 0.000000 0.000000... 0.000000 0.000000 0.001584 0.000000 0.000792 0.011876 0.000000 0.000000 1.000792 0.000000
13 0.000000 0.006533 0.000000 0.000000 0.000000 0.000000 0.002395 0.005444 0.000000 0.000000... 0.000000 0.000000 0.000436 0.000000 0.000218 0.011324 0.000000 0.003049 1.000218 0.000000
14 0.012293 0.000000 0.000000 0.001229 0.001229 0.000000 0.000000 0.006146 0.004302 0.001229... 0.000000 0.000000 0.001229 0.001844 0.000615 0.002459 0.004302 0.000000 1.000615 0.000000
15 0.009773 0.000000 0.000000 0.000888 0.002665 0.000000 0.000000 0.004442 0.003110 0.006664... 0.000000 0.000000 0.000888 0.001333 0.000444 0.004887 0.006219 0.000000 1.000444 0.000888
16 0.010925 0.000000 0.000000 0.000728 0.000728 0.000000 0.000000 0.007283 0.005098 0.002185... 0.000000 0.000000 0.001457 0.002185 0.000728 0.004370 0.005098 0.000000 1.000728 0.001457
17 0.000000 0.000000 0.000000 0.000000 0.000000 0.000746 0.000746 0.010440 0.000000 0.000000... 0.000000 0.000000 0.001491 0.000000 0.000746 0.013423 0.013423 0.000000 1.000746 0.000000
18 0.000000 0.000000 0.000000 0.000000 0.000000 0.001906 0.000476 0.007623 0.000000 0.003335... 0.000000 0.000953 0.000953 0.000000 0.000476 0.014293 0.015722 0.000000 1.000476 0.000000
19 0.000000 0.000000 0.000000 0.001267 0.001267 0.001901 0.000000 0.004436 0.000000 0.008872... 0.000000 0.000000 0.001267 0.001901 0.000634 0.009506 0.022180 0.000000 1.000634 0.000634
20 0.000000 0.000000 0.000000 0.001387 0.001387 0.000693 0.000000 0.009015 0.000000 0.013870... 0.000000 0.000000 0.001387 0.002080 0.000693 0.009709 0.017337 0.000000 1.000693 0.000000
21 0.000000 0.000000 0.000000 0.001355 0.001355 0.002033 0.000000 0.004743 0.000000 0.000000... 0.000000 0.000000 0.001355 0.002033 0.000678 0.012873 0.018970 0.000000 1.000678 0.000678
22 0.000000 0.000258 0.000000 0.000515 0.000515 0.001289 0.000000 0.003866 0.000000 0.000000... 0.000000 0.000000 0.000515 0.000773 0.000258 0.015206 0.027320 0.001289 1.000258 0.001031
23 0.000000 0.000557 0.000000 0.000557 0.000557 0.002784 0.002784 0.007238 0.005568 0.000000... 0.000000 0.000000 0.001114 0.000000 0.000557 0.017261 0.000000 0.000000 1.000557 0.000000
24 0.002914 0.000000 0.000000 0.000000 0.000000 0.000000 0.004079 0.005828 0.004079 0.000583... 0.004079 0.000000 0.001166 0.001748 0.000583 0.000000 0.008159 0.000000 1.000583 0.000000
25 0.003380 0.000000 0.000000 0.000000 0.000000 0.000000 0.005311 0.003863 0.005311 0.000483... 0.005311 0.000000 0.000966 0.001449 0.000483 0.000000 0.005794 0.000000 1.000483 0.000000
26 0.001107 0.000000 0.000000 0.000000 0.000000 0.000000 0.009222 0.002951 0.004795 0.000369... 0.009222 0.000000 0.000738 0.001107 0.000369 0.000000 0.004426 0.000000 1.000369 0.000369 1.002950 0.002950
27 0.000000 0.001931 0.000000 0.000000 0.00000027 30 php class Application extends App {\\n\\t/**\\n\\t * @... 0.000000 0.004505 0.001931 0.000512 0.000000 0.005629 0.005629 0.005118 0.000000... 0.000000 0.000000 0.001287 0.000000 0.000644 0.018018 0.000000 0.001535 0.000512 0.000512 0.011771 0.011259 0.000000 1.000644 1.000512 0.000000
28 0.000000 0.000608 0.000000 0.000000 0.000000 0.000000 0.003647 0.003040 0.00000028 31 ocaml type name = string\\n\\nlet compare_label label1... 0.005422 0.001322 0.000000 0.000661 0.002248 0.000926 0.000397... 0.000000 0.000000 0.001216 0.000000 0.000608 0.015805 0.000608 0.000000 1.000608 0.000132 0.000132 0.000132 0.006612 0.000397 0.000000 1.000132 0.000264
29 0.000000 0.000000 0.000000 0.00000029 32 ocaml let search_compiler_libs () =\\n prerr_endline... 0.005217 0.003478 0.000000 0.000000 0.003053 0.002290 0.001739 0.000000 0.000000... 0.000000 0.000000 0.001527 0.000000 0.000763 0.016794 0.000000 0.001739 0.001739 0.000000 1.000763 0.012174 0.000000 1.001739 0.001739
\n", + "

30 rows \u00d7 23 columns

\n", + "
" + ], + "metadata": {}, + "output_type": "pyout", + "prompt_number": 280, + "text": [ + " Filename Language Code \\\n", + "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", + "1 2 clojure (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", + "2 3 clojure (extend-type String\\n Person\\n (first-name [... \n", + "3 4 clojure (require '[overtone.live :as overtone])\\n\\n(de... \n", + "4 5 python from pkgutil import iter_modules\\nfrom subproc... \n", + "5 6 python import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", + "6 7 python class NoSuchService(Exception):\\n def __ini... \n", + "7 8 python from collections import namedtuple\\nimport fun... \n", + "8 9 javascript function errorHandler(context) {\\n return fun... \n", + "9 10 javascript var _ = require('lodash'),\\n fs = require('... \n", + "10 11 javascript /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", + "11 12 javascript var r = riot.route = function(arg) {\\n //... \n", + "12 13 ruby module ActiveJob\\n module Core\\n extend Ac... \n", + "13 14 ruby require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", + "14 15 ruby module Fluent\\n class Input\\n include Conf... \n", + "15 16 haskell {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", + "16 17 haskell reverseDependencies :: ModuleGraph -> M.Map Mo... \n", + "17 18 haskell {- git-annex extra config files\\n -\\n - Copyri... \n", + "18 19 scheme (define subst-f\\n (lambda (new old l)\\n (c... \n", + "19 20 scheme (define add1\\n (lambda (n) (+ n 1))) \n", + "20 21 scheme (define-lib-primitive (length lst)\\n (if (nul... \n", + "21 22 java /**\\n * Interface to represent a persistence s... \n", + "22 23 java /*\\n * Copyright 2002-2008 the original author... \n", + "23 24 scala package com.github.pathikrit\\n\\nimport scala.a... \n", + "24 25 scala /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", + "25 28 php class View\\n{\\n /**\\n * Data available ... \n", + "26 29 php public function formatLocalized($format)\\n... \n", + "27 30 php class Application extends App {\\n\\t/**\\n\\t * @... \n", + "28 31 ocaml type name = string\\n\\nlet compare_label label1... \n", + "29 32 ocaml let search_compiler_libs () =\\n prerr_endline... \n", + "\n", + " let end defn function fun return def \\\n", + "0 0.001759 0.000880 0.003518 0.000000 0.000000 0.000000 0.003518 \n", + "1 0.000000 0.000000 0.009852 0.000000 0.000000 0.000000 0.009852 \n", + "2 0.000000 0.006993 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "3 0.001675 0.000000 0.001675 0.000000 0.000000 0.000000 0.003350 \n", + "4 0.000000 0.004983 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "5 0.000000 0.001403 0.000000 0.000000 0.000000 0.001403 0.001403 \n", + "6 0.000000 0.000000 0.000000 0.000000 0.000000 0.006135 0.012270 \n", + "7 0.000000 0.003158 0.000000 0.000000 0.000148 0.000691 0.003059 \n", + "8 0.000000 0.000000 0.000000 0.008982 0.008982 0.001497 0.000000 \n", + "9 0.000000 0.000000 0.000000 0.005731 0.005731 0.008596 0.002865 \n", + "10 0.000058 0.000864 0.000000 0.004377 0.004435 0.002649 0.000864 \n", + "11 0.000000 0.000000 0.000000 0.011765 0.011765 0.000000 0.000000 \n", + "12 0.000000 0.005049 0.000000 0.000000 0.000000 0.000281 0.003086 \n", + "13 0.000000 0.006110 0.000000 0.000000 0.000000 0.000000 0.002037 \n", + "14 0.000000 0.014286 0.000000 0.000000 0.000000 0.000000 0.008163 \n", + "15 0.000131 0.000196 0.000000 0.000000 0.000000 0.000523 0.000261 \n", + "16 0.000000 0.006452 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "17 0.000491 0.000000 0.000000 0.000000 0.000982 0.001473 0.000491 \n", + "18 0.000000 0.000000 0.000000 0.002591 0.002591 0.000000 0.007772 \n", + "19 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.027778 \n", + "20 0.001341 0.000000 0.000000 0.000000 0.000000 0.000000 0.007449 \n", + "21 0.001424 0.000000 0.000000 0.000000 0.000000 0.001898 0.000949 \n", + "22 0.000000 0.000000 0.000000 0.000000 0.000000 0.001095 0.001095 \n", + "23 0.000000 0.003219 0.000000 0.000000 0.000000 0.000000 0.001788 \n", + "24 0.000000 0.001565 0.000000 0.000000 0.000000 0.000000 0.004173 \n", + "25 0.000000 0.001805 0.000000 0.002557 0.002708 0.002407 0.000000 \n", + "26 0.000000 0.000000 0.000000 0.002950 0.002950 0.002950 0.000000 \n", + "27 0.000000 0.000512 0.000000 0.005629 0.005629 0.005118 0.000000 \n", + "28 0.005422 0.001322 0.000000 0.000661 0.002248 0.000926 0.000397 \n", + "29 0.005217 0.003478 0.000000 0.000000 0.001739 0.000000 0.000000 \n", + "\n", + " ... .format define :: $ ^ , \\\n", + "0 ... 0.000880 0.000000 0.000000 0.000880 0.000880 0.009675 \n", + "1 ... 0.000000 0.000000 0.000000 0.004926 0.004926 0.000000 \n", + "2 ... 0.000000 0.000000 0.000000 0.006993 0.006993 0.000000 \n", + "3 ... 0.000000 0.000000 0.000000 0.001675 0.001675 0.006700 \n", + "4 ... 0.004983 0.000000 0.000000 0.001661 0.001661 0.014950 \n", + "5 ... 0.000000 0.000000 0.000000 0.000351 0.000351 0.003857 \n", + "6 ... 0.000000 0.000000 0.000000 0.003067 0.003067 0.006135 \n", + "7 ... 0.000000 0.000000 0.000000 0.000049 0.000049 0.014952 \n", + "8 ... 0.000000 0.000000 0.000000 0.000749 0.000749 0.005240 \n", + "9 ... 0.000000 0.000000 0.000000 0.005731 0.002865 0.011461 \n", + "10 ... 0.000000 0.000576 0.000000 0.000058 0.000058 0.012844 \n", + "11 ... 0.000000 0.000000 0.000000 0.005882 0.005882 0.005882 \n", + "12 ... 0.000000 0.000281 0.000561 0.000281 0.000281 0.001964 \n", + "13 ... 0.000000 0.000000 0.000000 0.002037 0.002037 0.010183 \n", + "14 ... 0.000000 0.000000 0.000000 0.002041 0.002041 0.000000 \n", + "15 ... 0.000849 0.000000 0.000915 0.000065 0.000065 0.013264 \n", + "16 ... 0.000000 0.000000 0.006452 0.003226 0.003226 0.012903 \n", + "17 ... 0.000000 0.000000 0.003929 0.000491 0.000491 0.001965 \n", + "18 ... 0.000000 0.007772 0.000000 0.002591 0.002591 0.000000 \n", + "19 ... 0.000000 0.027778 0.000000 0.027778 0.027778 0.000000 \n", + "20 ... 0.000000 0.007449 0.000000 0.000149 0.000149 0.000000 \n", + "21 ... 0.000000 0.000000 0.000000 0.000475 0.000475 0.000949 \n", + "22 ... 0.000000 0.001095 0.000000 0.000548 0.000548 0.004381 \n", + "23 ... 0.000000 0.000000 0.001073 0.000358 0.000358 0.005007 \n", + "24 ... 0.000000 0.000000 0.000000 0.000522 0.000522 0.001043 \n", + "25 ... 0.000000 0.000000 0.000301 0.000150 0.000150 0.002858 \n", + "26 ... 0.014749 0.000000 0.000000 0.002950 0.002950 0.014749 \n", + "27 ... 0.000000 0.000000 0.001535 0.000512 0.000512 0.011771 \n", + "28 ... 0.000000 0.000000 0.000132 0.000132 0.000132 0.006612 \n", + "29 ... 0.000000 0.000000 0.000000 0.001739 0.001739 0.000000 \n", + "\n", + " ; & | ! \n", + "0 0.000000 0.000000 1.000880 0.000000 \n", + "1 0.000000 0.009852 1.004926 0.000000 \n", + "2 0.000000 0.000000 1.006993 0.000000 \n", + "3 0.006700 0.000000 1.001675 0.001675 \n", + "4 0.000000 0.000000 1.001661 0.000000 \n", + "5 0.000000 0.000000 1.000351 0.000000 \n", + "6 0.000000 0.000000 1.003067 0.000000 \n", + "7 0.000247 0.000000 1.000049 0.000247 \n", + "8 0.014222 0.000000 1.000749 0.000000 \n", + "9 0.011461 0.000000 1.002865 0.000000 \n", + "10 0.000691 0.002361 1.000058 0.001498 \n", + "11 0.000000 0.000000 1.005882 0.000000 \n", + "12 0.000000 0.000561 1.000281 0.000000 \n", + "13 0.000000 0.000000 1.002037 0.000000 \n", + "14 0.000000 0.000000 1.002041 0.000000 \n", + "15 0.000261 0.000000 1.000065 0.000000 \n", + "16 0.000000 0.009677 1.003226 0.000000 \n", + "17 0.000491 0.000000 1.000491 0.000000 \n", + "18 0.010363 0.000000 1.002591 0.000000 \n", + "19 0.000000 0.000000 1.027778 0.000000 \n", + "20 0.000298 0.000000 1.000149 0.002086 \n", + "21 0.003322 0.000000 1.000475 0.000000 \n", + "22 0.003286 0.000000 1.000548 0.000000 \n", + "23 0.000000 0.000000 1.000358 0.000000 \n", + "24 0.000000 0.000000 1.000522 0.000000 \n", + "25 0.004964 0.000602 1.000150 0.000903 \n", + "26 0.005900 0.000000 1.002950 0.002950 \n", + "27 0.011259 0.000000 1.000512 0.000000 \n", + "28 0.000397 0.000000 1.000132 0.000264 \n", + "29 0.012174 0.000000 1.001739 0.001739 \n", + "\n", + "[30 rows x 23 columns]" + ] + } + ], + "prompt_number": 280 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_codelist = tcode_sucker()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 281 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df = pd.read_csv(\"test.csv\")" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 282 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df[\"Testcode\"] = test_codelist" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 283 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df['code length'] = test_df.Testcode.apply(length_getter)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 284 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df['^'] = df.Code.apply(carat)\n", + "test_df[';'] = df.Code.apply(semicolon)\n", + "test_df[','] = df.Code.apply(comma)\n", + "test_df['&'] = df.Code.apply(carat)\n", + "test_df['!'] = df.Code.apply(semicolon)\n", + "test_df['|'] = df.Code.apply(comma)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 285 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df['let'] = df.Code.apply(let_ratio)\n", + "test_df['end'] = df.Code.apply(end_ratio)\n", + "test_df['fun'] = df.Code.apply(fun_ratio)\n", + "test_df['defn'] = df.Code.apply(defn_ratio)\n", + "test_df['def'] = df.Code.apply(def_ratio)\n", + "test_df['function'] = df.Code.apply(function_ratio)\n", + "test_df['slice'] = df.Code.apply(slice_ratio)\n", + "test_df['return'] = df.Code.apply(return_ratio)\n", + "test_df['define'] = df.Code.apply(define_ratio)\n", + "test_df['doublecolon'] = df.Code.apply(doublecolon_ratio)\n", + "test_df['check'] = df.Code.apply(check_ratio)\n", + "test_df['make'] = df.Code.apply(make_ratio)\n", + "test_df['.format'] = df.Code.apply(format_ratio)\n", + "test_df['->'] = df.Code.apply(arrow_ratio)\n", + "test_df['$'] = df.Code.apply(dollar_ratio)\n", + "test_df['printf'] = df.Code.apply(printf_ratio)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 286 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "test_df" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", " \n", - " \n", - " \n", + " \n", " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", " \n", - " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", + " \n", " \n", - " \n", " \n", " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", + " \n", " \n", - " \n", " \n", - " \n", - " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", - " \n", - " \n", " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", " \n", + " \n", " \n", - " \n", " \n", - " \n", - " \n", - " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", " \n", + " \n", " \n", - " \n", " \n", - " \n", " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", + " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", + " \n", " \n", - " \n", " \n", + " \n", " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", + " \n", " \n", " \n", + " \n", " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", " \n", + " \n", " \n", " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", " \n", - " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", + " \n", " \n", - " \n", " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", " \n", + " \n", " \n", - " \n", " \n", - " \n", " \n", - " \n", + " \n", " \n", - " \n", - " \n", " \n", " \n", "
FilenameLanguageTestcodecode length^;,&!|..................................................................
356 0.000000 0.000000 0.000000 0.000000 0.000000 0.004155 0.004848 0.000000 0.000000 0.000000... 0.000000 0.000000 0.001385 0.000000 0.000693 0.009003 0.000000 0.000000 1.000693 0.000000slicereturndefinedoublecoloncheckmake.format->$printf
357 0.000000 0.000000 0.000000 0.000000 0.000000 0.003165 0.003956 0.000000 0.000000 0.0000000 1 clojure (defn cf-settings\\n \"Setup settings for campf... 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826... 0 0.000000 0.000000 0.001582 0.000000 0.000791 0.005538 0.005372 0.000000 0.001240 0.000000 1.000791 0.000826 0.000000
358 0.000000 0.000000 0.000000 0.000000 0.000000 0.000600 0.003001 0.000000 0.000000 0.0000001 2 clojure (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... 203 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771... 0 0.000000 0.000000 0.001200 0.000000 0.000600 0.011405 0.000000 0.005012 0.002699 0.001157 0.000000 1.000600 0.000771 0.000000
359 0.002172 0.000000 0.000000 0.000000 0.000000 0.000543 0.002714 0.000000 0.001629 0.0027142 3 clojure (extend-type String\\n Person\\n (first-name [... 143 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347... 0.002714 0.000000 0.001086 0.000543 0.000543 0.000543 0.014115 0.000000 1.000543 0.001086
360 0.001901 0.000000 0 0.000000 0.000000 0.000000 0.000475 0.002376 0.009094 0.000000 0.001901 0.003327... 0.002376 0.001010 0.000000 0.000951 0.000475 0.000475 0.000475 0.013308 0.000674 0.000000 1.000475 0.000951
361 0.003863 0.000000 0.000000 0.000000 0.0000003 4 clojure (require '[overtone.live :as overtone])\\n\\n(de... 597 0.000000 0.005311 0.000618 0.006177 0.000000 0.001931 0.002414 0.000618 0.006177... 0.005311 0.000000 0.000966 0 0.000000 0.000483 0.000000 0.004829 0.002471 0.006794 0.005559 0.000000 1.000483 0.000966 0.005559 0.001235 0.000618
362 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.002508 0.0000004 5 python from pkgutil import iter_modules\\nfrom subproc... 602 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294... 0 0.000000 0.000000 0.001672 0.000836 0.000836 0.015050 0.000836 0.000836 1.000836 0.002118 0.006882 0.004764 0.000000 0.005823 0.001059 0.000529
363 0.000000 0.002877 0.000000 0.000000 0.000000 0.000000 0.002877 0.0000005 6 python import re\\nimport subprocess\\n\\ndef cmd_keymap... 2852 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158... 0 0.000000 0.000000 0.000822 0.000000 0.000411 0.009453 0.000000 0.000000 1.000411 0.002292 0.007450 0.005158 0.000000 0.006304 0.001146 0.000573
364 0.000248 0.000248 0.000000 0.000248 0.000248 0.000248 0.002475 0.0000006 7 python class NoSuchService(Exception):\\n def __ini... 326 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719... 0 0.000737 0.000000 0.000495 0.000495 0.000000 0.000248 0.009406 0.000000 0.000000 1.000248 0.000000
365 0.000458 0.000229 0.000000 0.000229 0.000229 0.000229 0.002521 0.000000 0.000000 0.000000... 0.000000 0.000687 0.000458 0.002947 0.000000 0.000229 0.008249 0.000000 0.000000 1.000229 0.000491 0.000000
366 0.001794 0.002691 0.002691 0.0000007 8 python from collections import namedtuple\\nimport fun... 20265 0.000000 0.013258 0.005682 0.000000 0.002691 0.013258 0.005682... 0 0.001894 0.000000 0.000000 0.004261 0.000000... 0.000000 0.000000 0.001794 0.000947 0.000000 0.000897 0.000897 0.008969 0.000897 1.000897 0.000897
367 0.000000 0.004206 0.003155 0.001052 0.001052 0.001052 0.004206 0.0000008 9 javascript function errorHandler(context) {\\n return fun... 1336 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636... 0 0.001391 0.000000 0.000000 0.002103 0.006027 0.000000 0.000000 0.001052 0.000000 0.011567 0.001052 1.001052 0.000927 0.000000
368 0.000000 0.000000 0.0000009 10 javascript var _ = require('lodash'),\\n fs = require('... 349 0.000000 0.017544 0.010234 0.000000 0.001149 0.017544 0.010234... 0 0.002924 0.000000 0.000000 0.001149 0.004598... 0.006579 0.000000 0.001149 0.002299 0.000000 0.001149 0.001149 0.000000 0.001462 0.000000 1.001149 0.001149
369 0.000000 0.000897 0.00000010 11 javascript /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... 17362 0.000000 0.000000 0.000897 0.011236 0.000000 0.000000 0.011236... 0 0.001605 0.000000 0.000000... 0.011236 0.000000 0.000000 0.000897 0.000000 0.000449 0.000897 0.018394 0.001605 0.000000 1.000449 0.000449
370 0.000000 0.000600 0.000000 0.000000 0.000000 0.00060011 12 javascript var r = riot.route = function(arg) {\\n //... 170 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921... 0 0.001403 0.000000 0.000000... 0.009818 0.000000 0.000000 0.001200 0.000000 0.000600 0.001801 0.017407 0.001403 0.000000 1.000600 0.000600
371 0.000000 0.001525 0.00000012 13 ruby module ActiveJob\\n module Core\\n extend Ac... 3565 0.000000 0.000000 0.000508 0.011876 0.000000 0.000000 0.011876... 0 0.000000 0.000000... 0.000000 0.011085 0.000000 0.000508 0.000000 0.000254 0.002542 0.014743 0.000000 1.000254 0.001584 0.000000
372 0.000000 0.000000 0.000000 0.000000 0.000000 0.00000013 14 ruby require 'formula'\\n\\nclass A52dec < Formula\\n ... 491 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324... 0 0.000000 0.000000... 0.000000 0.005444 0.000000 0.001504 0.000000 0.000752 0.000000 0.015038 0.000436 0.000000 1.000752 0.000752
373 0.000000 0.001183 0.000000 0.000000 0.000000 0.000000 0.000000 0.00000014 15 ruby module Fluent\\n class Input\\n include Conf... 490 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459... 0 0.000000 0.000000 0.000789 0.000000 0.000394 0.001577 0.011435 0.000000 1.000394 0.006146 0.004302 0.000000 0.001229 0.001229 0.001844
374 0.000000 0.000626 0.000000 0.000000 0.000000 0.000000 0.000000 0.00000015 16 haskell {-# LANGUAGE ScopedTypeVariables, FlexibleInst... 15305 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887... 0 0.000000 0.000000 0.001252 0.000000 0.000626 0.000000 0.019399 0.000000 1.000626 0.004442 0.003110 0.000000 0.006664 0.000888 0.001333
37516 17 haskell reverseDependencies :: ModuleGraph -> M.Map Mo... 310 0.000000 0.010881 0.005098 0.004370 0.000000 0.005098 0.004370... 0 0.000000 0.000000 0.000000 0.004353 0.007283 0.005098 0.000000 0.002185 0.001457 0.002185
17 18 haskell {- git-annex extra config files\\n -\\n - Copyri... 2036 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423... 0 0.000746 0.000000 0.000000 0.002176 0.010440 0.000000 0.001088 0.001088 0.000000 0.000000 1.001088 0.001491 0.000000
376 0.000000 0.01013518 19 scheme (define subst-f\\n (lambda (new old l)\\n (c... 386 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293... 0 0.001906 0.000000 0.000953 0.007623 0.000000 0.000000 0.003335 0.000953 0.000000
19 20 scheme (define add1\\n (lambda (n) (+ n 1))) 36 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506... 0 0.001901 0.000000 0.000000 0.003378 0.000000 0.001689 0.000000 0.000000 0.004436 0.000000 1.001689 0.000000 0.008872 0.001267 0.001901
377 0.011611 0.002903 0.000000 0.000000 0.002903 0.000000 0.00000020 21 scheme (define-lib-primitive (length lst)\\n (if (nul... 6712 0.000000 0.017337 0.009709 0.000000 0.002903 0.017337 0.009709... 0 0.000693 0.000000 0.000000 0.002903 0.000000 0.001451 0.000000 0.005806 0.009015 0.000000 1.001451 0.000000 0.013870 0.001387 0.002080
378 0.01061321 22 java /**\\n * Interface to represent a persistence s... 2107 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873... 0 0.002033 0.000000 0.000000 0.004743 0.000000 0.000000 0.000000 0.001355 0.002033
22 23 java /*\\n * Copyright 2002-2008 the original author... 1826 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206... 0 0.001289 0.000000 0.000000 0.002358 0.003866 0.000000 0.000000 0.001179 0.002358 0.014151 0.000000 1.001179 0.002358 0.000515 0.000773
379 0.010914 0.000000 0.000000 0.000000 0.00136423 24 scala package com.github.pathikrit\\n\\nimport scala.a... 2796 0.000000 0.000000 0.017261 0.000000 0.000000 0.001364 0.017261... 0 0.002784 0.000000 0.000000 0.002729 0.000000 0.001364 0.002729 0.012278 0.007238 0.005568 0.001670 0.000000 1.001364 0.001114 0.000000
380 0.000000 0.000000 0.000000 0.000000 0.00212824 25 scala /* sbt -- Simple Build Tool\\n * Copyright 2010... 1917 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 0.008511... 0 0.000000 0.004255 0.002128 0.004079 0.000000 0.001064 0.001064 0.029787 0.001064 1.001064 0.005828 0.004079 0.000000 0.000583 0.001166 0.001748
381 0.000420 0.000840 0.00000025 28 php class View\\n{\\n /**\\n * Data available ... 6648 0.000000 0.005794 0.000000 0.000000 0.000840 0.005794 0.000000 0.000420 0.002940... 0.000420 0.001260 0.000840 0 0.000000 0.005311 0.000000 0.000420 0.004200 0.012180 0.000840 1.000420 0.003863 0.005311 0.000000 0.000483 0.000966 0.001449
382 0.000000 0.000000 0.000000 0.000000 0.00209026 29 php public function formatLocalized($format)\\n... 339 0.000000 0.001045 0.004426 0.000000 0.000000 0.004426 0.000000... 0 0.000000 0.009222 0.000000 0.002090 0.000000 0.001045 0.006270 0.000000 0.000000 1.001045 0.002951 0.004795 0.000000 0.000369 0.000738 0.001107
383 0.000000 0.006090 0.000000 0.000000 0.00121827 30 php class Application extends App {\\n\\t/**\\n\\t * @... 1954 0.000000 0.002436 0.000000 0.018018 0.000000 0.000000 0.018018... 0 0.000000 0.000000 0.002436 0.000000 0.001218 0.003654 0.001931 0.000000 0.000000 0.000000 1.001218 0.001287 0.000000
384 0.003911 0.002608 0.00000028 31 ocaml type name = string\\n\\nlet compare_label label1... 7562 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805... 0 0.000000 0.001304 0.000000 0.000000 0.001304... 0.001304 0.003040 0.000000 0.002608 0.001304 0.001304 0.000000 0.027379 0.000000 1.001304 0.001216 0.000000
385 0.000000 0.001414 0.00000029 32 ocaml let search_compiler_libs () =\\n prerr_endline... 575 0.000000 0.000000 0.016794 0.000000 0.002829 0.000000 0.016794... 0 0.000000 0.000000... 0.000000 0.002290 0.000000 0.002829 0.000000 0.001414 0.000000 0.001414 0.001527 0.000000 1.001414 0.002829
\n", - "

386 rows \u00d7 21 columns

\n", + "

30 rows \u00d7 26 columns

\n", "
" ], "metadata": {}, "output_type": "pyout", - "prompt_number": 212, + "prompt_number": 287, "text": [ - " let end defn function fun return def \\\n", - "0 0.002066 0.000000 0.002066 0.000000 0.000000 0.000000 0.004545 \n", - "1 0.002699 0.000386 0.001928 0.000000 0.000000 0.000000 0.003470 \n", - "2 0.002695 0.000000 0.002021 0.000000 0.000000 0.000000 0.003705 \n", - "3 0.002471 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "4 0.002647 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "5 0.002865 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "6 0.000000 0.001228 0.000000 0.000000 0.000000 0.000737 0.000000 \n", - "7 0.000000 0.000000 0.000000 0.000000 0.000000 0.001894 0.000000 \n", - "8 0.000000 0.000000 0.000000 0.000000 0.000000 0.001391 0.000000 \n", - "9 0.000000 0.000000 0.000000 0.002193 0.002193 0.002924 0.000000 \n", - "10 0.000000 0.003210 0.000000 0.000000 0.000000 0.001605 0.001605 \n", - "11 0.000000 0.003506 0.000000 0.000000 0.000000 0.001403 0.001403 \n", - "12 0.000000 0.004751 0.000000 0.000000 0.000000 0.000000 0.001584 \n", - "13 0.000000 0.006533 0.000000 0.000000 0.000000 0.000000 0.002395 \n", - "14 0.012293 0.000000 0.000000 0.001229 0.001229 0.000000 0.000000 \n", - "15 0.009773 0.000000 0.000000 0.000888 0.002665 0.000000 0.000000 \n", - "16 0.010925 0.000000 0.000000 0.000728 0.000728 0.000000 0.000000 \n", - "17 0.000000 0.000000 0.000000 0.000000 0.000000 0.000746 0.000746 \n", - "18 0.000000 0.000000 0.000000 0.000000 0.000000 0.001906 0.000476 \n", - "19 0.000000 0.000000 0.000000 0.001267 0.001267 0.001901 0.000000 \n", - "20 0.000000 0.000000 0.000000 0.001387 0.001387 0.000693 0.000000 \n", - "21 0.000000 0.000000 0.000000 0.001355 0.001355 0.002033 0.000000 \n", - "22 0.000000 0.000258 0.000000 0.000515 0.000515 0.001289 0.000000 \n", - "23 0.000000 0.000557 0.000000 0.000557 0.000557 0.002784 0.002784 \n", - "24 0.002914 0.000000 0.000000 0.000000 0.000000 0.000000 0.004079 \n", - "25 0.003380 0.000000 0.000000 0.000000 0.000000 0.000000 0.005311 \n", - "26 0.001107 0.000000 0.000000 0.000000 0.000000 0.000000 0.009222 \n", - "27 0.000000 0.001931 0.000000 0.000000 0.000000 0.000000 0.004505 \n", - "28 0.000000 0.000608 0.000000 0.000000 0.000000 0.000000 0.003647 \n", - "29 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.003053 \n", - ".. ... ... ... ... ... ... ... \n", - "356 0.000000 0.000000 0.000000 0.000000 0.000000 0.004155 0.004848 \n", - "357 0.000000 0.000000 0.000000 0.000000 0.000000 0.003165 0.003956 \n", - "358 0.000000 0.000000 0.000000 0.000000 0.000000 0.000600 0.003001 \n", - "359 0.002172 0.000000 0.000000 0.000000 0.000000 0.000543 0.002714 \n", - "360 0.001901 0.000000 0.000000 0.000000 0.000000 0.000475 0.002376 \n", - "361 0.003863 0.000000 0.000000 0.000000 0.000000 0.000000 0.005311 \n", - "362 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.002508 \n", - "363 0.000000 0.002877 0.000000 0.000000 0.000000 0.000000 0.002877 \n", - "364 0.000248 0.000248 0.000000 0.000248 0.000248 0.000248 0.002475 \n", - "365 0.000458 0.000229 0.000000 0.000229 0.000229 0.000229 0.002521 \n", - "366 0.001794 0.002691 0.002691 0.000000 0.000000 0.000000 0.002691 \n", - "367 0.000000 0.004206 0.003155 0.001052 0.001052 0.001052 0.004206 \n", - "368 0.000000 0.000000 0.000000 0.000000 0.000000 0.001149 0.000000 \n", - "369 0.000000 0.000897 0.000000 0.000000 0.000000 0.000897 0.000000 \n", - "370 0.000000 0.000600 0.000000 0.000000 0.000000 0.000600 0.000000 \n", - "371 0.000000 0.001525 0.000000 0.000000 0.000000 0.000508 0.000000 \n", - "372 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "373 0.000000 0.001183 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "374 0.000000 0.000626 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "375 0.000000 0.010881 0.000000 0.000000 0.000000 0.000000 0.004353 \n", - "376 0.000000 0.010135 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "377 0.011611 0.002903 0.000000 0.000000 0.002903 0.000000 0.000000 \n", - "378 0.010613 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "379 0.010914 0.000000 0.000000 0.000000 0.001364 0.000000 0.000000 \n", - "380 0.000000 0.000000 0.000000 0.000000 0.002128 0.000000 0.000000 \n", - "381 0.000420 0.000840 0.000000 0.000000 0.000000 0.000000 0.000840 \n", - "382 0.000000 0.000000 0.000000 0.000000 0.002090 0.000000 0.001045 \n", - "383 0.000000 0.006090 0.000000 0.000000 0.001218 0.000000 0.002436 \n", - "384 0.003911 0.002608 0.000000 0.000000 0.000000 0.000000 0.001304 \n", - "385 0.000000 0.001414 0.000000 0.000000 0.000000 0.000000 0.002829 \n", + " Filename Language Testcode \\\n", + "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", + "1 2 clojure (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", + "2 3 clojure (extend-type String\\n Person\\n (first-name [... \n", + "3 4 clojure (require '[overtone.live :as overtone])\\n\\n(de... \n", + "4 5 python from pkgutil import iter_modules\\nfrom subproc... \n", + "5 6 python import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", + "6 7 python class NoSuchService(Exception):\\n def __ini... \n", + "7 8 python from collections import namedtuple\\nimport fun... \n", + "8 9 javascript function errorHandler(context) {\\n return fun... \n", + "9 10 javascript var _ = require('lodash'),\\n fs = require('... \n", + "10 11 javascript /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", + "11 12 javascript var r = riot.route = function(arg) {\\n //... \n", + "12 13 ruby module ActiveJob\\n module Core\\n extend Ac... \n", + "13 14 ruby require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", + "14 15 ruby module Fluent\\n class Input\\n include Conf... \n", + "15 16 haskell {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", + "16 17 haskell reverseDependencies :: ModuleGraph -> M.Map Mo... \n", + "17 18 haskell {- git-annex extra config files\\n -\\n - Copyri... \n", + "18 19 scheme (define subst-f\\n (lambda (new old l)\\n (c... \n", + "19 20 scheme (define add1\\n (lambda (n) (+ n 1))) \n", + "20 21 scheme (define-lib-primitive (length lst)\\n (if (nul... \n", + "21 22 java /**\\n * Interface to represent a persistence s... \n", + "22 23 java /*\\n * Copyright 2002-2008 the original author... \n", + "23 24 scala package com.github.pathikrit\\n\\nimport scala.a... \n", + "24 25 scala /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", + "25 28 php class View\\n{\\n /**\\n * Data available ... \n", + "26 29 php public function formatLocalized($format)\\n... \n", + "27 30 php class Application extends App {\\n\\t/**\\n\\t * @... \n", + "28 31 ocaml type name = string\\n\\nlet compare_label label1... \n", + "29 32 ocaml let search_compiler_libs () =\\n prerr_endline... \n", + "\n", + " code length ^ ; , & ! | \\\n", + "0 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826 \n", + "1 203 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771 \n", + "2 143 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347 \n", + "3 597 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177 \n", + "4 602 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294 \n", + "5 2852 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158 \n", + "6 326 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719 \n", + "7 20265 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682 \n", + "8 1336 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636 \n", + "9 349 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234 \n", + "10 17362 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236 \n", + "11 170 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921 \n", + "12 3565 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876 \n", + "13 491 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324 \n", + "14 490 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459 \n", + "15 15305 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887 \n", + "16 310 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370 \n", + "17 2036 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423 \n", + "18 386 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293 \n", + "19 36 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506 \n", + "20 6712 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709 \n", + "21 2107 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873 \n", + "22 1826 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206 \n", + "23 2796 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261 \n", + "24 1917 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 \n", + "25 6648 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000 \n", + "26 339 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000 \n", + "27 1954 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018 \n", + "28 7562 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805 \n", + "29 575 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794 \n", "\n", - " check make -> ... define :: $ \\\n", - "0 0.005372 0.000000 0.000000 ... 0.000000 0.000000 0.000826 \n", - "1 0.005012 0.002699 0.000000 ... 0.000000 0.000000 0.000771 \n", - "2 0.009094 0.000000 0.000000 ... 0.000000 0.000000 0.000674 \n", - "3 0.006794 0.005559 0.005559 ... 0.000000 0.002471 0.001235 \n", - "4 0.006882 0.004764 0.005823 ... 0.000000 0.002118 0.001059 \n", - "5 0.007450 0.005158 0.006304 ... 0.000000 0.002292 0.001146 \n", - "6 0.002947 0.000000 0.000000 ... 0.000000 0.000000 0.000491 \n", - "7 0.004261 0.000000 0.000000 ... 0.000000 0.000000 0.000947 \n", - "8 0.006027 0.000000 0.000000 ... 0.000000 0.000000 0.000927 \n", - "9 0.006579 0.000000 0.000000 ... 0.000000 0.000000 0.001462 \n", - "10 0.011236 0.000000 0.000000 ... 0.000000 0.000000 0.001605 \n", - "11 0.009818 0.000000 0.000000 ... 0.000000 0.000000 0.001403 \n", - "12 0.011085 0.000000 0.000000 ... 0.000000 0.000000 0.001584 \n", - "13 0.005444 0.000000 0.000000 ... 0.000000 0.000000 0.000436 \n", - "14 0.006146 0.004302 0.001229 ... 0.000000 0.000000 0.001229 \n", - "15 0.004442 0.003110 0.006664 ... 0.000000 0.000000 0.000888 \n", - "16 0.007283 0.005098 0.002185 ... 0.000000 0.000000 0.001457 \n", - "17 0.010440 0.000000 0.000000 ... 0.000000 0.000000 0.001491 \n", - "18 0.007623 0.000000 0.003335 ... 0.000000 0.000953 0.000953 \n", - "19 0.004436 0.000000 0.008872 ... 0.000000 0.000000 0.001267 \n", - "20 0.009015 0.000000 0.013870 ... 0.000000 0.000000 0.001387 \n", - "21 0.004743 0.000000 0.000000 ... 0.000000 0.000000 0.001355 \n", - "22 0.003866 0.000000 0.000000 ... 0.000000 0.000000 0.000515 \n", - "23 0.007238 0.005568 0.000000 ... 0.000000 0.000000 0.001114 \n", - "24 0.005828 0.004079 0.000583 ... 0.004079 0.000000 0.001166 \n", - "25 0.003863 0.005311 0.000483 ... 0.005311 0.000000 0.000966 \n", - "26 0.002951 0.004795 0.000369 ... 0.009222 0.000000 0.000738 \n", - "27 0.001931 0.000000 0.000000 ... 0.000000 0.000000 0.001287 \n", - "28 0.003040 0.000000 0.000000 ... 0.000000 0.000000 0.001216 \n", - "29 0.002290 0.000000 0.000000 ... 0.000000 0.000000 0.001527 \n", - ".. ... ... ... ... ... ... ... \n", - "356 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001385 \n", - "357 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001582 \n", - "358 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001200 \n", - "359 0.000000 0.001629 0.002714 ... 0.002714 0.000000 0.001086 \n", - "360 0.000000 0.001901 0.003327 ... 0.002376 0.000000 0.000951 \n", - "361 0.000000 0.001931 0.002414 ... 0.005311 0.000000 0.000966 \n", - "362 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001672 \n", - "363 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000822 \n", - "364 0.000000 0.000000 0.000000 ... 0.000000 0.000495 0.000495 \n", - "365 0.000000 0.000000 0.000000 ... 0.000000 0.000687 0.000458 \n", - "366 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001794 \n", - "367 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002103 \n", - "368 0.000000 0.001149 0.004598 ... 0.000000 0.001149 0.002299 \n", - "369 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000897 \n", - "370 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001200 \n", - "371 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000508 \n", - "372 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001504 \n", - "373 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000789 \n", - "374 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.001252 \n", - "375 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002176 \n", - "376 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.003378 \n", - "377 0.000000 0.000000 0.002903 ... 0.000000 0.000000 0.002903 \n", - "378 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002358 \n", - "379 0.000000 0.000000 0.001364 ... 0.000000 0.000000 0.002729 \n", - "380 0.000000 0.000000 0.008511 ... 0.000000 0.004255 0.002128 \n", - "381 0.000000 0.000420 0.002940 ... 0.000420 0.001260 0.000840 \n", - "382 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002090 \n", - "383 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002436 \n", - "384 0.000000 0.000000 0.001304 ... 0.001304 0.000000 0.002608 \n", - "385 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.002829 \n", + " ... slice return define doublecolon check make \\\n", + "0 ... 0 0.000000 0.000000 0.000000 0.005372 0.000000 \n", + "1 ... 0 0.000000 0.000000 0.000000 0.005012 0.002699 \n", + "2 ... 0 0.000000 0.000000 0.000000 0.009094 0.000000 \n", + "3 ... 0 0.000000 0.000000 0.002471 0.006794 0.005559 \n", + "4 ... 0 0.000000 0.000000 0.002118 0.006882 0.004764 \n", + "5 ... 0 0.000000 0.000000 0.002292 0.007450 0.005158 \n", + "6 ... 0 0.000737 0.000000 0.000000 0.002947 0.000000 \n", + "7 ... 0 0.001894 0.000000 0.000000 0.004261 0.000000 \n", + "8 ... 0 0.001391 0.000000 0.000000 0.006027 0.000000 \n", + "9 ... 0 0.002924 0.000000 0.000000 0.006579 0.000000 \n", + "10 ... 0 0.001605 0.000000 0.000000 0.011236 0.000000 \n", + "11 ... 0 0.001403 0.000000 0.000000 0.009818 0.000000 \n", + "12 ... 0 0.000000 0.000000 0.000000 0.011085 0.000000 \n", + "13 ... 0 0.000000 0.000000 0.000000 0.005444 0.000000 \n", + "14 ... 0 0.000000 0.000000 0.000000 0.006146 0.004302 \n", + "15 ... 0 0.000000 0.000000 0.000000 0.004442 0.003110 \n", + "16 ... 0 0.000000 0.000000 0.000000 0.007283 0.005098 \n", + "17 ... 0 0.000746 0.000000 0.000000 0.010440 0.000000 \n", + "18 ... 0 0.001906 0.000000 0.000953 0.007623 0.000000 \n", + "19 ... 0 0.001901 0.000000 0.000000 0.004436 0.000000 \n", + "20 ... 0 0.000693 0.000000 0.000000 0.009015 0.000000 \n", + "21 ... 0 0.002033 0.000000 0.000000 0.004743 0.000000 \n", + "22 ... 0 0.001289 0.000000 0.000000 0.003866 0.000000 \n", + "23 ... 0 0.002784 0.000000 0.000000 0.007238 0.005568 \n", + "24 ... 0 0.000000 0.004079 0.000000 0.005828 0.004079 \n", + "25 ... 0 0.000000 0.005311 0.000000 0.003863 0.005311 \n", + "26 ... 0 0.000000 0.009222 0.000000 0.002951 0.004795 \n", + "27 ... 0 0.000000 0.000000 0.000000 0.001931 0.000000 \n", + "28 ... 0 0.000000 0.000000 0.000000 0.003040 0.000000 \n", + "29 ... 0 0.000000 0.000000 0.000000 0.002290 0.000000 \n", "\n", - " printf ^ , ; & | ! \n", - "0 0.000000 0.000413 0.000826 0.009091 0.000413 1.000413 0.000826 \n", - "1 0.000000 0.000386 0.000771 0.008096 0.000771 1.000386 0.000771 \n", - "2 0.000000 0.000337 0.001347 0.010104 0.000337 1.000337 0.000337 \n", - "3 0.000618 0.000618 0.006177 0.000618 0.000000 1.000618 0.002471 \n", - "4 0.000529 0.000529 0.005294 0.000529 0.000000 1.000529 0.003176 \n", - "5 0.000573 0.000573 0.005158 0.000573 0.000000 1.000573 0.002292 \n", - "6 0.000000 0.000246 0.001719 0.016208 0.000000 1.000246 0.000246 \n", - "7 0.000000 0.000473 0.005682 0.013258 0.000000 1.000473 0.000000 \n", - "8 0.000000 0.000464 0.004636 0.014372 0.000000 1.000464 0.000000 \n", - "9 0.000000 0.000731 0.010234 0.017544 0.000000 1.000731 0.000000 \n", - "10 0.000000 0.000803 0.011236 0.000000 0.000000 1.000803 0.000000 \n", - "11 0.000000 0.000701 0.011921 0.001403 0.000000 1.000701 0.000000 \n", - "12 0.000000 0.000792 0.011876 0.000000 0.000000 1.000792 0.000000 \n", - "13 0.000000 0.000218 0.011324 0.000000 0.003049 1.000218 0.000000 \n", - "14 0.001844 0.000615 0.002459 0.004302 0.000000 1.000615 0.000000 \n", - "15 0.001333 0.000444 0.004887 0.006219 0.000000 1.000444 0.000888 \n", - "16 0.002185 0.000728 0.004370 0.005098 0.000000 1.000728 0.001457 \n", - "17 0.000000 0.000746 0.013423 0.013423 0.000000 1.000746 0.000000 \n", - "18 0.000000 0.000476 0.014293 0.015722 0.000000 1.000476 0.000000 \n", - "19 0.001901 0.000634 0.009506 0.022180 0.000000 1.000634 0.000634 \n", - "20 0.002080 0.000693 0.009709 0.017337 0.000000 1.000693 0.000000 \n", - "21 0.002033 0.000678 0.012873 0.018970 0.000000 1.000678 0.000678 \n", - "22 0.000773 0.000258 0.015206 0.027320 0.001289 1.000258 0.001031 \n", - "23 0.000000 0.000557 0.017261 0.000000 0.000000 1.000557 0.000000 \n", - "24 0.001748 0.000583 0.000000 0.008159 0.000000 1.000583 0.000000 \n", - "25 0.001449 0.000483 0.000000 0.005794 0.000000 1.000483 0.000000 \n", - "26 0.001107 0.000369 0.000000 0.004426 0.000000 1.000369 0.000369 \n", - "27 0.000000 0.000644 0.018018 0.000000 0.000000 1.000644 0.000000 \n", - "28 0.000000 0.000608 0.015805 0.000608 0.000000 1.000608 0.000000 \n", - "29 0.000000 0.000763 0.016794 0.000000 0.000000 1.000763 0.000000 \n", - ".. ... ... ... ... ... ... ... \n", - "356 0.000000 0.000693 0.009003 0.000000 0.000000 1.000693 0.000000 \n", - "357 0.000000 0.000791 0.005538 0.000000 0.000000 1.000791 0.000000 \n", - "358 0.000000 0.000600 0.011405 0.000000 0.000000 1.000600 0.000000 \n", - "359 0.000543 0.000543 0.000543 0.014115 0.000000 1.000543 0.001086 \n", - "360 0.000475 0.000475 0.000475 0.013308 0.000000 1.000475 0.000951 \n", - "361 0.000000 0.000483 0.000000 0.004829 0.000000 1.000483 0.000966 \n", - "362 0.000836 0.000836 0.015050 0.000836 0.000836 1.000836 0.000000 \n", - "363 0.000000 0.000411 0.009453 0.000000 0.000000 1.000411 0.000000 \n", - "364 0.000000 0.000248 0.009406 0.000000 0.000000 1.000248 0.000000 \n", - "365 0.000000 0.000229 0.008249 0.000000 0.000000 1.000229 0.000000 \n", - "366 0.000000 0.000897 0.000897 0.008969 0.000897 1.000897 0.000897 \n", - "367 0.000000 0.001052 0.000000 0.011567 0.001052 1.001052 0.000000 \n", - "368 0.000000 0.001149 0.001149 0.000000 0.000000 1.001149 0.001149 \n", - "369 0.000000 0.000449 0.000897 0.018394 0.000000 1.000449 0.000449 \n", - "370 0.000000 0.000600 0.001801 0.017407 0.000000 1.000600 0.000600 \n", - "371 0.000000 0.000254 0.002542 0.014743 0.000000 1.000254 0.000000 \n", - "372 0.000000 0.000752 0.000000 0.015038 0.000000 1.000752 0.000752 \n", - "373 0.000000 0.000394 0.001577 0.011435 0.000000 1.000394 0.000000 \n", - "374 0.000000 0.000626 0.000000 0.019399 0.000000 1.000626 0.000000 \n", - "375 0.000000 0.001088 0.001088 0.000000 0.000000 1.001088 0.000000 \n", - "376 0.000000 0.001689 0.000000 0.000000 0.000000 1.001689 0.000000 \n", - "377 0.000000 0.001451 0.000000 0.005806 0.000000 1.001451 0.000000 \n", - "378 0.000000 0.001179 0.002358 0.014151 0.000000 1.001179 0.002358 \n", - "379 0.000000 0.001364 0.002729 0.012278 0.000000 1.001364 0.000000 \n", - "380 0.000000 0.001064 0.001064 0.029787 0.001064 1.001064 0.000000 \n", - "381 0.000000 0.000420 0.004200 0.012180 0.000840 1.000420 0.000000 \n", - "382 0.000000 0.001045 0.006270 0.000000 0.000000 1.001045 0.000000 \n", - "383 0.000000 0.001218 0.003654 0.000000 0.000000 1.001218 0.000000 \n", - "384 0.001304 0.001304 0.000000 0.027379 0.000000 1.001304 0.000000 \n", - "385 0.000000 0.001414 0.000000 0.001414 0.000000 1.001414 0.002829 \n", + " .format -> $ printf \n", + "0 0.001240 0.000000 0.000826 0.000000 \n", + "1 0.001157 0.000000 0.000771 0.000000 \n", + "2 0.001010 0.000000 0.000674 0.000000 \n", + "3 0.000000 0.005559 0.001235 0.000618 \n", + "4 0.000000 0.005823 0.001059 0.000529 \n", + "5 0.000000 0.006304 0.001146 0.000573 \n", + "6 0.000000 0.000000 0.000491 0.000000 \n", + "7 0.000000 0.000000 0.000947 0.000000 \n", + "8 0.000000 0.000000 0.000927 0.000000 \n", + "9 0.000000 0.000000 0.001462 0.000000 \n", + "10 0.000000 0.000000 0.001605 0.000000 \n", + "11 0.000000 0.000000 0.001403 0.000000 \n", + "12 0.000000 0.000000 0.001584 0.000000 \n", + "13 0.000000 0.000000 0.000436 0.000000 \n", + "14 0.000000 0.001229 0.001229 0.001844 \n", + "15 0.000000 0.006664 0.000888 0.001333 \n", + "16 0.000000 0.002185 0.001457 0.002185 \n", + "17 0.000000 0.000000 0.001491 0.000000 \n", + "18 0.000000 0.003335 0.000953 0.000000 \n", + "19 0.000000 0.008872 0.001267 0.001901 \n", + "20 0.000000 0.013870 0.001387 0.002080 \n", + "21 0.000000 0.000000 0.001355 0.002033 \n", + "22 0.000000 0.000000 0.000515 0.000773 \n", + "23 0.001670 0.000000 0.001114 0.000000 \n", + "24 0.000000 0.000583 0.001166 0.001748 \n", + "25 0.000000 0.000483 0.000966 0.001449 \n", + "26 0.000000 0.000369 0.000738 0.001107 \n", + "27 0.000000 0.000000 0.001287 0.000000 \n", + "28 0.000000 0.000000 0.001216 0.000000 \n", + "29 0.000000 0.000000 0.001527 0.000000 \n", "\n", - "[386 rows x 21 columns]" + "[30 rows x 26 columns]" + ] + } + ], + "prompt_number": 287 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn import metrics" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 288 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def create_xy(df, test_df startx, columny):\n", + " x_train = df.loc[:, startx:]\n", + " x_test = test_df.loc[:, startx:]\n", + " y_train = df[columny]\n", + " y_test = test_df[columny]\n", + " return x_train, x_test, y_train, y_test" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 1)", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m def create_xy(df, test_df startx, columny):\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], - "prompt_number": 212 + "prompt_number": 289 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train = df.loc[:,\"^\":]\n", + "x_test = test_df.loc[:, \"^\":]\n", + "y_train = df.Language\n", + "y_test = test_df.Language" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train, x_test, y_train, y_test = create_xy('let', 'Language')" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train" + ], + "language": "python", + "metadata": {}, + "outputs": [] }, { "cell_type": "code", @@ -6390,8 +2928,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 142 + "outputs": [] }, { "cell_type": "code", @@ -6404,8 +2941,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 143 + "outputs": [] }, { "cell_type": "code", @@ -6416,41 +2952,7 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " precision recall f1-score support\n", - "\n", - " clojure 0.33 0.25 0.29 4\n", - " haskell 0.20 0.33 0.25 3\n", - " java 0.00 0.00 0.00 2\n", - " javascript 0.25 0.25 0.25 4\n", - " ocaml 0.00 0.00 0.00 2\n", - " php 0.00 0.00 0.00 3\n", - " python 0.00 0.00 0.00 4\n", - " ruby 0.00 0.00 0.00 3\n", - " scala 0.00 0.00 0.00 2\n", - " scheme 0.00 0.00 0.00 3\n", - "\n", - "avg / total 0.10 0.10 0.10 30\n", - "\n", - "[[1 1 0 1 0 0 1 0 0 0]\n", - " [0 1 1 0 0 0 0 0 1 0]\n", - " [0 0 0 0 0 1 0 0 1 0]\n", - " [1 2 0 1 0 0 0 0 0 0]\n", - " [0 0 0 1 0 0 0 1 0 0]\n", - " [0 0 0 0 0 0 2 1 0 0]\n", - " [0 1 0 0 0 0 0 3 0 0]\n", - " [0 0 1 0 0 0 0 0 2 0]\n", - " [1 0 0 0 1 0 0 0 0 0]\n", - " [0 0 0 1 0 1 0 1 0 0]]\n", - "0.0964285714286\n" - ] - } - ], - "prompt_number": 213 + "outputs": [] }, { "cell_type": "code", @@ -6461,43 +2963,7 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " precision recall f1-score support\n", - "\n", - " clojure 0.33 0.25 0.29 4\n", - " haskell 0.00 0.00 0.00 3\n", - " java 0.00 0.00 0.00 2\n", - " javascript 0.00 0.00 0.00 4\n", - " ocaml 0.00 0.00 0.00 2\n", - " perl 0.00 0.00 0.00 0\n", - " php 0.00 0.00 0.00 3\n", - " python 0.00 0.00 0.00 4\n", - " ruby 0.00 0.00 0.00 3\n", - " scala 0.00 0.00 0.00 2\n", - " scheme 0.00 0.00 0.00 3\n", - "\n", - "avg / total 0.04 0.03 0.04 30\n", - "\n", - "[[1 0 0 2 0 0 1 0 0 0 0]\n", - " [0 0 0 1 0 0 0 0 1 1 0]\n", - " [0 0 0 0 1 0 1 0 0 0 0]\n", - " [1 0 0 0 0 2 1 0 0 0 0]\n", - " [0 0 0 1 0 0 0 0 1 0 0]\n", - " [0 0 0 0 0 0 0 0 0 0 0]\n", - " [0 0 0 0 0 0 0 3 0 0 0]\n", - " [0 0 0 0 0 1 0 0 2 1 0]\n", - " [0 1 0 0 0 1 0 0 0 0 1]\n", - " [1 0 0 0 1 0 0 0 0 0 0]\n", - " [0 0 0 0 0 0 2 0 1 0 0]]\n", - "0.0380952380952\n" - ] - } - ], - "prompt_number": 214 + "outputs": [] } ], "metadata": {} From a1a7a6d1a8207a25d78d18adb80b9c7bc9220bf1 Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Sun, 15 Feb 2015 14:28:01 -0500 Subject: [PATCH 6/9] created guess_lang.py, needs work on accuracy as well as function --- plc/Code Classifier.ipynb | 351 ++----- plc/classifier.py | 5 + plc/code_snippet.txt | 26 + plc/guess_lang.py | 84 ++ plc/split and test.ipynb | 211 ++++ plc/workbook.ipynb | 1963 ++----------------------------------- 6 files changed, 463 insertions(+), 2177 deletions(-) create mode 100644 plc/code_snippet.txt create mode 100644 plc/guess_lang.py create mode 100644 plc/split and test.ipynb diff --git a/plc/Code Classifier.ipynb b/plc/Code Classifier.ipynb index a7595b7..0a95450 100644 --- a/plc/Code Classifier.ipynb +++ b/plc/Code Classifier.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:aa35d7283b86da81f1512e49ff7045892454a5dc1ee2c5c3be305e6c1133bdc3" + "signature": "sha256:bb2286b7350a238ba5ac194e90f30571f08fb3a5d205269816ac9c27790329bc" }, "nbformat": 3, "nbformat_minor": 0, @@ -20,7 +20,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 82 + "prompt_number": 149 }, { "cell_type": "code", @@ -34,7 +34,15 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 83 + "prompt_number": 150 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "The lists below are the basis for my features. For the word_list and symbol_list, the program creates a feature based on the number of occurences of the word or symbol divided by the number of characters in the code snippet. For the endings list, if the code snippet ends with one of those strings, the feature receives a value of 10. If it doesn't have one of the listed endings, the feature is valued at 0." + ] }, { "cell_type": "code", @@ -43,14 +51,22 @@ "word_list = ['let', 'end', 'defn', 'function', 'fun', 'return', 'def', 'return', 'check', 'make', '->', '.format',\n", " 'define', '::', 'done', 'type', 'rescue', 'print', 'elif', 'clone', 'display', '$format', 'echo', 'str',\n", " 'join', '&&', 'val', 'Nil', 'object', '<-', '--', 'lambda', 'var', '//', 'tmpl', 'public function',\n", - " 'stdlib', '=>', ]\n", + " 'stdlib', '=>', 'final', 'case', 'impl']\n", "symbol_list = ['$', '^', ',', ';', '&', '|', '!', '*', '@', '#']\n", "endings = ['end', ')', '}']" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 84 + "prompt_number": 151 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "The following function creates the data frame of features based on the corpus of code snippets pulled from the Computer Language Benchmarks game." + ] }, { "cell_type": "code", @@ -83,7 +99,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 85 + "prompt_number": 152 }, { "cell_type": "code", @@ -94,7 +110,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 86 + "prompt_number": 153 }, { "cell_type": "code", @@ -105,7 +121,15 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 87 + "prompt_number": 154 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "The following function creates the data frame of features based on the code snippets provided for testing the classifier." + ] }, { "cell_type": "code", @@ -135,7 +159,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 88 + "prompt_number": 155 }, { "cell_type": "code", @@ -146,7 +170,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 89 + "prompt_number": 156 }, { "cell_type": "code", @@ -157,29 +181,27 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 90 + "prompt_number": 157 }, { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", + "cell_type": "heading", + "level": 3, "metadata": {}, - "outputs": [], - "prompt_number": 90 + "source": [ + "I used a Decision Tree Classifier and a Gaussian Naive Bayes Classifier. The Gaussian NB classifier scored higher, and thus I used that in my guess_lang.py program to be run from the console. I also made a random guesser. This is included as a morale booster for whenever I feel like my classifiers are not sufficiently effective." + ] }, { "cell_type": "code", "collapsed": false, "input": [ "from sklearn.naive_bayes import GaussianNB\n", - "from sklearn.tree import DecisionTreeClassifier\n", - "from sklearn.naive_bayes import MultinomialNB " + "from sklearn.tree import DecisionTreeClassifier" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 91 + "prompt_number": 158 }, { "cell_type": "code", @@ -198,33 +220,35 @@ " precision recall f1-score support\n", "\n", " clojure 1.00 0.75 0.86 4\n", - " haskell 0.75 1.00 0.86 3\n", - " java 1.00 1.00 1.00 2\n", - " javascript 0.50 0.75 0.60 4\n", - " ocaml 1.00 0.50 0.67 2\n", - " php 1.00 0.67 0.80 3\n", - " python 1.00 0.25 0.40 4\n", - " ruby 0.40 0.67 0.50 3\n", - " scala 0.50 1.00 0.67 2\n", + " haskell 0.50 0.67 0.57 3\n", + " java 1.00 0.50 0.67 2\n", + " javascript 1.00 0.50 0.67 4\n", + " ocaml 1.00 1.00 1.00 2\n", + " perl 0.00 0.00 0.00 0\n", + " php 1.00 0.33 0.50 3\n", + " python 0.40 0.50 0.44 4\n", + " ruby 0.50 0.67 0.57 3\n", + " scala 0.40 1.00 0.57 2\n", " scheme 0.00 0.00 0.00 3\n", "\n", - "avg / total 0.71 0.63 0.62 30\n", + "avg / total 0.68 0.57 0.58 30\n", "\n", - "[[3 0 0 0 0 0 0 1 0 0]\n", - " [0 3 0 0 0 0 0 0 0 0]\n", - " [0 0 2 0 0 0 0 0 0 0]\n", - " [0 0 0 3 0 0 0 0 1 0]\n", - " [0 1 0 0 1 0 0 0 0 0]\n", - " [0 0 0 0 0 2 0 0 1 0]\n", - " [0 0 0 1 0 0 1 1 0 1]\n", - " [0 0 0 0 0 0 0 2 0 1]\n", - " [0 0 0 0 0 0 0 0 2 0]\n", - " [0 0 0 2 0 0 0 1 0 0]]\n", - "0.618888888889\n" + "[[3 0 0 0 0 0 0 0 1 0 0]\n", + " [0 2 0 0 0 0 0 1 0 0 0]\n", + " [0 1 1 0 0 0 0 0 0 0 0]\n", + " [0 0 0 2 0 0 0 1 0 1 0]\n", + " [0 0 0 0 2 0 0 0 0 0 0]\n", + " [0 0 0 0 0 0 0 0 0 0 0]\n", + " [0 0 0 0 0 1 1 0 0 1 0]\n", + " [0 0 0 0 0 1 0 2 1 0 0]\n", + " [0 0 0 0 0 1 0 0 2 0 0]\n", + " [0 0 0 0 0 0 0 0 0 2 0]\n", + " [0 1 0 0 0 0 0 1 0 1 0]]\n", + "0.575925925926\n" ] } ], - "prompt_number": 92 + "prompt_number": 159 }, { "cell_type": "code", @@ -244,17 +268,17 @@ "\n", " clojure 1.00 1.00 1.00 4\n", " haskell 1.00 0.67 0.80 3\n", - " java 1.00 1.00 1.00 2\n", + " java 0.67 1.00 0.80 2\n", " javascript 1.00 0.25 0.40 4\n", " ocaml 1.00 1.00 1.00 2\n", " perl 0.00 0.00 0.00 0\n", - " php 0.33 1.00 0.50 3\n", + " php 0.38 1.00 0.55 3\n", " python 1.00 1.00 1.00 4\n", " ruby 1.00 0.33 0.50 3\n", " scala 0.00 0.00 0.00 2\n", " scheme 1.00 1.00 1.00 3\n", "\n", - "avg / total 0.87 0.73 0.73 30\n", + "avg / total 0.85 0.73 0.72 30\n", "\n", "[[4 0 0 0 0 0 0 0 0 0 0]\n", " [0 2 0 0 0 0 0 0 0 1 0]\n", @@ -265,240 +289,13 @@ " [0 0 0 0 0 0 3 0 0 0 0]\n", " [0 0 0 0 0 0 0 4 0 0 0]\n", " [0 0 0 0 0 1 1 0 1 0 0]\n", - " [0 0 0 0 0 0 2 0 0 0 0]\n", + " [0 0 1 0 0 0 1 0 0 0 0]\n", " [0 0 0 0 0 0 0 0 0 0 3]]\n", - "0.733333333333\n" - ] - } - ], - "prompt_number": 93 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_string = \"\"\"import re\n", - "\n", - "def character_counter(code, char):\n", - " counter = 0\n", - " for _ in code:\n", - " if _ == char:\n", - " counter+=1\n", - " return counter\n", - "\n", - "def character_ratio(code, char):\n", - " value = character_counter(code, char)/len(code)\n", - " return value\n", - "\n", - "def string_finder(string, code):\n", - " value = len(re.findall(string, code))\n", - " return value\n", - "\n", - "def string_ratio(string, code):\n", - " value = string_finder(string, code)/len(code)\n", - " return value\n", - "\n", - "def string_end(string, code):\n", - " if code.endswith(string):\n", - " return 10\n", - " else:\n", - " return 0\"\"\"" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 94 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "test_list=[test_string]" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 95 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "xdf = pd.DataFrame(test_list, index=range(1), columns=['Code'])" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 96 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 96 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def x_data_frame_generator(df):\n", - " for string in word_list:\n", - " def sub_function(code):\n", - " x = string_ratio(string, code)\n", - " return x\n", - " df[string] = df.Code.apply(sub_function)\n", - " for char in symbol_list:\n", - " def sub_function2(code):\n", - " y = character_ratio(code, char)\n", - " return y\n", - " df[char] = df.Code.apply(sub_function2)\n", - " for ending in endings:\n", - " def sub_function3(code):\n", - " z = string_end(ending, code)\n", - " return z\n", - " df['_' + ending] = df.Code.apply(sub_function3)\n", - " return df" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 97 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "xdf = x_data_frame_generator(xdf)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 98 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "xdf" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
Codeletenddefnfunctionfunreturndefcheckmake...;&|!*@#_end_)_}
0 import re\\n\\ndef character_counter(code, char)... 0 0.003663 0 0 0 0.010989 0.009158 0 0... 0 0 0 0 0 0 0 0 0 0
\n", - "

1 rows \u00d7 51 columns

\n", - "
" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 99, - "text": [ - " Code let end defn \\\n", - "0 import re\\n\\ndef character_counter(code, char)... 0 0.003663 0 \n", - "\n", - " function fun return def check make ... ; & | ! * @ # \\\n", - "0 0 0 0.010989 0.009158 0 0 ... 0 0 0 0 0 0 0 \n", - "\n", - " _end _) _} \n", - "0 0 0 0 \n", - "\n", - "[1 rows x 51 columns]" - ] - } - ], - "prompt_number": 99 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "n = gauss.predict_proba(xdf.loc[:, 'let':])" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 100 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "metadata": {}, - "output_type": "pyout", - "prompt_number": 101, - "text": [ - "array([[ 0.00000000e+000, 0.00000000e+000, 0.00000000e+000,\n", - " 0.00000000e+000, 0.00000000e+000, 9.05283150e-071,\n", - " 9.48911785e-060, 1.00000000e+000, 1.13311483e-064,\n", - " 1.47138138e-306, 0.00000000e+000]])" + "0.724545454545\n" ] } ], - "prompt_number": 101 + "prompt_number": 160 }, { "cell_type": "code", @@ -512,13 +309,13 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 102, + "prompt_number": 166, "text": [ - "0.13333333333333333" + "0.06666666666666667" ] } ], - "prompt_number": 102 + "prompt_number": 166 } ], "metadata": {} diff --git a/plc/classifier.py b/plc/classifier.py index af69ddd..0539ca8 100644 --- a/plc/classifier.py +++ b/plc/classifier.py @@ -15,3 +15,8 @@ def run_classifier(clf, x_train, x_test, y_train, y_test): print(metrics.classification_report(y_test, predicted)) print(metrics.confusion_matrix(y_test, predicted)) print(metrics.f1_score(y_test, predicted)) + +def create_train(df, startx, columny): + x_train = df.loc[:, startx:] + y_train = df[columny] + return x_train, y_train diff --git a/plc/code_snippet.txt b/plc/code_snippet.txt new file mode 100644 index 0000000..3ef89f9 --- /dev/null +++ b/plc/code_snippet.txt @@ -0,0 +1,26 @@ +class Utils + + def self.seconds_to_string(s) + + # d = days, h = hours, m = minutes, s = seconds + m = (s / 60).floor + s = s % 60 + h = (m / 60).floor + m = m % 60 + d = (h / 24).floor + h = h % 24 + + output = "#{s} second#{Utils.pluralize(s)}" if (s > 0) + output = "#{m} minute#{Utils.pluralize(m)}, #{s} second#{Utils.pluralize(s)}" if (m > 0) + output = "#{h} hour#{Utils.pluralize(h)}, #{m} minute#{Utils.pluralize(m)}, #{s} second#{Utils.pluralize(s)}" if (h > 0) + output = "#{d} day#{Utils.pluralize(d)}, #{h} hour#{Utils.pluralize(h)}, #{m} minute#{Utils.pluralize(m)}, #{s} second#{Utils.pluralize(s)}" if (d > 0) + + return output + end + + def self.pluralize number + return "s" unless number == 1 + return "" + end + +end diff --git a/plc/guess_lang.py b/plc/guess_lang.py new file mode 100644 index 0000000..1f0f5c9 --- /dev/null +++ b/plc/guess_lang.py @@ -0,0 +1,84 @@ +from data_load import* +from features import* +from classifier import* + +from sklearn.naive_bayes import GaussianNB + +import os +import pandas as pd +import re +import random + +word_list = ['let', 'end', 'defn', 'function', 'fun', 'return', 'def', 'return', 'check', 'make', '->', '.format', + 'define', '::', 'done', 'type', 'rescue', 'print', 'elif', 'clone', 'display', '$format', 'echo', 'str', + 'join', '&&', 'val', 'Nil', 'object', '<-', '--', 'lambda', 'var', '//', 'tmpl', 'public function', + 'stdlib', '=>', 'final', 'case', 'impl'] +symbol_list = ['$', '^', ',', ';', '&', '|', '!', '*', '@', '#'] +endings = ['end', ')', '}'] + +def data_frame_generator(): + codelist = code_sucker() + typelist = type_getter() + df = pd.DataFrame(typelist, index=range(386)) + df.columns = ["Language"] + df["Code"] = codelist + df['Language'] = df.Language.apply(lambda x:x.lower()) + for string in word_list: + def sub_function(code): + x = string_ratio(string, code) + return x + df[string] = df.Code.apply(sub_function) + for char in symbol_list: + def sub_function2(code): + y = character_ratio(code, char) + return y + df[char] = df.Code.apply(sub_function2) + for ending in endings: + def sub_function3(code): + z = string_end(ending, code) + return z + df['_' + ending] = df.Code.apply(sub_function3) + return df + +def x_data_frame_generator(): + test_list = [] + with open("code_snippet.txt") as test_file: + test_list.append(test_file.read()) + df = pd.DataFrame(test_list, index=range(1), columns=['Code']) + for string in word_list: + def sub_function(code): + x = string_ratio(string, code) + return x + df[string] = df.Code.apply(sub_function) + for char in symbol_list: + def sub_function2(code): + y = character_ratio(code, char) + return y + df[char] = df.Code.apply(sub_function2) + for ending in endings: + def sub_function3(code): + z = string_end(ending, code) + return z + df['_' + ending] = df.Code.apply(sub_function3) + return df + + +def probability_display(df): + n = gauss.predict_proba(xdf.loc[:, 'let':]) + prob_list = n.tolist()[0] + programs_list = ['Clojure', 'Haskell', 'Java', 'Javascript', 'Ocaml', 'Perl', 'Php', 'Python', 'Ruby', 'Scala', 'Scheme'] + percent = 0 + for item in prob_list: + if item > percent: + percent = item + idx = prob_list.index(item) + print("The code snippet is written in {}".format(programs_list[idx])) + print("Confidence: {}%".format(percent*100)) + +if __name__ == "__main__": + df = data_frame_generator() + gauss = GaussianNB() + x_train, y_train = create_train(df, word_list[0], 'Language') + gauss.fit(x_train, y_train) + xdf = x_data_frame_generator() + probability_display(xdf) diff --git a/plc/split and test.ipynb b/plc/split and test.ipynb new file mode 100644 index 0000000..fe1e4a7 --- /dev/null +++ b/plc/split and test.ipynb @@ -0,0 +1,211 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:d92b8193818cf4fb449ca66b377d7ceb050fe6af17428898526d4210e2ddb23a" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from data_load import*\n", + "from features import*\n", + "from classifier import*\n", + "from guess_lang import*" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 6 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import pandas as pd\n", + "import re\n", + "import random" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 7 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "word_list = ['let', 'end', 'defn', 'function', 'fun', 'return', 'def', 'return', 'check', 'make', '->', '.format',\n", + " 'define', '::', 'done', 'type', 'rescue', 'print', 'elif', 'clone', 'display', '$format', 'echo', 'str',\n", + " 'join', '&&', 'val', 'Nil', 'object', '<-', '--', 'lambda', 'var', '//', 'tmpl', 'public function',\n", + " 'stdlib', '=>', 'final', 'case', 'impl']\n", + "symbol_list = ['$', '^', ',', ';', '&', '|', '!', '*', '@', '#']\n", + "endings = ['end', ')', '}']" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn.cross_validation import train_test_split\n", + "from sklearn import metrics" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "df = data_frame_generator()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 10 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "xdata = df.loc[:, 'let':]\n", + "ydata = df['Language']" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x_train, x_test, y_train, y_test = train_test_split(xdata, ydata, test_size=0.3, random_state=0)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 12 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sklearn.naive_bayes import GaussianNB\n", + "from sklearn.tree import DecisionTreeClassifier" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 13 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "tree = DecisionTreeClassifier()\n", + "run_classifier(tree, x_train, x_test, y_train, y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " precision recall f1-score support\n", + "\n", + " clojure 1.00 1.00 1.00 11\n", + " haskell 0.80 0.80 0.80 10\n", + " java 1.00 0.80 0.89 15\n", + " javascript 0.70 0.88 0.78 8\n", + " ocaml 0.75 1.00 0.86 9\n", + " perl 1.00 0.82 0.90 11\n", + " php 0.82 1.00 0.90 9\n", + " python 0.77 1.00 0.87 10\n", + " ruby 1.00 0.83 0.91 12\n", + " scala 1.00 0.93 0.96 14\n", + " scheme 1.00 0.71 0.83 7\n", + "\n", + "avg / total 0.91 0.89 0.89 116\n", + "\n", + "[[11 0 0 0 0 0 0 0 0 0 0]\n", + " [ 0 8 0 0 1 0 0 1 0 0 0]\n", + " [ 0 0 12 3 0 0 0 0 0 0 0]\n", + " [ 0 1 0 7 0 0 0 0 0 0 0]\n", + " [ 0 0 0 0 9 0 0 0 0 0 0]\n", + " [ 0 0 0 0 0 9 2 0 0 0 0]\n", + " [ 0 0 0 0 0 0 9 0 0 0 0]\n", + " [ 0 0 0 0 0 0 0 10 0 0 0]\n", + " [ 0 0 0 0 0 0 0 2 10 0 0]\n", + " [ 0 1 0 0 0 0 0 0 0 13 0]\n", + " [ 0 0 0 0 2 0 0 0 0 0 5]]\n", + "0.889563785928\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "gauss = GaussianNB()\n", + "run_classifier(gauss, x_train, x_test, y_train, y_test)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " precision recall f1-score support\n", + "\n", + " clojure 0.92 1.00 0.96 11\n", + " haskell 0.91 1.00 0.95 10\n", + " java 1.00 0.87 0.93 15\n", + " javascript 0.83 0.62 0.71 8\n", + " ocaml 1.00 1.00 1.00 9\n", + " perl 0.92 1.00 0.96 11\n", + " php 0.82 1.00 0.90 9\n", + " python 1.00 0.70 0.82 10\n", + " ruby 0.77 0.83 0.80 12\n", + " scala 0.87 0.93 0.90 14\n", + " scheme 1.00 1.00 1.00 7\n", + "\n", + "avg / total 0.91 0.91 0.90 116\n", + "\n", + "[[11 0 0 0 0 0 0 0 0 0 0]\n", + " [ 0 10 0 0 0 0 0 0 0 0 0]\n", + " [ 0 0 13 1 0 0 1 0 0 0 0]\n", + " [ 0 0 0 5 0 0 1 0 0 2 0]\n", + " [ 0 0 0 0 9 0 0 0 0 0 0]\n", + " [ 0 0 0 0 0 11 0 0 0 0 0]\n", + " [ 0 0 0 0 0 0 9 0 0 0 0]\n", + " [ 0 0 0 0 0 0 0 7 3 0 0]\n", + " [ 1 1 0 0 0 0 0 0 10 0 0]\n", + " [ 0 0 0 0 0 1 0 0 0 13 0]\n", + " [ 0 0 0 0 0 0 0 0 0 0 7]]\n", + "0.902561751579\n" + ] + } + ], + "prompt_number": 15 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/plc/workbook.ipynb b/plc/workbook.ipynb index 6c4c68c..46b5484 100644 --- a/plc/workbook.ipynb +++ b/plc/workbook.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:026ede5bff2ce1025c2313e6c6dd589dcb79c50220a5e50673fd0d724593951e" + "signature": "sha256:95e12a41859fa3e312230e9c8cd06933a5646f54cec92e1fc473f5eecb3bbc3e" }, "nbformat": 3, "nbformat_minor": 0, @@ -19,7 +19,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 249 + "prompt_number": 290 }, { "cell_type": "code", @@ -69,7 +69,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 250 + "prompt_number": 291 }, { "cell_type": "code", @@ -85,7 +85,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 251 + "prompt_number": 292 }, { "cell_type": "code", @@ -104,7 +104,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 252 + "prompt_number": 293 }, { "cell_type": "code", @@ -115,7 +115,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 253 + "prompt_number": 294 }, { "cell_type": "code", @@ -129,13 +129,13 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 254, + "prompt_number": 295, "text": [ "386" ] } ], - "prompt_number": 254 + "prompt_number": 295 }, { "cell_type": "code", @@ -156,7 +156,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 255 + "prompt_number": 296 }, { "cell_type": "code", @@ -167,7 +167,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 256 + "prompt_number": 297 }, { "cell_type": "code", @@ -181,13 +181,13 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 257, + "prompt_number": 298, "text": [ "386" ] } ], - "prompt_number": 257 + "prompt_number": 298 }, { "cell_type": "code", @@ -198,7 +198,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 258 + "prompt_number": 299 }, { "cell_type": "code", @@ -210,7 +210,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 259 + "prompt_number": 300 }, { "cell_type": "code", @@ -221,7 +221,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 260 + "prompt_number": 301 }, { "cell_type": "code", @@ -556,7 +556,7 @@ ], "metadata": {}, "output_type": "pyout", - "prompt_number": 261, + "prompt_number": 302, "text": [ " Language Code\n", "0 clojure ;; The Computer Language Benchmarks Game\\n;; h...\n", @@ -625,7 +625,7 @@ ] } ], - "prompt_number": 261 + "prompt_number": 302 }, { "cell_type": "code", @@ -639,13 +639,13 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 262, + "prompt_number": 303, "text": [ "'--\\n-- The Computer Language Benchmarks Game\\n-- http://benchmarksgame.alioth.debian.org/\\n--\\n-- Contributed by Don Stewart\\n--\\n\\nimport System.Environment\\nimport Data.Bits\\nimport Text.Printf\\n\\n--\\n-- an artificially strict tree. \\n--\\n-- normally you would ensure the branches are lazy, but this benchmark\\n-- requires strict allocation.\\n--\\ndata Tree = Nil | Node !Int !Tree !Tree\\n\\nminN = 4\\n\\nio s n t = printf \"%s of depth %d\\\\t check: %d\\\\n\" s n t\\n\\nmain = do\\n n <- getArgs >>= readIO . head\\n let maxN = max (minN + 2) n\\n stretchN = maxN + 1\\n\\n -- stretch memory tree\\n let c = check (make 0 stretchN)\\n io \"stretch tree\" stretchN c\\n\\n -- allocate a long lived tree\\n let !long = make 0 maxN\\n\\n -- allocate, walk, and deallocate many bottom-up binary trees\\n let vs = depth minN maxN\\n mapM_ (\\\\((m,d,i)) -> io (show m ++ \"\\\\t trees\") d i) vs\\n\\n -- confirm the the long-lived binary tree still exists\\n io \"long lived tree\" maxN (check long)\\n\\n-- generate many trees\\ndepth :: Int -> Int -> [(Int,Int,Int)]\\ndepth d m\\n | d <= m = (2*n,d,sumT d n 0) : depth (d+2) m\\n | otherwise = []\\n where n = 1 `shiftL` (m - d + minN)\\n\\n-- allocate and check lots of trees\\nsumT :: Int -> Int -> Int -> Int\\nsumT d 0 t = t\\nsumT d i t = sumT d (i-1) (t + a + b)\\n where a = check (make i d)\\n b = check (make (-i) d)\\n\\n-- traverse the tree, counting up the nodes\\ncheck :: Tree -> Int\\ncheck Nil = 0\\ncheck (Node i l r) = i + check l - check r\\n\\n-- build a tree\\nmake :: Int -> Int -> Tree\\nmake i 0 = Node i Nil Nil\\nmake i d = Node i (make (i2-1) d2) (make i2 d2)\\n where i2 = 2*i; d2 = d-1\\n'" ] } ], - "prompt_number": 262 + "prompt_number": 303 }, { "cell_type": "code", @@ -657,7 +657,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 263 + "prompt_number": 304 }, { "cell_type": "code", @@ -678,7 +678,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 264 + "prompt_number": 305 }, { "cell_type": "code", @@ -701,7 +701,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 265 + "prompt_number": 306 }, { "cell_type": "code", @@ -718,7 +718,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 266 + "prompt_number": 307 }, { "cell_type": "code", @@ -729,7 +729,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 267 + "prompt_number": 308 }, { "cell_type": "code", @@ -741,7 +741,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 268 + "prompt_number": 309 }, { "cell_type": "code", @@ -764,7 +764,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 269 + "prompt_number": 310 }, { "cell_type": "code", @@ -775,7 +775,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 270 + "prompt_number": 311 }, { "cell_type": "code", @@ -786,7 +786,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 271 + "prompt_number": 312 }, { "cell_type": "code", @@ -795,7 +795,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 271 + "prompt_number": 312 }, { "cell_type": "code", @@ -806,7 +806,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 272 + "prompt_number": 313 }, { "cell_type": "code", @@ -822,7 +822,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 273 + "prompt_number": 314 }, { "cell_type": "code", @@ -834,17 +834,26 @@ "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", - "text": [ - "ruby\n", - "\n", - "(define add1\n", - " (lambda (n) (+ n 1)))\n" + "ename": "KeyError", + "evalue": "'Code'", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcode_lookup\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtest_df\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m13\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36mcode_lookup\u001b[0;34m(df, num)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mcode_lookup\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnum\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mcodeblob\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mTextBlob\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miloc\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mnum\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Code'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miloc\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mnum\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Language'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcodeblob\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/core/series.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 507\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__getitem__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 508\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 509\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 510\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 511\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0misscalar\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/core/index.py\u001b[0m in \u001b[0;36mget_value\u001b[0;34m(self, series, key)\u001b[0m\n\u001b[1;32m 1429\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mInvalidIndexError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1430\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1431\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0me1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1432\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# pragma: no cover\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1433\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0me1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/core/index.py\u001b[0m in \u001b[0;36mget_value\u001b[0;34m(self, series, key)\u001b[0m\n\u001b[1;32m 1415\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1416\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1417\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1418\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1419\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m0\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minferred_type\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'integer'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'boolean'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/index.so\u001b[0m in \u001b[0;36mpandas.index.IndexEngine.get_value (pandas/index.c:3096)\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/index.so\u001b[0m in \u001b[0;36mpandas.index.IndexEngine.get_value (pandas/index.c:2827)\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/index.so\u001b[0m in \u001b[0;36mpandas.index.IndexEngine.get_loc (pandas/index.c:3687)\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/hashtable.so\u001b[0m in \u001b[0;36mpandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12310)\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/charting/lib/python3.4/site-packages/pandas/hashtable.so\u001b[0m in \u001b[0;36mpandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12261)\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'Code'" ] } ], - "prompt_number": 274 + "prompt_number": 315 }, { "cell_type": "code", @@ -860,8 +869,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 275 + "outputs": [] }, { "cell_type": "code", @@ -880,8 +888,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 276 + "outputs": [] }, { "cell_type": "code", @@ -891,8 +898,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 277 + "outputs": [] }, { "cell_type": "code", @@ -902,8 +908,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 278 + "outputs": [] }, { "cell_type": "code", @@ -913,46 +918,7 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "metadata": {}, - "output_type": "pyout", - "prompt_number": 279, - "text": [ - "['(defn cf-settings\\n \"Setup settings for campfire. Required information is your api-token, ssl connection\\n true or false, and your campfire sub-domain.\"\\n [token ssl sub-domain]\\n {:api-token token, :ssl ssl, :sub-domain sub-domain})\\n\\n(defn room\\n \"Sets up the room to send events too. Pass in the settings created with cf-settings\\n and the room name\"\\n [settings room-name]\\n (cf/room-by-name settings room-name))\\n\\n(defn campfire_message\\n \"Formats an event into a string\"\\n [e]\\n (str (join \" \" [\"Riemann alert on\" (str (:host e)) \"-\" (str (:service e)) \"is\" (upper-case (str (:state e))) \"- Description:\" (str (:description e))])))\\n\\n(defn campfire\\n \"Creates an adaptor to forward events to campfire. The campfire event will\\n contain the host, state, service, metric and description.\\n Tested with:\\n (streams\\n (by [:host, :service]\\n (let [camp (campfire \\\\\"token\\\\\", true, \\\\\"sub-domain\\\\\", \\\\\"room\\\\\")]\\n camp)))\"\\n [token ssl sub-domain room-name]\\n (fn [e]\\n (let [message_string (campfire_message e)\\n settings (cf-settings token ssl sub-domain)]\\n (cf/message (room settings room-name) message_string))))',\n", - " '(ns my-cli.core)\\n\\n(defn -main [& args]\\n (println \"My CLI received arguments:\" args))\\n\\n(defn add-main [& args]\\n (->> (map #(Integer/parseInt %) args)\\n (reduce + 0)\\n (println \"The sum is:\")))',\n", - " '(extend-type String\\n Person\\n (first-name [s] (first (clojure.string/split s #\" \")))\\n (last-name [s] (second (clojure.string/split s #\" \"))))',\n", - " '(require \\'[overtone.live :as overtone])\\n\\n(defn note [timing pitch] {:time timing :pitch pitch})\\n\\n(def melody\\n (let [pitches\\n [0 0 0 1 2\\n ; Row, row, row your boat,\\n 2 1 2 3 4\\n ; Gently down the stream,\\n 7 7 7 4 4 4 2 2 2 0 0 0\\n ; (take 4 (repeat \"merrily\"))\\n 4 3 2 1 0]\\n ; Life is but a dream!\\n durations\\n [1 1 2/3 1/3 1\\n 2/3 1/3 2/3 1/3 2\\n 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3\\n 2/3 1/3 2/3 1/3 2]\\n times (reductions + 0 durations)]\\n (map note times pitches)))',\n", - " 'from pkgutil import iter_modules\\nfrom subprocess import call\\n\\ndependencies = {\\n \"Crypto\": \"crypto\",\\n \"dpkt\": \"dpkt\",\\n \"IPy\": \"ipy\",\\n \"pcap\": \"pypcap\"\\n}\\n\\ninstalled, missing_pkgs = [pkg[1] for pkg in iter_modules()], []\\n\\nfor module, pkg in dependencies.items():\\n if module not in installed:\\n print(\"dshell requires {}\".format(module))\\n missing_pkgs.append(\"python-{}\".format(pkg))\\n else:\\n print(\"{} is installed\".format(module))\\n\\nif missing_pkgs:\\n cmd = [\"sudo\", \"apt-get\", \"install\"] + missing_pkgs\\n\\n print(\" \".join(cmd))\\n call(cmd)\\n\\ncall([\"make\", \"all\"])',\n", - " \"import re\\nimport subprocess\\n\\ndef cmd_keymap_table():\\n return subprocess.Popen(\\n ['xmodmap','-pk'], stdout=subprocess.PIPE).communicate()[0]\\n\\ndef cmd_modifier_map():\\n return subprocess.Popen(\\n ['xmodmap','-pm'], stdout=subprocess.PIPE).communicate()[0]\\n\\ndef get_keymap_table():\\n keymap = {}\\n\\n keymap_table = cmd_keymap_table()\\n\\n re_line = re.compile(r'0x\\\\w+')\\n for line in keymap_table.split('\\\\n')[1:]:\\n if len(line) > 0:\\n keycode = re.search(r'\\\\s+(\\\\d+).*', line)\\n if keycode:\\n new_keysyms = []\\n keycode = int(keycode.group(1))\\n keysyms = re_line.findall(line)\\n # When you press only one key\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[0], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n # When you press a key plus Shift key\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[1], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n # When you press a key plus meta (dead keys)\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[4], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n # When you press a key plus meta plus Shift key\\n unicode_char = ''\\n try:\\n unicode_char = unichr(int(keysyms[5], 16))\\n except:\\n unicode_char = ''\\n if unicode_char == u'\\\\x00':\\n unicode_char = ''\\n new_keysyms.append(unicode_char)\\n\\n \\t\\t#keymap[keycode-8] = new_keysyms\\n \\t\\tkeymap[keycode] = new_keysyms\\n\\n return keymap\\n\\ndef get_modifier_map():\\n modifiers = {}\\n\\n modifier_map = cmd_modifier_map()\\n\\n re_line = re.compile(r'(0x\\\\w+)')\\n for line in modifier_map.split('\\\\n')[1:]:\\n if len(line) > 0:\\n mod_name = re.match(r'(\\\\w+).*', line)\\n if mod_name:\\n mod_name = mod_name.group(1)\\n keycodes = re_line.findall(line)\\n # Convert key codes from hex to dec for use them\\n # with the keymap table\\n keycodes =[ int(kc, 16) for kc in keycodes]\\n \\n modifiers[mod_name] = keycodes\\n\\n return modifiers\",\n", - " 'class NoSuchService(Exception):\\n def __init__(self, name):\\n self.name = name\\n self.msg = \"No such service: %s\" % self.name\\n\\n def __str__(self):\\n return self.msg\\n\\n\\nclass ConfigurationError(Exception):\\n def __init__(self, msg):\\n self.msg = msg\\n\\n def __str__(self):\\n return self.msg',\n", - " 'from collections import namedtuple\\nimport functools\\nimport heapq\\nimport itertools\\nimport logging\\nimport Queue\\nimport random\\nimport threading\\n\\n# data types\\nProposal = namedtuple(\\'Proposal\\', [\\'caller\\', \\'client_id\\', \\'input\\'])\\nBallot = namedtuple(\\'Ballot\\', [\\'n\\', \\'leader\\'])\\n\\n# message types\\nAccepted = namedtuple(\\'Accepted\\', [\\'slot\\', \\'ballot_num\\'])\\nAccept = namedtuple(\\'Accept\\', [\\'slot\\', \\'ballot_num\\', \\'proposal\\'])\\nDecision = namedtuple(\\'Decision\\', [\\'slot\\', \\'proposal\\'])\\nInvoked = namedtuple(\\'Invoked\\', [\\'client_id\\', \\'output\\'])\\nInvoke = namedtuple(\\'Invoke\\', [\\'caller\\', \\'client_id\\', \\'input_value\\'])\\nJoin = namedtuple(\\'Join\\', [])\\nActive = namedtuple(\\'Active\\', [])\\nPrepare = namedtuple(\\'Prepare\\', [\\'ballot_num\\'])\\nPromise = namedtuple(\\'Promise\\', [\\'ballot_num\\', \\'accepted_proposals\\'])\\nPropose = namedtuple(\\'Propose\\', [\\'slot\\', \\'proposal\\'])\\nWelcome = namedtuple(\\'Welcome\\', [\\'state\\', \\'slot\\', \\'decisions\\'])\\nDecided = namedtuple(\\'Decided\\', [\\'slot\\'])\\nPreempted = namedtuple(\\'Preempted\\', [\\'slot\\', \\'preempted_by\\'])\\nAdopted = namedtuple(\\'Adopted\\', [\\'ballot_num\\', \\'accepted_proposals\\'])\\nAccepting = namedtuple(\\'Accepting\\', [\\'leader\\'])\\n\\n# constants - these times should really be in terms of average round-trip time\\nJOIN_RETRANSMIT = 0.7\\nCATCHUP_INTERVAL = 0.6\\nACCEPT_RETRANSMIT = 1.0\\nPREPARE_RETRANSMIT = 1.0\\nINVOKE_RETRANSMIT = 0.5\\nLEADER_TIMEOUT = 1.0\\nNULL_BALLOT = Ballot(-1, -1) # sorts before all real ballots\\nNOOP_PROPOSAL = Proposal(None, None, None) # no-op to fill otherwise empty slots\\n\\nclass Node(object):\\n unique_ids = itertools.count()\\n\\n def __init__(self, network, address):\\n self.network = network\\n self.address = address or \\'N%d\\' % self.unique_ids.next()\\n self.logger = SimTimeLogger(logging.getLogger(self.address), {\\'network\\': self.network})\\n self.logger.info(\\'starting\\')\\n self.roles = []\\n self.send = functools.partial(self.network.send, self)\\n\\n def register(self, roles):\\n self.roles.append(roles)\\n\\n def unregister(self, roles):\\n self.roles.remove(roles)\\n\\n def receive(self, sender, message):\\n handler_name = \\'do_%s\\' % type(message).__name__\\n\\n for comp in self.roles[:]:\\n if not hasattr(comp, handler_name):\\n continue\\n comp.logger.debug(\"received %s from %s\", message, sender)\\n fn = getattr(comp, handler_name)\\n fn(sender=sender, **message._asdict())\\n\\nclass Timer(object):\\n\\n def __init__(self, expires, address, callback):\\n self.expires = expires\\n self.address = address\\n self.callback = callback\\n self.cancelled = False\\n\\n def __cmp__(self, other):\\n return cmp(self.expires, other.expires)\\n\\n def cancel(self):\\n self.cancelled = True\\n\\nclass Network(object):\\n PROP_DELAY = 0.03\\n PROP_JITTER = 0.02\\n DROP_PROB = 0.05\\n\\n def __init__(self, seed):\\n self.nodes = {}\\n self.rnd = random.Random(seed)\\n self.timers = []\\n self.now = 1000.0\\n\\n def new_node(self, address=None):\\n node = Node(self, address=address)\\n self.nodes[node.address] = node\\n return node\\n\\n def run(self):\\n while self.timers:\\n next_timer = self.timers[0]\\n if next_timer.expires > self.now:\\n self.now = next_timer.expires\\n heapq.heappop(self.timers)\\n if next_timer.cancelled:\\n continue\\n if not next_timer.address or next_timer.address in self.nodes:\\n next_timer.callback()\\n\\n def stop(self):\\n self.timers = []\\n\\n def set_timer(self, address, seconds, callback):\\n timer = Timer(self.now + seconds, address, callback)\\n heapq.heappush(self.timers, timer)\\n return timer\\n\\n def send(self, sender, destinations, message):\\n sender.logger.debug(\"sending %s to %s\", message, destinations)\\n for dest in (d for d in destinations if d in self.nodes):\\n if dest == sender.address:\\n # reliably deliver local messages with no delay\\n self.set_timer(sender.address, 0, lambda: sender.receive(sender.address, message))\\n elif self.rnd.uniform(0, 1.0) > self.DROP_PROB:\\n delay = self.PROP_DELAY + self.rnd.uniform(-self.PROP_JITTER, self.PROP_JITTER)\\n self.set_timer(dest, delay, functools.partial(self.nodes[dest].receive,\\n sender.address, message))\\n\\nclass SimTimeLogger(logging.LoggerAdapter):\\n\\n def process(self, msg, kwargs):\\n return \"T=%.3f %s\" % (self.extra[\\'network\\'].now, msg), kwargs\\n\\n def getChild(self, name):\\n return self.__class__(self.logger.getChild(name),\\n {\\'network\\': self.extra[\\'network\\']})\\n\\nclass Role(object):\\n\\n def __init__(self, node):\\n self.node = node\\n self.node.register(self)\\n self.running = True\\n self.logger = node.logger.getChild(type(self).__name__)\\n\\n def set_timer(self, seconds, callback):\\n return self.node.network.set_timer(self.node.address, seconds,\\n lambda: self.running and callback())\\n\\n def stop(self):\\n self.running = False\\n self.node.unregister(self)\\n\\nclass Acceptor(Role):\\n\\n def __init__(self, node):\\n super(Acceptor, self).__init__(node)\\n self.ballot_num = NULL_BALLOT\\n self.accepted_proposals = {} # {slot: (ballot_num, proposal)}\\n\\n def do_Prepare(self, sender, ballot_num):\\n if ballot_num > self.ballot_num:\\n self.ballot_num = ballot_num\\n # we\\'ve heard from a scout, so it might be the next leader\\n self.node.send([self.node.address], Accepting(leader=sender))\\n\\n self.node.send([sender], Promise(ballot_num=self.ballot_num, accepted_proposals=self.accepted_proposals))\\n\\n def do_Accept(self, sender, ballot_num, slot, proposal):\\n if ballot_num >= self.ballot_num:\\n self.ballot_num = ballot_num\\n acc = self.accepted_proposals\\n if slot not in acc or acc[slot][0] < ballot_num:\\n acc[slot] = (ballot_num, proposal)\\n\\n self.node.send([sender], Accepted(\\n slot=slot, ballot_num=self.ballot_num))\\n\\nclass Replica(Role):\\n\\n def __init__(self, node, execute_fn, state, slot, decisions, peers):\\n super(Replica, self).__init__(node)\\n self.execute_fn = execute_fn\\n self.state = state\\n self.slot = slot\\n self.decisions = decisions.copy()\\n self.peers = peers\\n self.proposals = {}\\n # next slot num for a proposal (may lead slot)\\n self.next_slot = slot\\n self.latest_leader = None\\n self.latest_leader_timeout = None\\n\\n # making proposals\\n\\n def do_Invoke(self, sender, caller, client_id, input_value):\\n proposal = Proposal(caller, client_id, input_value)\\n slot = next((s for s, p in self.proposals.iteritems() if p == proposal), None)\\n # propose, or re-propose if this proposal already has a slot\\n self.propose(proposal, slot)\\n\\n def propose(self, proposal, slot=None):\\n \"\"\"Send (or resend, if slot is specified) a proposal to the leader\"\"\"\\n if not slot:\\n slot, self.next_slot = self.next_slot, self.next_slot + 1\\n self.proposals[slot] = proposal\\n # find a leader we think is working - either the latest we know of, or\\n # ourselves (which may trigger a scout to make us the leader)\\n leader = self.latest_leader or self.node.address\\n self.logger.info(\"proposing %s at slot %d to leader %s\" % (proposal, slot, leader))\\n self.node.send([leader], Propose(slot=slot, proposal=proposal))\\n\\n # handling decided proposals\\n\\n def do_Decision(self, sender, slot, proposal):\\n assert not self.decisions.get(self.slot, None), \\\\\\n \"next slot to commit is already decided\"\\n if slot in self.decisions:\\n assert self.decisions[slot] == proposal, \\\\\\n \"slot %d already decided with %r!\" % (slot, self.decisions[slot])\\n return\\n self.decisions[slot] = proposal\\n self.next_slot = max(self.next_slot, slot + 1)\\n\\n # re-propose our proposal in a new slot if it lost its slot and wasn\\'t a no-op\\n our_proposal = self.proposals.get(slot)\\n if our_proposal is not None and our_proposal != proposal and our_proposal.caller:\\n self.propose(our_proposal)\\n\\n # execute any pending, decided proposals\\n while True:\\n commit_proposal = self.decisions.get(self.slot)\\n if not commit_proposal:\\n break # not decided yet\\n commit_slot, self.slot = self.slot, self.slot + 1\\n\\n self.commit(commit_slot, commit_proposal)\\n\\n def commit(self, slot, proposal):\\n \"\"\"Actually commit a proposal that is decided and in sequence\"\"\"\\n decided_proposals = [p for s, p in self.decisions.iteritems() if s < slot]\\n if proposal in decided_proposals:\\n self.logger.info(\"not committing duplicate proposal %r at slot %d\", proposal, slot)\\n return # duplicate\\n\\n self.logger.info(\"committing %r at slot %d\" % (proposal, slot))\\n if proposal.caller is not None:\\n # perform a client operation\\n self.state, output = self.execute_fn(self.state, proposal.input)\\n self.node.send([proposal.caller], Invoked(client_id=proposal.client_id, output=output))\\n\\n # tracking the leader\\n\\n def do_Adopted(self, sender, ballot_num, accepted_proposals):\\n self.latest_leader = self.node.address\\n self.leader_alive()\\n\\n def do_Accepting(self, sender, leader):\\n self.latest_leader = leader\\n self.leader_alive()\\n\\n def do_Active(self, sender):\\n if sender != self.latest_leader:\\n return\\n self.leader_alive()\\n\\n def leader_alive(self):\\n if self.latest_leader_timeout:\\n self.latest_leader_timeout.cancel()\\n\\n def reset_leader():\\n idx = self.peers.index(self.latest_leader)\\n self.latest_leader = self.peers[(idx + 1) % len(self.peers)]\\n self.logger.debug(\"leader timed out; tring the next one, %s\", self.latest_leader)\\n self.latest_leader_timeout = self.set_timer(LEADER_TIMEOUT, reset_leader)\\n\\n # adding new cluster members\\n\\n def do_Join(self, sender):\\n if sender in self.peers:\\n self.node.send([sender], Welcome(\\n state=self.state, slot=self.slot, decisions=self.decisions))\\n\\nclass Commander(Role):\\n\\n def __init__(self, node, ballot_num, slot, proposal, peers):\\n super(Commander, self).__init__(node)\\n self.ballot_num = ballot_num\\n self.slot = slot\\n self.proposal = proposal\\n self.acceptors = set([])\\n self.peers = peers\\n self.quorum = len(peers) / 2 + 1\\n\\n def start(self):\\n self.node.send(set(self.peers) - self.acceptors, Accept(\\n slot=self.slot, ballot_num=self.ballot_num, proposal=self.proposal))\\n self.set_timer(ACCEPT_RETRANSMIT, self.start)\\n\\n def finished(self, ballot_num, preempted):\\n if preempted:\\n self.node.send([self.node.address], Preempted(slot=self.slot, preempted_by=ballot_num))\\n else:\\n self.node.send([self.node.address], Decided(slot=self.slot))\\n self.stop()\\n\\n def do_Accepted(self, sender, slot, ballot_num):\\n if slot != self.slot:\\n return\\n if ballot_num == self.ballot_num:\\n self.acceptors.add(sender)\\n if len(self.acceptors) < self.quorum:\\n return\\n self.node.send(self.peers, Decision(slot=self.slot, proposal=self.proposal))\\n self.finished(ballot_num, False)\\n else:\\n self.finished(ballot_num, True)\\n\\nclass Scout(Role):\\n\\n def __init__(self, node, ballot_num, peers):\\n super(Scout, self).__init__(node)\\n self.ballot_num = ballot_num\\n self.accepted_proposals = {}\\n self.acceptors = set([])\\n self.peers = peers\\n self.quorum = len(peers) / 2 + 1\\n self.retransmit_timer = None\\n\\n def start(self):\\n self.logger.info(\"scout starting\")\\n self.send_prepare()\\n\\n def send_prepare(self):\\n self.node.send(self.peers, Prepare(ballot_num=self.ballot_num))\\n self.retransmit_timer = self.set_timer(PREPARE_RETRANSMIT, self.send_prepare)\\n\\n def update_accepted(self, accepted_proposals):\\n acc = self.accepted_proposals\\n for slot, (ballot_num, proposal) in accepted_proposals.iteritems():\\n if slot not in acc or acc[slot][0] < ballot_num:\\n acc[slot] = (ballot_num, proposal)\\n\\n def do_Promise(self, sender, ballot_num, accepted_proposals):\\n if ballot_num == self.ballot_num:\\n self.logger.info(\"got matching promise; need %d\" % self.quorum)\\n self.update_accepted(accepted_proposals)\\n self.acceptors.add(sender)\\n if len(self.acceptors) >= self.quorum:\\n # strip the ballot numbers from self.accepted_proposals, now that it\\n # represents a majority\\n accepted_proposals = dict((s, p) for s, (b, p) in self.accepted_proposals.iteritems())\\n # We\\'re adopted; note that this does *not* mean that no other leader is active.\\n # Any such conflicts will be handled by the commanders.\\n self.node.send([self.node.address],\\n Adopted(ballot_num=ballot_num, accepted_proposals=accepted_proposals))\\n self.stop()\\n else:\\n # this acceptor has promised another leader a higher ballot number, so we\\'ve lost\\n self.node.send([self.node.address], Preempted(slot=None, preempted_by=ballot_num))\\n self.stop()\\n\\nclass Leader(Role):\\n\\n def __init__(self, node, peers, commander_cls=Commander, scout_cls=Scout):\\n super(Leader, self).__init__(node)\\n self.ballot_num = Ballot(0, node.address)\\n self.active = False\\n self.proposals = {}\\n self.commander_cls = commander_cls\\n self.scout_cls = scout_cls\\n self.scouting = False\\n self.peers = peers\\n\\n def start(self):\\n # reminder others we\\'re active before LEADER_TIMEOUT expires\\n def active():\\n if self.active:\\n self.node.send(self.peers, Active())\\n self.set_timer(LEADER_TIMEOUT / 2.0, active)\\n active()\\n\\n def spawn_scout(self):\\n assert not self.scouting\\n self.scouting = True\\n self.scout_cls(self.node, self.ballot_num, self.peers).start()\\n\\n def do_Adopted(self, sender, ballot_num, accepted_proposals):\\n self.scouting = False\\n self.proposals.update(accepted_proposals)\\n # note that we don\\'t re-spawn commanders here; if there are undecided\\n # proposals, the replicas will re-propose\\n self.logger.info(\"leader becoming active\")\\n self.active = True\\n\\n def spawn_commander(self, ballot_num, slot):\\n proposal = self.proposals[slot]\\n self.commander_cls(self.node, ballot_num, slot, proposal, self.peers).start()\\n\\n def do_Preempted(self, sender, slot, preempted_by):\\n if not slot: # from the scout\\n self.scouting = False\\n self.logger.info(\"leader preempted by %s\", preempted_by.leader)\\n self.active = False\\n self.ballot_num = Ballot((preempted_by or self.ballot_num).n + 1, self.ballot_num.leader)\\n\\n def do_Propose(self, sender, slot, proposal):\\n if slot not in self.proposals:\\n if self.active:\\n self.proposals[slot] = proposal\\n self.logger.info(\"spawning commander for slot %d\" % (slot,))\\n self.spawn_commander(self.ballot_num, slot)\\n else:\\n if not self.scouting:\\n self.logger.info(\"got PROPOSE when not active - scouting\")\\n self.spawn_scout()\\n else:\\n self.logger.info(\"got PROPOSE while scouting; ignored\")\\n else:\\n self.logger.info(\"got PROPOSE for a slot already being proposed\")\\n\\nclass Bootstrap(Role):\\n\\n def __init__(self, node, peers, execute_fn,\\n replica_cls=Replica, acceptor_cls=Acceptor, leader_cls=Leader,\\n commander_cls=Commander, scout_cls=Scout):\\n super(Bootstrap, self).__init__(node)\\n self.execute_fn = execute_fn\\n self.peers = peers\\n self.peers_cycle = itertools.cycle(peers)\\n self.replica_cls = replica_cls\\n self.acceptor_cls = acceptor_cls\\n self.leader_cls = leader_cls\\n self.commander_cls = commander_cls\\n self.scout_cls = scout_cls\\n\\n def start(self):\\n self.join()\\n\\n def join(self):\\n self.node.send([next(self.peers_cycle)], Join())\\n self.set_timer(JOIN_RETRANSMIT, self.join)\\n\\n def do_Welcome(self, sender, state, slot, decisions):\\n self.acceptor_cls(self.node)\\n self.replica_cls(self.node, execute_fn=self.execute_fn, peers=self.peers,\\n state=state, slot=slot, decisions=decisions)\\n self.leader_cls(self.node, peers=self.peers, commander_cls=self.commander_cls,\\n scout_cls=self.scout_cls).start()\\n self.stop()\\n\\nclass Seed(Role):\\n\\n def __init__(self, node, initial_state, execute_fn, peers, bootstrap_cls=Bootstrap):\\n super(Seed, self).__init__(node)\\n self.initial_state = initial_state\\n self.execute_fn = execute_fn\\n self.peers = peers\\n self.bootstrap_cls = bootstrap_cls\\n self.seen_peers = set([])\\n self.exit_timer = None\\n\\n def do_Join(self, sender):\\n self.seen_peers.add(sender)\\n if len(self.seen_peers) <= len(self.peers) / 2:\\n return\\n\\n # cluster is ready - welcome everyone\\n self.node.send(list(self.seen_peers), Welcome(\\n state=self.initial_state, slot=1, decisions={}))\\n\\n # stick around for long enough that we don\\'t hear any new JOINs from\\n # the newly formed cluster\\n if self.exit_timer:\\n self.exit_timer.cancel()\\n self.exit_timer = self.set_timer(JOIN_RETRANSMIT * 2, self.finish)\\n\\n def finish(self):\\n # bootstrap this node into the cluster we just seeded\\n bs = self.bootstrap_cls(self.node, peers=self.peers, execute_fn=self.execute_fn)\\n bs.start()\\n self.stop()\\n\\nclass Requester(Role):\\n\\n client_ids = itertools.count(start=100000)\\n\\n def __init__(self, node, n, callback):\\n super(Requester, self).__init__(node)\\n self.client_id = self.client_ids.next()\\n self.n = n\\n self.output = None\\n self.callback = callback\\n\\n def start(self):\\n self.node.send([self.node.address], Invoke(caller=self.node.address,\\n client_id=self.client_id, input_value=self.n))\\n self.invoke_timer = self.set_timer(INVOKE_RETRANSMIT, self.start)\\n\\n def do_Invoked(self, sender, client_id, output):\\n if client_id != self.client_id:\\n return\\n self.logger.debug(\"received output %r\" % (output,))\\n self.invoke_timer.cancel()\\n self.callback(output)\\n self.stop()\\n\\nclass Member(object):\\n\\n def __init__(self, state_machine, network, peers, seed=None,\\n seed_cls=Seed, bootstrap_cls=Bootstrap):\\n self.network = network\\n self.node = network.new_node()\\n if seed is not None:\\n self.startup_role = seed_cls(self.node, initial_state=seed, peers=peers,\\n execute_fn=state_machine)\\n else:\\n self.startup_role = bootstrap_cls(self.node, execute_fn=state_machine, peers=peers)\\n self.requester = None\\n\\n def start(self):\\n self.startup_role.start()\\n self.thread = threading.Thread(target=self.network.run)\\n self.thread.start()\\n\\n def invoke(self, input_value, request_cls=Requester):\\n assert self.requester is None\\n q = Queue.Queue()\\n self.requester = request_cls(self.node, input_value, q.put)\\n self.requester.start()\\n output = q.get()\\n self.requester = None\\n return output',\n", - " \"function errorHandler(context) {\\n return function(error) {\\n trace('Failure in ' + context + ': ' + error.toString);\\n }\\n}\\n\\nfunction successHandler(context) {\\n return function() {\\n trace('Success in ' + context);\\n }\\n}\\n\\nfunction noAction() {\\n}\\n\\n\\nfunction VideoPipe(stream, handler) {\\n var servers = null;\\n var pc1 = new RTCPeerConnection(servers);\\n var pc2 = new RTCPeerConnection(servers);\\n\\n pc1.addStream(stream);\\n pc1.onicecandidate = function(event) {\\n if (event.candidate) {\\n pc2.addIceCandidate(new RTCIceCandidate(event.candidate),\\n noAction, errorHandler('AddIceCandidate'));\\n }\\n }\\n pc2.onicecandidate = function(event) {\\n if (event.candidate) {\\n pc1.addIceCandidate(new RTCIceCandidate(event.candidate),\\n noAction, errorHandler('AddIceCandidate'));\\n }\\n }\\n pc2.onaddstream = function(e) {\\n handler(e.stream);\\n }\\n pc1.createOffer(function(desc) {\\n pc1.setLocalDescription(desc);\\n pc2.setRemoteDescription(desc);\\n pc2.createAnswer(function(desc2) {\\n pc2.setLocalDescription(desc2);\\n pc1.setRemoteDescription(desc2);\\n }, errorHandler('pc2.createAnswer'));\\n }, errorHandler('pc1.createOffer'));\\n this.pc1 = pc1;\\n this.pc2 = pc2;\\n}\\n\\nVideoPipe.prototype.close = function() {\\n this.pc1.close();\\n this.pc2.close();\\n}\",\n", - " \"var _ = require('lodash'),\\n fs = require('fs'),\\n yaml = require('js-yaml');\\n\\nfunction getDefaultSettings() {\\n return yaml.safeLoad(fs.readFileSync('defaults.yml', 'utf8'));\\n}\\n\\nfunction getFileSettings() {\\n if (fs.existsSync('settings.yml')) {\\n return yaml.safeLoad(fs.readFileSync('settings.yml', 'utf8'));\\n }\\n return {};\\n}\\n\",\n", - " '/* Riot v2.0.8, @license MIT, (c) 2015 Muut Inc. + contributors */\\n\\n;(function() {\\n\\nvar riot = { version: \\'v2.0.8\\', settings: {} }\\n\\n\\'use strict\\'\\n\\nriot.observable = function(el) {\\n\\n el = el || {}\\n\\n var callbacks = {}\\n\\n el.on = function(events, fn) {\\n if (typeof fn == \\'function\\') {\\n events.replace(/\\\\S+/g, function(name, pos) {\\n (callbacks[name] = callbacks[name] || []).push(fn)\\n fn.typed = pos > 0\\n })\\n }\\n return el\\n }\\n\\n el.off = function(events, fn) {\\n if (events == \\'*\\') callbacks = {}\\n else if (fn) {\\n var arr = callbacks[events]\\n for (var i = 0, cb; (cb = arr && arr[i]); ++i) {\\n if (cb == fn) { arr.splice(i, 1); i-- }\\n }\\n } else {\\n events.replace(/\\\\S+/g, function(name) {\\n callbacks[name] = []\\n })\\n }\\n return el\\n }\\n\\n // only single event supported\\n el.one = function(name, fn) {\\n if (fn) fn.one = 1\\n return el.on(name, fn)\\n }\\n\\n el.trigger = function(name) {\\n var args = [].slice.call(arguments, 1),\\n fns = callbacks[name] || []\\n\\n for (var i = 0, fn; (fn = fns[i]); ++i) {\\n if (!fn.busy) {\\n fn.busy = 1\\n fn.apply(el, fn.typed ? [name].concat(args) : args)\\n if (fn.one) { fns.splice(i, 1); i-- }\\n else if (fns[i] !== fn) { i-- } // Makes self-removal possible during iteration\\n fn.busy = 0\\n }\\n }\\n\\n return el\\n }\\n\\n return el\\n\\n}\\n;(function(riot, evt) {\\n\\n // browsers only\\n if (!this.top) return\\n\\n var loc = location,\\n fns = riot.observable(),\\n current = hash(),\\n win = window\\n\\n function hash() {\\n return loc.hash.slice(1)\\n }\\n\\n function parser(path) {\\n return path.split(\\'/\\')\\n }\\n\\n function emit(path) {\\n if (path.type) path = hash()\\n\\n if (path != current) {\\n fns.trigger.apply(null, [\\'H\\'].concat(parser(path)))\\n current = path\\n }\\n }\\n\\n var r = riot.route = function(arg) {\\n // string\\n if (arg[0]) {\\n loc.hash = arg\\n emit(arg)\\n\\n // function\\n } else {\\n fns.on(\\'H\\', arg)\\n }\\n }\\n\\n r.exec = function(fn) {\\n fn.apply(null, parser(hash()))\\n }\\n\\n r.parser = function(fn) {\\n parser = fn\\n }\\n\\n win.addEventListener ? win.addEventListener(evt, emit, false) : win.attachEvent(\\'on\\' + evt, emit)\\n\\n})(riot, \\'hashchange\\')\\n/*\\n\\n//// How it works?\\n\\n\\nThree ways:\\n\\n1. Expressions: tmpl(\\'{ value }\\', data).\\n Returns the result of evaluated expression as a raw object.\\n\\n2. Templates: tmpl(\\'Hi { name } { surname }\\', data).\\n Returns a string with evaluated expressions.\\n\\n3. Filters: tmpl(\\'{ show: !done, highlight: active }\\', data).\\n Returns a space separated list of trueish keys (mainly\\n used for setting html classes), e.g. \"show highlight\".\\n\\n\\n// Template examples\\n\\ntmpl(\\'{ title || \"Untitled\" }\\', data)\\ntmpl(\\'Results are { results ? \"ready\" : \"loading\" }\\', data)\\ntmpl(\\'Today is { new Date() }\\', data)\\ntmpl(\\'{ message.length > 140 && \"Message is too long\" }\\', data)\\ntmpl(\\'This item got { Math.round(rating) } stars\\', data)\\ntmpl(\\'

{ title }

{ body }\\', data)\\n\\n\\n// Falsy expressions in templates\\n\\nIn templates (as opposed to single expressions) all falsy values\\nexcept zero (undefined/null/false) will default to empty string:\\n\\ntmpl(\\'{ undefined } - { false } - { null } - { 0 }\\', {})\\n// will return: \" - - - 0\"\\n\\n\\n// Customizable brackets\\n\\n riot.settings.brackets = \\'[ ]\\'\\n riot.settings.brackets = \\'<% %>\\'\\n\\n*/\\n\\nvar tmpl = (function() {\\n\\n var cache = {},\\n brackets,\\n re_expr,\\n re_vars = /(\"|\\').+?[^\\\\\\\\]\\\\1|\\\\.\\\\w*|\\\\w*:|\\\\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\\\\b|function *\\\\()|([a-z_]\\\\w*)/gi\\n // [ 1 ][ 2 ][ 3 ][ 4 ][ 5 ]\\n // find variable names:\\n // 1. skip quoted strings: \"a b\", \\'a b\\', \\'a \\\\\\'b\\\\\\'\\'\\n // 2. skip object properties: .name\\n // 3. skip object literals: name:\\n // 4. skip javascript keywords\\n // 5. match var name\\n\\n return function(str, data) {\\n\\n // make sure we use current brackets setting\\n var b = riot.settings.brackets || \\'{ }\\'\\n if(b != brackets){\\n brackets = b.split(\\' \\')\\n re_expr = re(/({[\\\\s\\\\S]*?})/)\\n }\\n\\n // build a template (or get it from cache), render with data\\n // (or just test if string has expression when called w/o data)\\n return data\\n ? str && (cache[str] = cache[str] || tmpl(str))(data)\\n : re_expr.test(str)\\n\\n }\\n\\n\\n // create a template instance\\n\\n function tmpl(s, p) {\\n\\n // default template string to {}\\n p = (s || brackets.join(\\'\\'))\\n\\n // temporarily convert \\\\{ and \\\\} to a non-character\\n .replace(re(/\\\\\\\\{/), \\'\\\\uFFF0\\')\\n .replace(re(/\\\\\\\\}/), \\'\\\\uFFF1\\')\\n \\n // split string to expression and non-expresion parts\\n .split(re_expr)\\n\\n return new Function(\\'d\\', \\'return \\' + (\\n\\n // is it a single expression or a template? i.e. {x} or {x}\\n !p[0] && !p[2] && !p[3]\\n\\n // if expression, evaluate it\\n ? expr(p[1])\\n\\n // if template, evaluate all expressions in it\\n : \\'[\\' + p.map(function(s, i) {\\n\\n // is it an expression or a string (every second part is an expression)\\n return i % 2\\n\\n // evaluate the expressions\\n ? expr(s, 1)\\n\\n // process string parts of the template:\\n : \\'\"\\' + s\\n\\n // preserve new lines\\n .replace(/\\\\n/g, \\'\\\\\\\\n\\')\\n\\n // escape quotes\\n .replace(/\"/g, \\'\\\\\\\\\"\\')\\n\\n + \\'\"\\'\\n\\n }).join(\\',\\') + \\'].join(\"\")\\'\\n )\\n\\n // bring escaped { and } back\\n .replace(/\\\\uFFF0/g, brackets[0])\\n .replace(/\\\\uFFF1/g, brackets[1])\\n\\n )\\n\\n }\\n\\n\\n // parse { ... } expression\\n\\n function expr(s, n) {\\n s = s\\n\\n // convert new lines to spaces\\n .replace(/\\\\n/g, \\' \\')\\n\\n // trim whitespace, curly brackets, strip comments\\n .replace(re(/^[{ ]+|[ }]+$|\\\\/\\\\*.+?\\\\*\\\\//g), \\'\\')\\n\\n // is it an object literal? i.e. { key : value }\\n return /^\\\\s*[\\\\w-\"\\']+ *:/.test(s)\\n\\n // if object literal, return trueish keys\\n // e.g.: { show: isOpen(), done: item.done } -> \"show done\"\\n ? \\'[\\' + s.replace(/\\\\W*([\\\\w-]+)\\\\W*:([^,]+)/g, function(_, k, v) {\\n\\n // safely execute vars to prevent undefined value errors\\n return v.replace(/\\\\w[^,|& ]*/g, function(v) { return wrap(v, n) }) + \\'?\"\\' + k + \\'\":\"\",\\'\\n\\n }) + \\'].join(\" \")\\'\\n\\n // if js expression, evaluate as javascript\\n : wrap(s, n)\\n\\n }\\n\\n\\n // execute js w/o breaking on errors or undefined vars\\n\\n function wrap(s, nonull) {\\n return \\'(function(v){try{v=\\'\\n\\n // prefix vars (name => data.name)\\n + (s.replace(re_vars, function(s, _, v) { return v ? \\'(d.\\'+v+\\'===undefined?window.\\'+v+\\':d.\\'+v+\\')\\' : s })\\n\\n // break the expression if its empty (resulting in undefined value)\\n || \\'x\\')\\n\\n + \\'}finally{return \\'\\n\\n // default to empty string for falsy values except zero\\n + (nonull ? \\'!v&&v!==0?\"\":v\\' : \\'v\\')\\n\\n + \\'}}).call(d)\\'\\n }\\n\\n\\n // change regexp to use custom brackets\\n\\n function re(r) {\\n return RegExp(r.source\\n .split(\\'{\\').join(\\'\\\\\\\\\\'+brackets[0])\\n .split(\\'}\\').join(\\'\\\\\\\\\\'+brackets[1]),\\n r.global ? \\'g\\' : \\'\\')\\n }\\n\\n})()\\n// { key, i in items} -> { key, i, items }\\nfunction loopKeys(expr) {\\n var ret = { val: expr },\\n els = expr.split(/\\\\s+in\\\\s+/)\\n\\n if (els[1]) {\\n ret.val = \\'{ \\' + els[1]\\n els = els[0].slice(1).trim().split(/,\\\\s*/)\\n ret.key = els[0]\\n ret.pos = els[1]\\n }\\n return ret\\n}\\n\\nfunction _each(dom, parent, expr) {\\n\\n remAttr(dom, \\'each\\')\\n\\n var template = dom.outerHTML,\\n prev = dom.previousSibling,\\n root = dom.parentNode,\\n rendered = [],\\n tags = [],\\n checksum\\n\\n expr = loopKeys(expr)\\n\\n // clean template code after update (and let walk finish it\\'s parse)\\n parent.one(\\'update\\', function() {\\n root.removeChild(dom)\\n\\n }).one(\\'mount\\', function() {\\n if (!hasParent(root)) root = parent.root\\n\\n }).on(\\'update\\', function() {\\n\\n var items = tmpl(expr.val, parent)\\n if (!items) return\\n\\n // object loop. any changes cause full redraw\\n if (!Array.isArray(items)) {\\n var testsum = JSON.stringify(items)\\n if (testsum == checksum) return\\n checksum = testsum\\n\\n // clear old items\\n tags.map(function(tag) {\\n tag.unmount()\\n })\\n\\n tags = rendered = []\\n\\n items = Object.keys(items).map(function(key, i) {\\n var obj = {}\\n obj[expr.key] = key\\n obj[expr.pos] = items[key]\\n return obj\\n })\\n\\n }\\n\\n // unmount redundant\\n arrDiff(rendered, items).map(function(item) {\\n var pos = rendered.indexOf(item),\\n tag = tags[pos]\\n\\n if (tag) {\\n tag.unmount()\\n rendered.splice(pos, 1)\\n tags.splice(pos, 1)\\n }\\n })\\n\\n // mount new\\n var nodes = root.childNodes,\\n prev_index = Array.prototype.indexOf.call(nodes, prev)\\n\\n arrDiff(items, rendered).map(function(item, i) {\\n\\n var pos = items.indexOf(item)\\n\\n if (!checksum && expr.key) {\\n var obj = {}\\n obj[expr.key] = item\\n obj[expr.pos] = pos\\n item = obj\\n }\\n\\n var tag = new Tag({ tmpl: template }, {\\n before: nodes[prev_index + 1 + pos],\\n parent: parent,\\n root: root,\\n loop: true,\\n item: item\\n })\\n\\n tags.splice(pos, 0, tag)\\n\\n })\\n\\n rendered = items.slice()\\n\\n })\\n\\n}\\nfunction parseNamedElements(root, tag, expressions) {\\n walk(root, function(dom) {\\n if (dom.nodeType != 1) return\\n\\n each(dom.attributes, function(attr) {\\n if (/^(name|id)$/.test(attr.name)) tag[attr.value] = dom\\n })\\n })\\n}\\n\\nfunction parseLayout(root, tag, expressions) {\\n\\n function addExpr(dom, value, data) {\\n if (tmpl(value) || data) {\\n var expr = { dom: dom, expr: value }\\n expressions.push(extend(expr, data || {}))\\n }\\n }\\n\\n walk(root, function(dom) {\\n\\n var type = dom.nodeType\\n\\n // text node\\n if (type == 3 && dom.parentNode.tagName != \\'STYLE\\') addExpr(dom, dom.nodeValue)\\n if (type != 1) return\\n\\n /* element */\\n\\n // loop\\n var attr = dom.getAttribute(\\'each\\')\\n if (attr) { _each(dom, tag, attr); return false }\\n\\n // child tag\\n var impl = tag_impl[dom.tagName.toLowerCase()]\\n if (impl) {\\n impl = new Tag(impl, { root: dom, parent: tag })\\n return false\\n }\\n\\n // attributes\\n each(dom.attributes, function(attr) {\\n var name = attr.name,\\n value = attr.value\\n\\n // expressions\\n var bool = name.split(\\'__\\')[1]\\n addExpr(dom, value, { attr: bool || name, bool: bool })\\n\\n if (bool) {\\n remAttr(dom, name)\\n return false\\n }\\n\\n })\\n\\n })\\n\\n}\\nfunction Tag(impl, conf) {\\n\\n var self = riot.observable(this),\\n expressions = [],\\n attributes = {},\\n parent = conf.parent,\\n is_loop = conf.loop,\\n root = conf.root,\\n opts = conf.opts,\\n item = conf.item\\n\\n // cannot initialize twice on the same root element\\n if (!is_loop && root.riot) return\\n root.riot = 1\\n\\n opts = opts || {}\\n\\n extend(this, { parent: parent, root: root, opts: opts, children: [] })\\n extend(this, item)\\n\\n\\n // attributes\\n each(root.attributes, function(attr) {\\n var name = attr.name,\\n val = attr.value\\n\\n attributes[name] = val\\n\\n // remove dynamic attributes from node\\n if (val.indexOf(\\'{\\') >= 0) {\\n remAttr(root, name)\\n return false\\n }\\n })\\n\\n // options\\n function updateOpts() {\\n Object.keys(attributes).map(function(name) {\\n opts[name] = tmpl(attributes[name], parent || self)\\n })\\n }\\n\\n updateOpts()\\n\\n // child\\n parent && parent.children.push(this)\\n\\n var dom = mkdom(impl.tmpl),\\n loop_dom\\n\\n // named elements\\n parseNamedElements(dom, this)\\n\\n this.update = function(data, init) {\\n extend(self, data)\\n extend(self, item)\\n self.trigger(\\'update\\')\\n updateOpts()\\n update(expressions, self, item)\\n self.trigger(\\'updated\\')\\n }\\n\\n this.unmount = function() {\\n\\n if (is_loop) {\\n root.removeChild(loop_dom)\\n\\n } else {\\n var p = root.parentNode\\n p && p.removeChild(root)\\n }\\n\\n // splice from parent.children[]\\n if (parent) {\\n var els = parent.children\\n els.splice(els.indexOf(self), 1)\\n }\\n\\n self.trigger(\\'unmount\\')\\n\\n // cleanup\\n parent && parent.off(\\'update\\', self.update)\\n mounted = false\\n }\\n\\n function mount() {\\n while (dom.firstChild) {\\n if (is_loop) {\\n loop_dom = dom.firstChild\\n root.insertBefore(dom.firstChild, conf.before || null) // null needed for IE8\\n\\n } else {\\n root.appendChild(dom.firstChild)\\n }\\n }\\n\\n if (!hasParent(root)) self.root = root = parent.root\\n\\n self.trigger(\\'mount\\')\\n\\n // one way data flow: propagate updates and unmounts downwards from parent to children\\n parent && parent.on(\\'update\\', self.update).one(\\'unmount\\', self.unmount)\\n\\n }\\n\\n // initialize\\n if (impl.fn) impl.fn.call(this, opts)\\n\\n // layout\\n parseLayout(dom, this, expressions)\\n\\n this.update()\\n mount()\\n\\n}\\n\\n\\nfunction setEventHandler(name, handler, dom, tag, item) {\\n\\n dom[name] = function(e) {\\n\\n // cross browser event fix\\n e = e || window.event\\n e.which = e.which || e.charCode || e.keyCode\\n e.target = e.target || e.srcElement\\n e.currentTarget = dom\\n e.item = item\\n\\n // prevent default behaviour (by default)\\n if (handler.call(tag, e) !== true) {\\n e.preventDefault && e.preventDefault()\\n e.returnValue = false\\n }\\n\\n tag.update()\\n }\\n\\n}\\n\\nfunction insertTo(root, node, before) {\\n if (root) {\\n root.insertBefore(before, node)\\n root.removeChild(node)\\n }\\n}\\n\\n// item = currently looped item\\nfunction update(expressions, tag, item) {\\n\\n each(expressions, function(expr) {\\n var dom = expr.dom,\\n attr_name = expr.attr,\\n value = tmpl(expr.expr, tag)\\n\\n if (value == null) value = \\'\\'\\n\\n // no change\\n if (expr.value === value) return\\n expr.value = value\\n\\n // text node\\n if (!attr_name) return dom.nodeValue = value\\n\\n // remove attribute\\n if (!value && expr.bool || /obj|func/.test(typeof value)) remAttr(dom, attr_name)\\n\\n // event handler\\n if (typeof value == \\'function\\') {\\n setEventHandler(attr_name, value, dom, tag, item)\\n\\n // if- conditional\\n } else if (attr_name == \\'if\\') {\\n\\n remAttr(dom, attr_name)\\n\\n var stub = expr.stub\\n\\n // add to DOM\\n if (value) {\\n stub && insertTo(stub.parentNode, stub, dom)\\n\\n // remove from DOM\\n } else {\\n stub = expr.stub = stub || document.createTextNode(\\'\\')\\n insertTo(dom.parentNode, dom, stub)\\n }\\n\\n // show / hide\\n } else if (/^(show|hide)$/.test(attr_name)) {\\n remAttr(dom, attr_name)\\n if (attr_name == \\'hide\\') value = !value\\n dom.style.display = value ? \\'\\' : \\'none\\'\\n\\n // normal attribute\\n } else {\\n if (expr.bool) {\\n dom[attr_name] = value\\n if (!value) return\\n value = attr_name\\n }\\n\\n dom.setAttribute(attr_name, value)\\n }\\n\\n })\\n\\n}\\nfunction each(nodes, fn) {\\n for (var i = 0; i < (nodes || []).length; i++) {\\n if (fn(nodes[i], i) === false) i--\\n }\\n}\\n\\nfunction remAttr(dom, name) {\\n dom.removeAttribute(name)\\n}\\n\\nfunction extend(obj, from) {\\n from && Object.keys(from).map(function(key) {\\n obj[key] = from[key]\\n })\\n return obj\\n}\\n\\nfunction mkdom(template) {\\n var tag_name = template.trim().slice(1, 3).toLowerCase(),\\n root_tag = /td|th/.test(tag_name) ? \\'tr\\' : tag_name == \\'tr\\' ? \\'tbody\\' : \\'div\\'\\n el = document.createElement(root_tag)\\n\\n el.stub = true\\n el.innerHTML = template\\n return el\\n}\\n\\nfunction walk(dom, fn) {\\n dom = fn(dom) === false ? dom.nextSibling : dom.firstChild\\n\\n while (dom) {\\n walk(dom, fn)\\n dom = dom.nextSibling\\n }\\n}\\n\\nfunction arrDiff(arr1, arr2) {\\n return arr1.filter(function(el) {\\n return arr2.indexOf(el) < 0\\n })\\n}\\n\\n// HTMLDocument == IE8 thing\\nfunction hasParent(el) {\\n var p = el.parentNode,\\n doc = window.HTMLDocument\\n\\n return p && !(doc && p instanceof doc)\\n}\\n\\n/*\\n Virtual dom is an array of custom tags on the document.\\n Each tag stores an array of child tags.\\n Updates and unmounts propagate downwards from parent to children.\\n*/\\n\\nvar virtual_dom = [],\\n tag_impl = {}\\n\\nriot.tag = function(name, html, fn) {\\n tag_impl[name] = { name: name, tmpl: html, fn: fn }\\n}\\n\\nvar mountTo = riot.mountTo = function(root, tagName, opts) {\\n var impl = tag_impl[tagName], tag\\n\\n if (impl) tag = new Tag(impl, { root: root, opts: opts })\\n\\n if (tag) {\\n virtual_dom.push(tag)\\n return tag.on(\\'unmount\\', function() {\\n virtual_dom.splice(virtual_dom.indexOf(tag), 1)\\n })\\n }\\n}\\n\\nriot.mount = function(selector, opts) {\\n if (selector == \\'*\\') selector = Object.keys(tag_impl).join(\\', \\')\\n\\n var tags = []\\n\\n each(document.querySelectorAll(selector), function(root) {\\n\\n var tagName = root.tagName.toLowerCase(),\\n tag = mountTo(root, tagName, opts)\\n\\n if (tag) tags.push(tag)\\n })\\n\\n return tags\\n}\\n\\n// update everything\\nriot.update = function() {\\n virtual_dom.map(function(tag) {\\n tag.update()\\n })\\n return virtual_dom\\n}\\n\\n\\n// support CommonJS\\nif (typeof exports === \\'object\\')\\n module.exports = riot\\n\\n// support AMD\\nelse if (typeof define === \\'function\\' && define.amd)\\n define(function() { return riot })\\n\\n// support browser\\nelse\\n this.riot = riot\\n\\n})();',\n", - " \" var r = riot.route = function(arg) {\\n // string\\n if (arg[0]) {\\n loc.hash = arg\\n emit(arg)\\n\\n // function\\n } else {\\n fns.on('H', arg)\\n }\\n }\",\n", - " \"module ActiveJob\\n module Core\\n extend ActiveSupport::Concern\\n\\n included do\\n # Job arguments\\n attr_accessor :arguments\\n attr_writer :serialized_arguments\\n\\n # Timestamp when the job should be performed\\n attr_accessor :scheduled_at\\n\\n # Job Identifier\\n attr_accessor :job_id\\n\\n # Queue in which the job will reside.\\n attr_writer :queue_name\\n end\\n\\n # These methods will be included into any Active Job object, adding\\n # helpers for de/serialization and creation of job instances.\\n module ClassMethods\\n # Creates a new job instance from a hash created with +serialize+\\n def deserialize(job_data)\\n job = job_data['job_class'].constantize.new\\n job.deserialize(job_data)\\n job\\n end\\n\\n # Creates a job preconfigured with the given options. You can call\\n # perform_later with the job arguments to enqueue the job with the\\n # preconfigured options\\n #\\n # ==== Options\\n # * :wait - Enqueues the job with the specified delay\\n # * :wait_until - Enqueues the job at the time specified\\n # * :queue - Enqueues the job on the specified queue\\n #\\n # ==== Examples\\n #\\n # VideoJob.set(queue: :some_queue).perform_later(Video.last)\\n # VideoJob.set(wait: 5.minutes).perform_later(Video.last)\\n # VideoJob.set(wait_until: Time.now.tomorrow).perform_later(Video.last)\\n # VideoJob.set(queue: :some_queue, wait: 5.minutes).perform_later(Video.last)\\n # VideoJob.set(queue: :some_queue, wait_until: Time.now.tomorrow).perform_later(Video.last)\\n def set(options={})\\n ConfiguredJob.new(self, options)\\n end\\n end\\n\\n # Creates a new job instance. Takes the arguments that will be\\n # passed to the perform method.\\n def initialize(*arguments)\\n @arguments = arguments\\n @job_id = SecureRandom.uuid\\n @queue_name = self.class.queue_name\\n end\\n\\n # Returns a hash with the job data that can safely be passed to the\\n # queueing adapter.\\n def serialize\\n {\\n 'job_class' => self.class.name,\\n 'job_id' => job_id,\\n 'queue_name' => queue_name,\\n 'arguments' => serialize_arguments(arguments)\\n }\\n end\\n\\n # Attaches the stored job data to the current instance. Receives a hash\\n # returned from +serialize+\\n #\\n # ==== Examples\\n #\\n # class DeliverWebhookJob < ActiveJob::Base\\n # def serialize\\n # super.merge('attempt_number' => (@attempt_number || 0) + 1)\\n # end\\n #\\n # def deserialize(job_data)\\n # super\\n # @attempt_number = job_data['attempt_number']\\n # end\\n #\\n # rescue_from(TimeoutError) do |exception|\\n # raise exception if @attempt_number > 5\\n # retry_job(wait: 10)\\n # end\\n # end\\n def deserialize(job_data)\\n self.job_id = job_data['job_id']\\n self.queue_name = job_data['queue_name']\\n self.serialized_arguments = job_data['arguments']\\n end\\n\\n private\\n def deserialize_arguments_if_needed\\n if defined?(@serialized_arguments) && @serialized_arguments.present?\\n @arguments = deserialize_arguments(@serialized_arguments)\\n @serialized_arguments = nil\\n end\\n end\\n\\n def serialize_arguments(serialized_args)\\n Arguments.serialize(serialized_args)\\n end\\n\\n def deserialize_arguments(serialized_args)\\n Arguments.deserialize(serialized_args)\\n end\\n end\\nend\",\n", - " 'require \\'formula\\'\\n\\nclass A52dec < Formula\\n homepage \\'http://liba52.sourceforge.net/\\'\\n url \\'http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz\\'\\n sha1 \\'79b33bd8d89dad7436f85b9154ad35667aa37321\\'\\n\\n def install\\n system \"./configure\", \"--disable-debug\",\\n \"--disable-dependency-tracking\",\\n \"--prefix=#{prefix}\",\\n \"--enable-shared\",\\n \"--mandir=#{man}\"\\n system \"make install\"\\n end\\nend',\n", - " \"module Fluent\\n class Input\\n include Configurable\\n include PluginId\\n include PluginLoggerMixin\\n\\n attr_accessor :router\\n\\n def initialize\\n super\\n end\\n\\n def configure(conf)\\n super\\n\\n if label_name = conf['@label']\\n label = Engine.root_agent.find_label(label_name)\\n @router = label.event_router\\n elsif @router.nil?\\n @router = Engine.root_agent.event_router\\n end\\n end\\n\\n def start\\n end\\n\\n def shutdown\\n end\\n end\\nend\",\n", - " '{-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-}\\n{-\\nCopyright (C) 2006-2014 John MacFarlane \\n\\nThis program is free software; you can redistribute it and/or modify\\nit under the terms of the GNU General Public License as published by\\nthe Free Software Foundation; either version 2 of the License, or\\n(at your option) any later version.\\n\\nThis program is distributed in the hope that it will be useful,\\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\\nGNU General Public License for more details.\\n\\nYou should have received a copy of the GNU General Public License\\nalong with this program; if not, write to the Free Software\\nFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\\n-}\\n\\n{- |\\n Module : Text.Pandoc\\n Copyright : Copyright (C) 2006-2014 John MacFarlane\\n License : GNU GPL, version 2 or above\\n\\n Maintainer : John MacFarlane \\n Stability : alpha\\n Portability : portable\\n\\nThis helper module exports the main writers, readers, and data\\nstructure definitions from the Pandoc libraries.\\n\\nA typical application will chain together a reader and a writer\\nto convert strings from one format to another. For example, the\\nfollowing simple program will act as a filter converting markdown\\nfragments to reStructuredText, using reference-style links instead of\\ninline links:\\n\\n> module Main where\\n> import Text.Pandoc\\n>\\n> markdownToRST :: String -> String\\n> markdownToRST =\\n> (writeRST def {writerReferenceLinks = True}) . readMarkdown def\\n>\\n> main = getContents >>= putStrLn . markdownToRST\\n\\nNote: all of the readers assume that the input text has @\\'\\\\n\\'@\\nline endings. So if you get your input text from a web form,\\nyou should remove @\\'\\\\r\\'@ characters using @filter (/=\\'\\\\r\\')@.\\n\\n-}\\n\\nmodule Text.Pandoc\\n (\\n -- * Definitions\\n module Text.Pandoc.Definition\\n -- * Generics\\n , module Text.Pandoc.Generic\\n -- * Options\\n , module Text.Pandoc.Options\\n -- * Lists of readers and writers\\n , readers\\n , writers\\n -- * Readers: converting /to/ Pandoc format\\n , Reader (..)\\n , mkStringReader\\n , readDocx\\n , readMarkdown\\n , readMediaWiki\\n , readRST\\n , readOrg\\n , readLaTeX\\n , readHtml\\n , readTextile\\n , readDocBook\\n , readOPML\\n , readHaddock\\n , readNative\\n , readJSON\\n , readTWiki\\n , readTxt2Tags\\n , readTxt2TagsNoMacros\\n , readEPUB\\n -- * Writers: converting /from/ Pandoc format\\n , Writer (..)\\n , writeNative\\n , writeJSON\\n , writeMarkdown\\n , writePlain\\n , writeRST\\n , writeLaTeX\\n , writeConTeXt\\n , writeTexinfo\\n , writeHtml\\n , writeHtmlString\\n , writeICML\\n , writeDocbook\\n , writeOPML\\n , writeOpenDocument\\n , writeMan\\n , writeMediaWiki\\n , writeDokuWiki\\n , writeTextile\\n , writeRTF\\n , writeODT\\n , writeDocx\\n , writeEPUB\\n , writeFB2\\n , writeOrg\\n , writeAsciiDoc\\n , writeHaddock\\n , writeCustom\\n -- * Rendering templates and default templates\\n , module Text.Pandoc.Templates\\n -- * Version\\n , pandocVersion\\n -- * Miscellaneous\\n , getReader\\n , getWriter\\n , ToJsonFilter(..)\\n ) where\\n\\nimport Text.Pandoc.Definition\\nimport Text.Pandoc.Generic\\nimport Text.Pandoc.JSON\\nimport Text.Pandoc.Readers.Markdown\\nimport Text.Pandoc.Readers.MediaWiki\\nimport Text.Pandoc.Readers.RST\\nimport Text.Pandoc.Readers.Org\\nimport Text.Pandoc.Readers.DocBook\\nimport Text.Pandoc.Readers.OPML\\nimport Text.Pandoc.Readers.LaTeX\\nimport Text.Pandoc.Readers.HTML\\nimport Text.Pandoc.Readers.Textile\\nimport Text.Pandoc.Readers.Native\\nimport Text.Pandoc.Readers.Haddock\\nimport Text.Pandoc.Readers.TWiki\\nimport Text.Pandoc.Readers.Docx\\nimport Text.Pandoc.Readers.Txt2Tags\\nimport Text.Pandoc.Readers.EPUB\\nimport Text.Pandoc.Writers.Native\\nimport Text.Pandoc.Writers.Markdown\\nimport Text.Pandoc.Writers.RST\\nimport Text.Pandoc.Writers.LaTeX\\nimport Text.Pandoc.Writers.ConTeXt\\nimport Text.Pandoc.Writers.Texinfo\\nimport Text.Pandoc.Writers.HTML\\nimport Text.Pandoc.Writers.ODT\\nimport Text.Pandoc.Writers.Docx\\nimport Text.Pandoc.Writers.EPUB\\nimport Text.Pandoc.Writers.FB2\\nimport Text.Pandoc.Writers.ICML\\nimport Text.Pandoc.Writers.Docbook\\nimport Text.Pandoc.Writers.OPML\\nimport Text.Pandoc.Writers.OpenDocument\\nimport Text.Pandoc.Writers.Man\\nimport Text.Pandoc.Writers.RTF\\nimport Text.Pandoc.Writers.MediaWiki\\nimport Text.Pandoc.Writers.DokuWiki\\nimport Text.Pandoc.Writers.Textile\\nimport Text.Pandoc.Writers.Org\\nimport Text.Pandoc.Writers.AsciiDoc\\nimport Text.Pandoc.Writers.Haddock\\nimport Text.Pandoc.Writers.Custom\\nimport Text.Pandoc.Templates\\nimport Text.Pandoc.Options\\nimport Text.Pandoc.Shared (safeRead, warn)\\nimport Text.Pandoc.MediaBag (MediaBag)\\nimport Data.Aeson\\nimport qualified Data.ByteString.Lazy as BL\\nimport Data.List (intercalate)\\nimport Data.Version (showVersion)\\nimport Data.Set (Set)\\nimport qualified Data.Set as Set\\nimport Text.Parsec\\nimport Text.Parsec.Error\\nimport qualified Text.Pandoc.UTF8 as UTF8\\nimport Paths_pandoc (version)\\n\\n-- | Version number of pandoc library.\\npandocVersion :: String\\npandocVersion = showVersion version\\n\\nparseFormatSpec :: String\\n -> Either ParseError (String, Set Extension -> Set Extension)\\nparseFormatSpec = parse formatSpec \"\"\\n where formatSpec = do\\n name <- formatName\\n extMods <- many extMod\\n return (name, foldl (.) id extMods)\\n formatName = many1 $ noneOf \"-+\"\\n extMod = do\\n polarity <- oneOf \"-+\"\\n name <- many $ noneOf \"-+\"\\n ext <- case safeRead (\"Ext_\" ++ name) of\\n Just n -> return n\\n Nothing\\n | name == \"lhs\" -> return Ext_literate_haskell\\n | otherwise -> fail $ \"Unknown extension: \" ++ name\\n return $ case polarity of\\n \\'-\\' -> Set.delete ext\\n _ -> Set.insert ext\\n\\ndata Reader = StringReader (ReaderOptions -> String -> IO Pandoc)\\n | ByteStringReader (ReaderOptions -> BL.ByteString -> IO (Pandoc, MediaBag))\\n\\nmkStringReader :: (ReaderOptions -> String -> Pandoc) -> Reader\\nmkStringReader r = StringReader (\\\\o s -> return $ r o s)\\n\\nmkStringReaderWithWarnings :: (ReaderOptions -> String -> (Pandoc, [String])) -> Reader\\nmkStringReaderWithWarnings r = StringReader $ \\\\o s -> do\\n let (doc, warnings) = r o s\\n mapM_ warn warnings\\n return doc\\n\\nmkBSReader :: (ReaderOptions -> BL.ByteString -> (Pandoc, MediaBag)) -> Reader\\nmkBSReader r = ByteStringReader (\\\\o s -> return $ r o s)\\n\\n-- | Association list of formats and readers.\\nreaders :: [(String, Reader)]\\nreaders = [ (\"native\" , StringReader $ \\\\_ s -> return $ readNative s)\\n ,(\"json\" , mkStringReader readJSON )\\n ,(\"markdown\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_strict\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_phpextra\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_github\" , mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"markdown_mmd\", mkStringReaderWithWarnings readMarkdownWithWarnings)\\n ,(\"rst\" , mkStringReaderWithWarnings readRSTWithWarnings )\\n ,(\"mediawiki\" , mkStringReader readMediaWiki)\\n ,(\"docbook\" , mkStringReader readDocBook)\\n ,(\"opml\" , mkStringReader readOPML)\\n ,(\"org\" , mkStringReader readOrg)\\n ,(\"textile\" , mkStringReader readTextile) -- TODO : textile+lhs\\n ,(\"html\" , mkStringReader readHtml)\\n ,(\"latex\" , mkStringReader readLaTeX)\\n ,(\"haddock\" , mkStringReader readHaddock)\\n ,(\"twiki\" , mkStringReader readTWiki)\\n ,(\"docx\" , mkBSReader readDocx)\\n ,(\"t2t\" , mkStringReader readTxt2TagsNoMacros)\\n ,(\"epub\" , mkBSReader readEPUB)\\n ]\\n\\ndata Writer = PureStringWriter (WriterOptions -> Pandoc -> String)\\n | IOStringWriter (WriterOptions -> Pandoc -> IO String)\\n | IOByteStringWriter (WriterOptions -> Pandoc -> IO BL.ByteString)\\n\\n-- | Association list of formats and writers.\\nwriters :: [ ( String, Writer ) ]\\nwriters = [\\n (\"native\" , PureStringWriter writeNative)\\n ,(\"json\" , PureStringWriter writeJSON)\\n ,(\"docx\" , IOByteStringWriter writeDocx)\\n ,(\"odt\" , IOByteStringWriter writeODT)\\n ,(\"epub\" , IOByteStringWriter $ \\\\o ->\\n writeEPUB o{ writerEpubVersion = Just EPUB2 })\\n ,(\"epub3\" , IOByteStringWriter $ \\\\o ->\\n writeEPUB o{ writerEpubVersion = Just EPUB3 })\\n ,(\"fb2\" , IOStringWriter writeFB2)\\n ,(\"html\" , PureStringWriter writeHtmlString)\\n ,(\"html5\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerHtml5 = True })\\n ,(\"icml\" , PureStringWriter writeICML)\\n ,(\"s5\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = S5Slides\\n , writerTableOfContents = False })\\n ,(\"slidy\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = SlidySlides })\\n ,(\"slideous\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = SlideousSlides })\\n ,(\"dzslides\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = DZSlides\\n , writerHtml5 = True })\\n ,(\"revealjs\" , PureStringWriter $ \\\\o ->\\n writeHtmlString o{ writerSlideVariant = RevealJsSlides\\n , writerHtml5 = True })\\n ,(\"docbook\" , PureStringWriter writeDocbook)\\n ,(\"opml\" , PureStringWriter writeOPML)\\n ,(\"opendocument\" , PureStringWriter writeOpenDocument)\\n ,(\"latex\" , PureStringWriter writeLaTeX)\\n ,(\"beamer\" , PureStringWriter $ \\\\o ->\\n writeLaTeX o{ writerBeamer = True })\\n ,(\"context\" , PureStringWriter writeConTeXt)\\n ,(\"texinfo\" , PureStringWriter writeTexinfo)\\n ,(\"man\" , PureStringWriter writeMan)\\n ,(\"markdown\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_strict\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_phpextra\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_github\" , PureStringWriter writeMarkdown)\\n ,(\"markdown_mmd\" , PureStringWriter writeMarkdown)\\n ,(\"plain\" , PureStringWriter writePlain)\\n ,(\"rst\" , PureStringWriter writeRST)\\n ,(\"mediawiki\" , PureStringWriter writeMediaWiki)\\n ,(\"dokuwiki\" , PureStringWriter writeDokuWiki)\\n ,(\"textile\" , PureStringWriter writeTextile)\\n ,(\"rtf\" , IOStringWriter writeRTFWithEmbeddedImages)\\n ,(\"org\" , PureStringWriter writeOrg)\\n ,(\"asciidoc\" , PureStringWriter writeAsciiDoc)\\n ,(\"haddock\" , PureStringWriter writeHaddock)\\n ]\\n\\ngetDefaultExtensions :: String -> Set Extension\\ngetDefaultExtensions \"markdown_strict\" = strictExtensions\\ngetDefaultExtensions \"markdown_phpextra\" = phpMarkdownExtraExtensions\\ngetDefaultExtensions \"markdown_mmd\" = multimarkdownExtensions\\ngetDefaultExtensions \"markdown_github\" = githubMarkdownExtensions\\ngetDefaultExtensions \"markdown\" = pandocExtensions\\ngetDefaultExtensions \"plain\" = pandocExtensions\\ngetDefaultExtensions \"org\" = Set.fromList [Ext_citations]\\ngetDefaultExtensions \"textile\" = Set.fromList [Ext_auto_identifiers]\\ngetDefaultExtensions \"html\" = Set.fromList [Ext_auto_identifiers,\\n Ext_native_divs,\\n Ext_native_spans]\\ngetDefaultExtensions \"html5\" = getDefaultExtensions \"html\"\\ngetDefaultExtensions \"epub\" = Set.fromList [Ext_auto_identifiers,\\n Ext_raw_html,\\n Ext_native_divs,\\n Ext_native_spans,\\n Ext_epub_html_exts]\\ngetDefaultExtensions _ = Set.fromList [Ext_auto_identifiers]\\n\\n-- | Retrieve reader based on formatSpec (format+extensions).\\ngetReader :: String -> Either String Reader\\ngetReader s =\\n case parseFormatSpec s of\\n Left e -> Left $ intercalate \"\\\\n\" $ [m | Message m <- errorMessages e]\\n Right (readerName, setExts) ->\\n case lookup readerName readers of\\n Nothing -> Left $ \"Unknown reader: \" ++ readerName\\n Just (StringReader r) -> Right $ StringReader $ \\\\o ->\\n r o{ readerExtensions = setExts $\\n getDefaultExtensions readerName }\\n Just (ByteStringReader r) -> Right $ ByteStringReader $ \\\\o ->\\n r o{ readerExtensions = setExts $\\n getDefaultExtensions readerName }\\n\\n-- | Retrieve writer based on formatSpec (format+extensions).\\ngetWriter :: String -> Either String Writer\\ngetWriter s\\n = case parseFormatSpec s of\\n Left e -> Left $ intercalate \"\\\\n\" $ [m | Message m <- errorMessages e]\\n Right (writerName, setExts) ->\\n case lookup writerName writers of\\n Nothing -> Left $ \"Unknown writer: \" ++ writerName\\n Just (PureStringWriter r) -> Right $ PureStringWriter $\\n \\\\o -> r o{ writerExtensions = setExts $\\n getDefaultExtensions writerName }\\n Just (IOStringWriter r) -> Right $ IOStringWriter $\\n \\\\o -> r o{ writerExtensions = setExts $\\n getDefaultExtensions writerName }\\n Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $\\n \\\\o -> r o{ writerExtensions = setExts $\\n getDefaultExtensions writerName }\\n\\n{-# DEPRECATED toJsonFilter \"Use \\'toJSONFilter\\' from \\'Text.Pandoc.JSON\\' instead\" #-}\\n-- | Deprecated. Use @toJSONFilter@ from @Text.Pandoc.JSON@ instead.\\nclass ToJSONFilter a => ToJsonFilter a\\n where toJsonFilter :: a -> IO ()\\n toJsonFilter = toJSONFilter\\n\\nreadJSON :: ReaderOptions -> String -> Pandoc\\nreadJSON _ = either error id . eitherDecode\\' . UTF8.fromStringLazy\\n\\nwriteJSON :: WriterOptions -> Pandoc -> String\\nwriteJSON _ = UTF8.toStringLazy . encode',\n", - " 'reverseDependencies :: ModuleGraph -> M.Map ModuleName [ModuleName]\\nreverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ]\\n where\\n combine :: (Ord a) => [(a, b)] -> M.Map a [b]\\n combine = M.fromList . map ((fst . head) &&& map snd) . groupBy ((==) `on` fst) . sortBy (compare `on` fst)',\n", - " '{- git-annex extra config files\\n -\\n - Copyright 2012 Joey Hess \\n -\\n - Licensed under the GNU GPL version 3 or higher.\\n -}\\n\\nmodule Config.Files where\\n\\nimport Common\\nimport Utility.Tmp\\nimport Utility.FreeDesktop\\n\\n{- ~/.config/git-annex/file -}\\nuserConfigFile :: FilePath -> IO FilePath\\nuserConfigFile file = do\\n\\tdir <- userConfigDir\\n\\treturn $ dir \"git-annex\" file\\n\\nautoStartFile :: IO FilePath\\nautoStartFile = userConfigFile \"autostart\"\\n\\n{- Returns anything listed in the autostart file (which may not exist). -}\\nreadAutoStartFile :: IO [FilePath]\\nreadAutoStartFile = do\\n\\tf <- autoStartFile\\n\\tnub . map dropTrailingPathSeparator . lines\\n\\t\\t<$> catchDefaultIO \"\" (readFile f)\\n\\nmodifyAutoStartFile :: ([FilePath] -> [FilePath]) -> IO ()\\nmodifyAutoStartFile func = do\\n\\tdirs <- readAutoStartFile\\n\\tlet dirs\\' = nubBy equalFilePath $ func dirs\\n\\twhen (dirs\\' /= dirs) $ do\\n\\t\\tf <- autoStartFile\\n\\t\\tcreateDirectoryIfMissing True (parentDir f)\\n\\t\\tviaTmp writeFile f $ unlines dirs\\'\\n\\n{- Adds a directory to the autostart file. If the directory is already\\n - present, it\\'s moved to the top, so it will be used as the default\\n - when opening the webapp. -}\\naddAutoStartFile :: FilePath -> IO ()\\naddAutoStartFile path = modifyAutoStartFile $ (:) path\\n\\n{- Removes a directory from the autostart file. -}\\nremoveAutoStartFile :: FilePath -> IO ()\\nremoveAutoStartFile path = modifyAutoStartFile $\\n\\tfilter (not . equalFilePath path)\\n\\n{- The path to git-annex is written here; which is useful when cabal\\n - has installed it to some awful non-PATH location. -}\\nprogramFile :: IO FilePath\\nprogramFile = userConfigFile \"program\"\\n\\n{- Returns a command to run for git-annex. -}\\nreadProgramFile :: IO FilePath\\nreadProgramFile = do\\n\\tprogramfile <- programFile\\n\\tp <- catchDefaultIO cmd $ \\n\\t\\tfromMaybe cmd . headMaybe . lines <$> readFile programfile\\n\\tifM (inPath p)\\n\\t\\t( return p\\n\\t\\t, ifM (inPath cmd)\\n\\t\\t\\t( return cmd\\n\\t\\t\\t, error $ \"cannot find git-annex program in PATH or in the location listed in \" ++ programfile\\n\\t\\t\\t)\\n\\t\\t)\\n where\\n\\tcmd = \"git-annex\"',\n", - " \"(define subst-f\\n (lambda (new old l)\\n (cond\\n ((null? l) '())\\n ((eq? (car l) old)\\n (cons new (cdr l)))\\n (else\\n (cons (car l) (subst new old (cdr l)))))))\\n\\n; The seqS function is what subst does that neither insertL nor insertR do\\n;\\n(define seqS\\n (lambda (new old l)\\n (cons new l)))\\n\\n; subst is now just (insret-g seqS)\\n;\\n(define subst (insert-g seqS))\",\n", - " '(define add1\\n (lambda (n) (+ n 1)))',\n", - " '(define-lib-primitive (length lst)\\n (if (null? lst)\\n 0\\n (fxadd1 (length (cdr lst)))))\\n\\n(define-lib-primitive (fill args setop)\\n (letrec ([rec (lambda (index args)\\n (unless (null? args)\\n (setop index (car args))\\n (rec (fxadd1 index) (cdr args))))])\\n (rec 0 args)))\\n \\n(define-lib-primitive (vector . args)\\n (let ([v (make-vector (length args))])\\n (fill args (lambda (index arg) (vector-set! v index arg)))\\n v))\\n\\n(define-lib-primitive (string . args)\\n (let ([s (make-string (length args))])\\n (fill args (lambda (index arg) (string-set! s index arg)))\\n s))\\n\\n(define-lib-primitive (list . args)\\n args)\\n\\n(define-lib-primitive (make_cell value)\\n (cons value \\'()))\\n\\n(define-lib-primitive (cell_get cell)\\n (car cell))\\n\\n(define-lib-primitive (cell_set cell value)\\n (set-car! cell value))\\n\\n(define-lib-primitive __symbols__\\n (make_cell \\'()))\\n\\n(define-lib-primitive (string=? s1 s2)\\n (letrec ([rec (lambda (index)\\n (or (fx= index (string-length s1))\\n (and (char= (string-ref s1 index) (string-ref s2 index))\\n (rec (fxadd1 index)))))])\\n (and (string? s1) (string? s2) (fx= (string-length s1) (string-length s2)) (rec 0))))\\n \\n(define-lib-primitive (__find_symbol__ str)\\n (letrec ([rec (lambda (symbols)\\n (cond\\n [(null? symbols) #f]\\n [(string=? str (string-symbol (car symbols))) (car symbols)]\\n [else (rec (cdr symbols))]))])\\n (rec (cell_get __symbols__))))\\n\\n(define-lib-primitive (string->symbol str)\\n (or (__find_symbol__ str)\\n (let ([symbol (make-symbol str)])\\n (cell_set __symbols__ (cons symbol (cell_get __symbols__)))\\n symbol)))\\n\\n(define-lib-primitive (error . args)\\n (foreign-call \"ik_error\" args))\\n\\n(define-lib-primitive (log msg)\\n (foreign-call \"ik_log\" msg))\\n\\n(define-lib-primitive (string-set! s i c)\\n (cond\\n [(not (string? s)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (char? c)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)]\\n [else ($string-set! s i c)]))\\n\\n(define-lib-primitive (string-ref s i)\\n (cond\\n [(not (string? s)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (string-length s)))) (error)]\\n [else ($string-ref s i)]))\\n\\n(define-lib-primitive (vector-set! v i e)\\n (cond\\n [(not (vector? v)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)]\\n [else ($vector-set! v i e)]))\\n\\n(define-lib-primitive (vector-ref v i)\\n (cond\\n [(not (vector? v)) (error)]\\n [(not (fixnum? i)) (error)]\\n [(not (and (fx<= 0 i) (fx< i (vector-length v)))) (error)]\\n [else ($vector-ref v i)]))\\n\\n(define-lib-primitive (liftneg f a b)\\n (cond\\n [(and (fx< a 0) (fx>= b 0))\\n (fx- 0 (f (fx- 0 a) b))]\\n [(and (fx>= a 0) (fx< b 0))\\n (fx- 0 (f a (fx- 0 b)))]\\n [(and (fx< a 0) (fx< b 0))\\n (f (fx- 0 a) (fx- 0 b))]\\n [else\\n (f a b)]))\\n\\n(define-lib-primitive (liftneg1 f a b)\\n (cond\\n [(and (fx< a 0) (fx>= b 0))\\n (fx- 0 (f (fx- 0 a) b))]\\n [(and (fx>= a 0) (fx< b 0))\\n (f a (fx- 0 b))]\\n [(and (fx< a 0) (fx< b 0))\\n (fx- 0 (f (fx- 0 a) (fx- 0 b)))]\\n [else\\n (f a b)]))\\n \\n(define-lib-primitive (fxquotient a b)\\n (liftneg (lambda (a b) ($fxquotient a b)) a b))\\n\\n(define-lib-primitive (fxremainder a b)\\n (liftneg1 (lambda (a b) ($fxremainder a b)) a b))\\n\\n(define-lib-primitive (exit . args)\\n (let ([status (if (null? args) 0 (car args))])\\n (foreign-call \"exit\" status)))\\n\\n(define-lib-primitive (s_write fd str len)\\n (foreign-call \"s_write\" fd str len))\\n\\n(define-lib-primitive stdout\\n (make-output-port \"\" 1))\\n\\n(define-lib-primitive (current-output-port)\\n stdout)\\n\\n(define-lib-primitive BUFFER_SIZE 4096)\\n\\n(define-lib-primitive (open-output-file fname . args)\\n (let ([fd (foreign-call \"s_open_write\" fname)])\\n (make-output-port fname fd)))\\n \\n(define-lib-primitive (make-output-port fname fd)\\n (vector \\'output-port fname fd (make-string BUFFER_SIZE) 0 BUFFER_SIZE))\\n\\n(define-lib-primitive (output-port-fname port)\\n (vector-ref port 1))\\n\\n(define-lib-primitive (output-port-fd port)\\n (vector-ref port 2))\\n\\n(define-lib-primitive (output-port-buffer port)\\n (vector-ref port 3))\\n\\n(define-lib-primitive (output-port-buffer-index port)\\n (vector-ref port 4))\\n\\n(define-lib-primitive (output-port-buffer-size port)\\n (vector-ref port 5))\\n\\n(define-lib-primitive (set-output-port-buffer-index! port index)\\n (vector-set! port 4 index))\\n\\n(define-lib-primitive (inc-output-port-buffer-index! port)\\n (set-output-port-buffer-index! port (fxadd1 (output-port-buffer-index port))))\\n\\n(define-lib-primitive (write-char c (port (current-output-port)))\\n (string-set! (output-port-buffer port) (output-port-buffer-index port) c)\\n (inc-output-port-buffer-index! port)\\n (when (fx= (output-port-buffer-index port) (output-port-buffer-size port))\\n\\t(output-port-write-buffer port)))\\n\\n(define-lib-primitive (output-port? x)\\n (and (vector? x) (fx= (vector-length x) 6) (eq? \\'output-port (vector-ref x 0))))\\n\\n(define-lib-primitive (output-port-write-buffer port)\\n (s_write (output-port-fd port)\\n\\t (output-port-buffer port)\\n\\t (output-port-buffer-index port))\\n (set-output-port-buffer-index! port 0))\\n\\n(define-lib-primitive (flush-output-port (port (current-output-port)))\\n (output-port-write-buffer port)\\n (foreign-call \"s_fflush\" (output-port-fd port)))\\n\\n(define-lib-primitive (close-output-port port)\\n (flush-output-port port)\\n (unless (string=? \"\" (output-port-fname port))\\n\\t (foreign-call \"s_close\" (output-port-fd port))))\\n\\n(define-lib-primitive (write x (port (current-output-port)))\\n (flush-output-port port)\\n ;; This is cheating... should write it in Scheme.\\n (foreign-call \"scheme_write\" (output-port-fd port) x 0)\\n (flush-output-port port))\\n\\n(define-lib-primitive (display x (port (current-output-port)))\\n (flush-output-port port)\\n (foreign-call \"scheme_write\" (output-port-fd port) x 2)\\n (flush-output-port port))\\n\\n(define-lib-primitive (open-input-file fname . args)\\n (let ([fd (foreign-call \"s_open_read\" fname)])\\n (make-input-port fname fd)))\\n \\n(define-lib-primitive (make-input-port fname fd)\\n (vector \\'input-port fname fd))\\n\\n(define-lib-primitive (input-port-fname port)\\n (vector-ref port 1))\\n\\n(define-lib-primitive (input-port-fd port)\\n (vector-ref port 2))\\n\\n(define-lib-primitive (input-port? x)\\n (and (vector? x) (fx= (vector-length x) 3) (eq? \\'input-port (vector-ref x 0))))\\n\\n(define-lib-primitive (read-char port)\\n (foreign-call \"s_read_char\" (input-port-fd port)))\\n\\n(define-lib-primitive (close-input-port port)\\n (foreign-call \"s_close\" (input-port-fd port)))',\n", - " \"/**\\n * Interface to represent a persistence store for archives\\n *\\n * @author James Kojo\\n * @author Vasanth Asokan\\n */\\npublic interface ArchiveRepository {\\n /**\\n * Get the ID of this repository\\n * @return the id string.\\n */\\n public String getRepositoryId();\\n\\n /**\\n * Get the default view into this repository.\\n * @return the default repository view.\\n */\\n public RepositoryView getDefaultView();\\n\\n /**\\n * Get a specific named view into this repository.\\n *\\n * @param view the name of the view.\\n * @return a {@link RepositoryView} that matches the given name or null if\\n * one wasn't found.\\n * @throws UnsupportedOperationException\\n * if this repository does not support named views.\\n */\\n public RepositoryView getView(String view);\\n\\n /**\\n * Insert a Jar into the repository\\n * @param jarScriptArchive script archive which describes the jar and\\n * the ModuleSpec which should be inserted\\n */\\n public void insertArchive(JarScriptArchive jarScriptArchive)\\n throws IOException;\\n\\n /**\\n * Insert a Jar into the repository\\n * @param jarScriptArchive script archive which describes the jar and\\n * the ModuleSpec which should be inserted\\n * @param initialDeploySpecs a set of initial deployment specs.\\n * @throws UnsupportedOperationException if this repository does not support\\n * adding deploy specs to a module.\\n */\\n public void insertArchive(JarScriptArchive jarScriptArchive, Map initialDeploySpecs)\\n throws IOException;\\n\\n /**\\n * Get all of the {@link ScriptArchive}s for the given set of moduleIds.\\n *\\n * @param moduleIds keys to search for\\n * @return set of ScriptArchives retrieved from the database\\n */\\n public Set getScriptArchives(Set moduleIds) throws IOException;\\n\\n /**\\n * Delete an archive by ID\\n * @param moduleId module id to delete\\n * @throws IOException\\n */\\n public void deleteArchive(ModuleId moduleId) throws IOException;\\n}\",\n", - " '/*\\n * Copyright 2002-2008 the original author or authors.\\n *\\n * Licensed under the Apache License, Version 2.0 (the \"License\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \"AS IS\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n */\\n\\npackage org.springframework.core;\\n\\n/**\\n * Common interface for managing aliases. Serves as super-interface for\\n * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}.\\n *\\n * @author Juergen Hoeller\\n * @since 2.5.2\\n */\\npublic interface AliasRegistry {\\n\\n\\t/**\\n\\t * Given a name, register an alias for it.\\n\\t * @param name the canonical name\\n\\t * @param alias the alias to be registered\\n\\t * @throws IllegalStateException if the alias is already in use\\n\\t * and may not be overridden\\n\\t */\\n\\tvoid registerAlias(String name, String alias);\\n\\n\\t/**\\n\\t * Remove the specified alias from this registry.\\n\\t * @param alias the alias to remove\\n\\t * @throws IllegalStateException if no such alias was found\\n\\t */\\n\\tvoid removeAlias(String alias);\\n\\n\\t/**\\n\\t * Determine whether this given name is defines as an alias\\n\\t * (as opposed to the name of an actually registered component).\\n\\t * @param beanName the bean name to check\\n\\t * @return whether the given name is an alias\\n\\t */\\n\\tboolean isAlias(String beanName);\\n\\n\\t/**\\n\\t * Return the aliases for the given name, if defined.\\n\\t * @param name the name to check for aliases\\n\\t * @return the aliases, or an empty array if none\\n\\t */\\n\\tString[] getAliases(String name);\\n\\n}',\n", - " 'package com.github.pathikrit\\n\\nimport scala.annotation.StaticAnnotation\\n\\nclass MetaRest extends StaticAnnotation {\\n def macroTransform(annottees: Any*): Any = macro MetaRest.impl\\n}\\n\\nobject MetaRest {\\n sealed trait MethodAnnotations extends StaticAnnotation\\n class get extends MethodAnnotations\\n class put extends MethodAnnotations\\n class post extends MethodAnnotations\\n class patch extends MethodAnnotations\\n object MethodAnnotations {\\n val values = List(\"get\", \"post\", \"put\", \"patch\") //TODO: use some enum/sealed trait macro to do this automatically\\n }\\n\\n def impl(c: macros.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {\\n import c.universe._\\n\\n def withCompileError[A](msg: String)(block: => A): A = try {\\n block\\n } catch {\\n case _: MatchError => c.abort(c.enclosingPosition, s\"@MetaRest: $msg\")\\n }\\n\\n def generateModels(fields: List[ValDef]) = {\\n val fieldsWithAnnotations = fields.map(_.mods.annotations).zip(fields)\\n val newFields = fieldsWithAnnotations flatMap { case (annotations, field) =>\\n annotations.map(_ -> field) collect {\\n case (q\"new patch\", q\"$accessor val $vname: $tpe\") => \"patch\" -> q\"$accessor val $vname: Option[$tpe] = None\"\\n case (q\"new $annotation\", f) if MethodAnnotations.values contains annotation.toString => annotation.toString -> f.duplicate\\n }\\n }\\n newFields.groupBy(_._1) map { case (annotation, values) =>\\n val (className, classFields) = (macros.toTypeName(c)(annotation.capitalize), values.map(_._2))\\n q\"@com.kifi.macros.json case class $className(..$classFields)\" //TODO: Switch back to jsonstrict once this is fixed: https://github.com/kifi/json-annotation/issues/7\\n }\\n }\\n\\n def modifiedDeclaration(classDecl: ClassDef, compDeclOpt: Option[ModuleDef] = None) = {\\n val (className, fields) = withCompileError(\"must annotate a case class\") {\\n val q\"case class $className(..$fields) extends ..$bases { ..$body }\" = classDecl\\n (className, fields)\\n }\\n\\n val compDecl = compDeclOpt map { compDecl =>\\n val q\"object $obj extends ..$bases { ..$body }\" = compDecl\\n q\"\"\"\\n object $obj extends ..$bases {\\n ..$body\\n ..${generateModels(fields)}\\n }\\n \"\"\"\\n } getOrElse {\\n q\"\"\"\\n object ${className.toTermName} {\\n ..${generateModels(fields)}\\n }\\n \"\"\"\\n }\\n\\n c.Expr(q\"\"\"\\n $classDecl\\n $compDecl\\n \"\"\")\\n }\\n\\n withCompileError(\"must annotate a class\") {\\n annottees.map(_.tree) match {\\n case (classDecl: ClassDef) :: Nil => modifiedDeclaration(classDecl)\\n case (classDecl: ClassDef) :: (compDecl: ModuleDef) :: Nil => modifiedDeclaration(classDecl, Some(compDecl))\\n }\\n }\\n }\\n}',\n", - " \"/* sbt -- Simple Build Tool\\n * Copyright 2010, 2011 Mark Harrah\\n */\\npackage object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtra with sbt.impl.DependencyBuilders\\n with sbt.PathExtra with sbt.ProjectExtra with sbt.DependencyFilterExtra with sbt.BuildExtra with sbt.TaskMacroExtra\\n with sbt.ScopeFilter.Make {\\n type Setting[T] = Def.Setting[T]\\n type ScopedKey[T] = Def.ScopedKey[T]\\n type SettingsDefinition = Def.SettingsDefinition\\n type File = java.io.File\\n type URI = java.net.URI\\n type URL = java.net.URL\\n\\n object CompileOrder {\\n val JavaThenScala = xsbti.compile.CompileOrder.JavaThenScala\\n val ScalaThenJava = xsbti.compile.CompileOrder.ScalaThenJava\\n val Mixed = xsbti.compile.CompileOrder.Mixed\\n }\\n type CompileOrder = xsbti.compile.CompileOrder\\n\\n implicit def maybeToOption[S](m: xsbti.Maybe[S]): Option[S] =\\n if (m.isDefined) Some(m.get) else None\\n def uri(s: String): URI = new URI(s)\\n def file(s: String): File = new File(s)\\n def url(s: String): URL = new URL(s)\\n\\n final val ThisScope = Scope.ThisScope\\n final val GlobalScope = Scope.GlobalScope\\n\\n import sbt.{ Configurations => C }\\n final val Compile = C.Compile\\n final val Test = C.Test\\n final val Runtime = C.Runtime\\n final val IntegrationTest = C.IntegrationTest\\n final val Default = C.Default\\n final val Docs = C.Docs\\n final val Sources = C.Sources\\n final val Provided = C.Provided\\n // java.lang.System is more important, so don't alias this one\\n //\\tfinal val System = C.System\\n final val Optional = C.Optional\\n def config(s: String): Configuration = Configurations.config(s)\\n\\n import language.experimental.macros\\n def settingKey[T](description: String): SettingKey[T] = macro std.KeyMacro.settingKeyImpl[T]\\n def taskKey[T](description: String): TaskKey[T] = macro std.KeyMacro.taskKeyImpl[T]\\n def inputKey[T](description: String): InputKey[T] = macro std.KeyMacro.inputKeyImpl[T]\\n}\",\n", - " 'class View\\n{\\n /**\\n * Data available to the view templates\\n * @var \\\\Slim\\\\Helper\\\\Set\\n */\\n protected $data;\\n /**\\n * Path to templates base directory (without trailing slash)\\n * @var string\\n */\\n protected $templatesDirectory;\\n /**\\n * Constructor\\n */\\n public function __construct()\\n {\\n $this->data = new \\\\Slim\\\\Helper\\\\Set();\\n }\\n /********************************************************************************\\n * Data methods\\n *******************************************************************************/\\n /**\\n * Does view data have value with key?\\n * @param string $key\\n * @return boolean\\n */\\n public function has($key)\\n {\\n return $this->data->has($key);\\n }\\n /**\\n * Return view data value with key\\n * @param string $key\\n * @return mixed\\n */\\n public function get($key)\\n {\\n return $this->data->get($key);\\n }\\n /**\\n * Set view data value with key\\n * @param string $key\\n * @param mixed $value\\n */\\n public function set($key, $value)\\n {\\n $this->data->set($key, $value);\\n }\\n /**\\n * Set view data value as Closure with key\\n * @param string $key\\n * @param mixed $value\\n */\\n public function keep($key, \\\\Closure $value)\\n {\\n $this->data->keep($key, $value);\\n }\\n /**\\n * Return view data\\n * @return array\\n */\\n public function all()\\n {\\n return $this->data->all();\\n }\\n /**\\n * Replace view data\\n * @param array $data\\n */\\n public function replace(array $data)\\n {\\n $this->data->replace($data);\\n }\\n /**\\n * Clear view data\\n */\\n public function clear()\\n {\\n $this->data->clear();\\n }\\n /********************************************************************************\\n * Legacy data methods\\n *******************************************************************************/\\n /**\\n * DEPRECATION WARNING! This method will be removed in the next major point release\\n *\\n * Get data from view\\n */\\n public function getData($key = null)\\n {\\n if (!is_null($key)) {\\n return isset($this->data[$key]) ? $this->data[$key] : null;\\n } else {\\n return $this->data->all();\\n }\\n }\\n /**\\n * DEPRECATION WARNING! This method will be removed in the next major point release\\n *\\n * Set data for view\\n */\\n public function setData()\\n {\\n $args = func_get_args();\\n if (count($args) === 1 && is_array($args[0])) {\\n $this->data->replace($args[0]);\\n } elseif (count($args) === 2) {\\n // Ensure original behavior is maintained. DO NOT invoke stored Closures.\\n if (is_object($args[1]) && method_exists($args[1], \\'__invoke\\')) {\\n $this->data->set($args[0], $this->data->protect($args[1]));\\n } else {\\n $this->data->set($args[0], $args[1]);\\n }\\n } else {\\n throw new \\\\InvalidArgumentException(\\'Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`\\');\\n }\\n }\\n /**\\n * DEPRECATION WARNING! This method will be removed in the next major point release\\n *\\n * Append data to view\\n * @param array $data\\n */\\n public function appendData($data)\\n {\\n if (!is_array($data)) {\\n throw new \\\\InvalidArgumentException(\\'Cannot append view data. Expected array argument.\\');\\n }\\n $this->data->replace($data);\\n }\\n /********************************************************************************\\n * Resolve template paths\\n *******************************************************************************/\\n /**\\n * Set the base directory that contains view templates\\n * @param string $directory\\n * @throws \\\\InvalidArgumentException If directory is not a directory\\n */\\n public function setTemplatesDirectory($directory)\\n {\\n $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR);\\n }\\n /**\\n * Get templates base directory\\n * @return string\\n */\\n public function getTemplatesDirectory()\\n {\\n return $this->templatesDirectory;\\n }\\n /**\\n * Get fully qualified path to template file using templates base directory\\n * @param string $file The template file pathname relative to templates base directory\\n * @return string\\n */\\n public function getTemplatePathname($file)\\n {\\n return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR);\\n }\\n /********************************************************************************\\n * Rendering\\n *******************************************************************************/\\n /**\\n * Display template\\n *\\n * This method echoes the rendered template to the current output buffer\\n *\\n * @param string $template Pathname of template file relative to templates directory\\n * @param array $data Any additonal data to be passed to the template.\\n */\\n public function display($template, $data = null)\\n {\\n echo $this->fetch($template, $data);\\n }\\n /**\\n * Return the contents of a rendered template file\\n *\\n * @param string $template The template pathname, relative to the template base directory\\n * @param array $data Any additonal data to be passed to the template.\\n * @return string The rendered template\\n */\\n public function fetch($template, $data = null)\\n {\\n return $this->render($template, $data);\\n }\\n /**\\n * Render a template file\\n *\\n * NOTE: This method should be overridden by custom view subclasses\\n *\\n * @param string $template The template pathname, relative to the template base directory\\n * @param array $data Any additonal data to be passed to the template.\\n * @return string The rendered template\\n * @throws \\\\RuntimeException If resolved template pathname is not a valid file\\n */\\n protected function render($template, $data = null)\\n {\\n $templatePathname = $this->getTemplatePathname($template);\\n if (!is_file($templatePathname)) {\\n throw new \\\\RuntimeException(\"View cannot render `$template` because the template does not exist\");\\n }\\n $data = array_merge($this->data->all(), (array) $data);\\n extract($data);\\n ob_start();\\n require $templatePathname;\\n return ob_get_clean();\\n }\\n}',\n", - " \" public function formatLocalized($format)\\n {\\n // Check for Windows to find and replace the %e\\n // modifier correctly\\n if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {\\n $format = preg_replace('#(?getContainer();\\n\\t\\t/**\\n\\t\\t * Controllers\\n\\t\\t */\\n\\t\\t$container->registerService('LostController', function(SimpleContainer $c) {\\n\\t\\t\\treturn new LostController(\\n\\t\\t\\t\\t$c->query('AppName'),\\n\\t\\t\\t\\t$c->query('Request'),\\n\\t\\t\\t\\t$c->query('URLGenerator'),\\n\\t\\t\\t\\t$c->query('UserManager'),\\n\\t\\t\\t\\t$c->query('Defaults'),\\n\\t\\t\\t\\t$c->query('L10N'),\\n\\t\\t\\t\\t$c->query('Config'),\\n\\t\\t\\t\\t$c->query('SecureRandom'),\\n\\t\\t\\t\\t$c->query('DefaultEmailAddress'),\\n\\t\\t\\t\\t$c->query('IsEncryptionEnabled')\\n\\t\\t\\t);\\n\\t\\t});\\n\\t\\t$container->registerService('UserController', function(SimpleContainer $c) {\\n\\t\\t\\treturn new UserController(\\n\\t\\t\\t\\t$c->query('AppName'),\\n\\t\\t\\t\\t$c->query('Request'),\\n\\t\\t\\t\\t$c->query('UserManager'),\\n\\t\\t\\t\\t$c->query('Defaults')\\n\\t\\t\\t);\\n\\t\\t});\\n\\t\\t/**\\n\\t\\t * Core class wrappers\\n\\t\\t */\\n\\t\\t$container->registerService('IsEncryptionEnabled', function() {\\n\\t\\t\\treturn \\\\OC_App::isEnabled('files_encryption');\\n\\t\\t});\\n\\t\\t$container->registerService('URLGenerator', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getURLGenerator();\\n\\t\\t});\\n\\t\\t$container->registerService('UserManager', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getUserManager();\\n\\t\\t});\\n\\t\\t$container->registerService('Config', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getConfig();\\n\\t\\t});\\n\\t\\t$container->registerService('L10N', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getL10N('core');\\n\\t\\t});\\n\\t\\t$container->registerService('SecureRandom', function(SimpleContainer $c) {\\n\\t\\t\\treturn $c->query('ServerContainer')->getSecureRandom();\\n\\t\\t});\\n\\t\\t$container->registerService('Defaults', function() {\\n\\t\\t\\treturn new \\\\OC_Defaults;\\n\\t\\t});\\n\\t\\t$container->registerService('DefaultEmailAddress', function() {\\n\\t\\t\\treturn Util::getDefaultEmailAddress('lostpassword-noreply');\\n\\t\\t});\\n\\t}\\n}\",\n", - " 'type name = string\\n\\nlet compare_label label1 label2 =\\n\\tlet compare_length = compare (String.length label1) (String.length label2) in\\n\\tif compare_length = 0 then\\n\\t\\tString.compare label1 label2\\n\\telse compare_length\\n\\n\\nmodule LabelMap = Map.Make(\\n\\tstruct\\n\\t\\ttype t = name\\n\\t\\tlet compare = compare_label\\n\\tend)\\n\\ntype expr =\\n\\t| Var of name (* variable *)\\n\\t| Call of expr * expr list (* application *)\\n\\t| Fun of name list * expr (* abstraction *)\\n\\t| Let of name * expr * expr (* let *)\\n\\t| RecordSelect of expr * name (* selecting value of label: `r.a` *)\\n\\t| RecordExtend of (expr list) LabelMap.t * expr (* extending a record: `{a = 1, b = 2 | r}` *)\\n\\t| RecordRestrict of expr * name (* deleting a label: `{r - a}` *)\\n\\t| RecordEmpty (* empty record: `{}` *)\\n\\t| Variant of name * expr (* new variant value: `:X a` *)\\n\\t| Case of expr * (name * name * expr) list * (name * expr) option\\n\\t\\t\\t(* a pattern-matching case expression:\\n\\t\\t\\t\\t\\tmatch e {\\n\\t\\t\\t\\t\\t\\t\\t:X a -> expr1\\n\\t\\t\\t\\t\\t\\t| :Y b -> expr2\\n\\t\\t\\t\\t\\t\\t...\\n\\t\\t\\t\\t\\t\\t| z -> default_expr (optional)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t*)\\n\\ntype id = int\\ntype level = int\\n\\ntype ty =\\n\\t| TConst of name (* type constant: `int` or `bool` *)\\n\\t| TApp of ty * ty list (* type application: `list[int]` *)\\n\\t| TArrow of ty list * ty (* function type: `(int, int) -> int` *)\\n\\t| TVar of tvar ref (* type variable *)\\n\\t| TRecord of row (* record type: `{...}` *)\\n\\t| TVariant of row (* variant type: `[...]` *)\\n\\t| TRowEmpty (* empty row: `<>` *)\\n\\t| TRowExtend of (ty list) LabelMap.t * row (* row extension: `
` *)\\n\\nand row = ty (* the kind of rows - empty row, row variable, or row extension *)\\n\\nand tvar =\\n\\t| Unbound of id * level\\n\\t| Link of ty\\n\\t| Generic of id\\n\\n\\nlet rec real_ty = function\\n\\t| TVar {contents = Link ty} -> real_ty ty\\n\\t| ty -> ty\\n\\nlet merge_label_maps label_map1 label_map2 =\\n\\tLabelMap.merge\\n\\t\\t(fun label maybe_ty_list1 maybe_ty_list2 ->\\n\\t\\t\\tmatch maybe_ty_list1, maybe_ty_list2 with\\n\\t\\t\\t\\t| None, None -> assert false\\n\\t\\t\\t\\t| None, (Some ty_list2) -> Some ty_list2\\n\\t\\t\\t\\t| (Some ty_list1), None -> Some ty_list1\\n\\t\\t\\t\\t| (Some ty_list1), (Some ty_list2) -> Some (ty_list1 @ ty_list2))\\n\\t\\tlabel_map1 label_map2\\n\\n(* Returns a label map with all field types and the type of the \"rest\",\\n which is either a type var or an empty row. *)\\nlet rec match_row_ty = function\\n\\t| TRowExtend(label_ty_map, rest_ty) -> begin\\n\\t\\t\\tmatch match_row_ty rest_ty with\\n\\t\\t\\t\\t| (rest_label_ty_map, rest_ty) when LabelMap.is_empty rest_label_ty_map ->\\n\\t\\t\\t\\t\\t\\t(label_ty_map, rest_ty)\\n\\t\\t\\t\\t| (rest_label_ty_map, rest_ty) ->\\n\\t\\t\\t\\t\\t\\t(merge_label_maps label_ty_map rest_label_ty_map, rest_ty)\\n\\t\\tend\\n\\t| TVar {contents = Link ty} -> match_row_ty ty\\n\\t| TVar _ as var -> (LabelMap.empty, var)\\n\\t| TRowEmpty -> (LabelMap.empty, TRowEmpty)\\n\\t| ty -> raise (Failure \"not a row\")\\n\\n(* Adds new bindings to a label map. Assumes all bindings (both\\n new and existing) are distinct. *)\\nlet add_distinct_labels label_el_map label_el_list =\\n\\tList.fold_left\\n\\t\\t(fun label_el_map (label, el) ->\\n\\t\\t\\tassert (not (LabelMap.mem label label_el_map)) ;\\n\\t\\t\\tLabelMap.add label el label_el_map)\\n\\tlabel_el_map label_el_list\\n\\nlet label_map_from_list label_el_list =\\n\\tadd_distinct_labels LabelMap.empty label_el_list\\n\\n\\n\\nlet string_of_expr expr : string =\\n\\tlet rec f is_simple = function\\n\\t\\t| Var name -> name\\n\\t\\t| Call(fn_expr, arg_list) ->\\n\\t\\t\\t\\tf true fn_expr ^ \"(\" ^ String.concat \", \" (List.map (f false) arg_list) ^ \")\"\\n\\t\\t| Fun(param_list, body_expr) ->\\n\\t\\t\\t\\tlet fun_str =\\n\\t\\t\\t\\t\\t\"fun \" ^ String.concat \" \" param_list ^ \" -> \" ^ f false body_expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tif is_simple then \"(\" ^ fun_str ^ \")\" else fun_str\\n\\t\\t| Let(var_name, value_expr, body_expr) ->\\n\\t\\t\\t\\tlet let_str =\\n\\t\\t\\t\\t\\t\"let \" ^ var_name ^ \" = \" ^ f false value_expr ^ \" in \" ^ f false body_expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tif is_simple then \"(\" ^ let_str ^ \")\" else let_str\\n\\t\\t| RecordEmpty -> \"{}\"\\n\\t\\t| RecordSelect(record_expr, label) -> f true record_expr ^ \".\" ^ label\\n\\t\\t| RecordRestrict(record_expr, label) -> \"{\" ^ f false record_expr ^ \" - \" ^ label ^ \"}\"\\n\\t\\t| RecordExtend(label_expr_map, rest_expr) ->\\n\\t\\t\\t\\tlet label_expr_str =\\n\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t(List.map\\n\\t\\t\\t\\t\\t\\t\\t(fun (label, expr_list) ->\\n\\t\\t\\t\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t(List.map (fun expr -> label ^ \" = \" ^ f false expr) expr_list))\\n\\t\\t\\t\\t\\t\\t\\t(LabelMap.bindings label_expr_map))\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlet rest_expr_str = match rest_expr with\\n\\t\\t\\t\\t\\t| RecordEmpty -> \"\"\\n\\t\\t\\t\\t\\t| expr -> \" | \" ^ f false expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\t\"{\" ^ label_expr_str ^ rest_expr_str ^ \"}\"\\n\\t\\t| Variant(label, value) ->\\n\\t\\t\\t\\tlet variant_str = \":\" ^ label ^ \" \" ^ f true value in\\n\\t\\t\\t\\tif is_simple then \"(\" ^ variant_str ^ \")\" else variant_str\\n\\t\\t| Case(expr, cases, maybe_default_case) ->\\n\\t\\t\\t\\tlet cases_str_list = List.map\\n\\t\\t\\t\\t\\t(fun (label, var_name, expr) ->\\n\\t\\t\\t\\t\\t\\t\"| :\" ^ label ^ \" \" ^ var_name ^ \" -> \" ^ f false expr)\\n\\t\\t\\t\\t\\tcases\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlet all_cases_str = match (cases_str_list, maybe_default_case) with\\n\\t\\t\\t\\t\\t| ([], Some (var_name, expr)) -> var_name ^ \" -> \" ^ f false expr\\n\\t\\t\\t\\t\\t| (cases_str_list, None) -> String.concat \"\" cases_str_list\\n\\t\\t\\t\\t\\t| (cases_str_list, Some (var_name, expr)) ->\\n\\t\\t\\t\\t\\t\\t\\tString.concat \"\" cases_str_list ^ \" | \" ^ var_name ^ \" -> \" ^ f false expr\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\t\"match \" ^ f false expr ^ \" { \" ^ all_cases_str ^ \" } \"\\n\\tin\\n\\tf false expr\\n\\nlet string_of_ty ty : string =\\n\\tlet id_name_map = Hashtbl.create 10 in\\n\\tlet count = ref 0 in\\n\\tlet next_name () =\\n\\t\\tlet i = !count in\\n\\t\\tincr count ;\\n\\t\\tlet name = String.make 1 (Char.chr (97 + i mod 26)) ^\\n\\t\\t\\tif i >= 26 then string_of_int (i / 26) else \"\"\\n\\t\\tin\\n\\t\\tname\\n\\tin\\n\\tlet rec f is_simple = function\\n\\t\\t| TConst name -> name\\n\\t\\t| TApp(ty, ty_arg_list) ->\\n\\t\\t\\t\\tf true ty ^ \"[\" ^ String.concat \", \" (List.map (f false) ty_arg_list) ^ \"]\"\\n\\t\\t| TArrow(param_ty_list, return_ty) ->\\n\\t\\t\\t\\tlet arrow_ty_str = match param_ty_list with\\n\\t\\t\\t\\t\\t| [param_ty] ->\\n\\t\\t\\t\\t\\t\\t\\tlet param_ty_str = f true param_ty in\\n\\t\\t\\t\\t\\t\\t\\tlet return_ty_str = f false return_ty in\\n\\t\\t\\t\\t\\t\\t\\tparam_ty_str ^ \" -> \" ^ return_ty_str\\n\\t\\t\\t\\t\\t| _ ->\\n\\t\\t\\t\\t\\t\\t\\tlet param_ty_list_str = String.concat \", \" (List.map (f false) param_ty_list) in\\n\\t\\t\\t\\t\\t\\t\\tlet return_ty_str = f false return_ty in\\n\\t\\t\\t\\t\\t\\t\\t\"(\" ^ param_ty_list_str ^ \") -> \" ^ return_ty_str\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tif is_simple then \"(\" ^ arrow_ty_str ^ \")\" else arrow_ty_str\\n\\t\\t| TVar {contents = Generic id} -> begin\\n\\t\\t\\t\\t\\ttry\\n\\t\\t\\t\\t\\t\\tHashtbl.find id_name_map id\\n\\t\\t\\t\\t\\twith Not_found ->\\n\\t\\t\\t\\t\\t\\tlet name = next_name () in\\n\\t\\t\\t\\t\\t\\tHashtbl.add id_name_map id name ;\\n\\t\\t\\t\\t\\t\\tname\\n\\t\\t\\t\\tend\\n\\t\\t| TVar {contents = Unbound(id, _)} -> \"_\" ^ string_of_int id\\n\\t\\t| TVar {contents = Link ty} -> f is_simple ty\\n\\t\\t| TRecord row_ty -> \"{\" ^ f false row_ty ^ \"}\"\\n\\t\\t| TVariant row_ty -> \"[\" ^ f false row_ty ^ \"]\"\\n\\t\\t| TRowEmpty -> \"\"\\n\\t\\t| TRowExtend _ as row_ty ->\\n\\t\\t\\t\\tlet (label_ty_map, rest_ty) = match_row_ty row_ty in\\n\\t\\t\\t\\tlet label_ty_str =\\n\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t(List.map\\n\\t\\t\\t\\t\\t\\t\\t(fun (label, ty_list) ->\\n\\t\\t\\t\\t\\t\\t\\t\\tString.concat \", \"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t(List.map (fun ty -> label ^ \" : \" ^ f false ty) ty_list))\\n\\t\\t\\t\\t\\t\\t\\t(LabelMap.bindings label_ty_map))\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlet rest_ty_str = match real_ty rest_ty with\\n\\t\\t\\t\\t\\t| TRowEmpty -> \"\"\\n\\t\\t\\t\\t\\t| TRowExtend _ -> assert false\\n\\t\\t\\t\\t\\t| other_ty -> \" | \" ^ f false other_ty\\n\\t\\t\\t\\tin\\n\\t\\t\\t\\tlabel_ty_str ^ rest_ty_str\\n\\tin\\n\\tlet ty_str = f false ty in\\n\\tif !count > 0 then\\n\\t\\tlet var_names = Hashtbl.fold (fun _ value acc -> value :: acc) id_name_map [] in\\n\\t\\t\"forall[\" ^ String.concat \" \" (List.sort String.compare var_names) ^ \"] \" ^ ty_str\\n\\telse\\n\\t\\tty_str',\n", - " 'let search_compiler_libs () =\\n prerr_endline \"I: Searching for OCaml compiler libraries\";\\n let stdlib = BaseEnv.var_get \"standard_library\" in\\n let ( / ) = Filename.concat in\\n try\\n List.find (fun path -> Sys.file_exists (path / \"types.cmi\") || Sys.file_exists (path / \"typing\" / \"types.cmi\")) [\\n stdlib;\\n stdlib / \"compiler-libs\";\\n stdlib / \"compiler-lib\";\\n stdlib / \"..\" / \"compiler-libs\";\\n stdlib / \"..\" / \"compiler-lib\";\\n ]\\n with Not_found ->\\n prerr_endline \"E: Cannot find compiler libraries! See the README for details.\";\\n exit 1']" - ] - } - ], - "prompt_number": 279 + "outputs": [] }, { "cell_type": "code", @@ -962,900 +928,7 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
FilenameLanguageCodeletenddefnfunctionfunreturndef....formatdefine::$^,;&|!
0 1 clojure (defn cf-settings\\n \"Setup settings for campf... 0.001759 0.000880 0.003518 0.000000 0.000000 0.000000 0.003518... 0.000880 0.000000 0.000000 0.000880 0.000880 0.009675 0.000000 0.000000 1.000880 0.000000
1 2 clojure (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... 0.000000 0.000000 0.009852 0.000000 0.000000 0.000000 0.009852... 0.000000 0.000000 0.000000 0.004926 0.004926 0.000000 0.000000 0.009852 1.004926 0.000000
2 3 clojure (extend-type String\\n Person\\n (first-name [... 0.000000 0.006993 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.000000 0.006993 0.006993 0.000000 0.000000 0.000000 1.006993 0.000000
3 4 clojure (require '[overtone.live :as overtone])\\n\\n(de... 0.001675 0.000000 0.001675 0.000000 0.000000 0.000000 0.003350... 0.000000 0.000000 0.000000 0.001675 0.001675 0.006700 0.006700 0.000000 1.001675 0.001675
4 5 python from pkgutil import iter_modules\\nfrom subproc... 0.000000 0.004983 0.000000 0.000000 0.000000 0.000000 0.000000... 0.004983 0.000000 0.000000 0.001661 0.001661 0.014950 0.000000 0.000000 1.001661 0.000000
5 6 python import re\\nimport subprocess\\n\\ndef cmd_keymap... 0.000000 0.001403 0.000000 0.000000 0.000000 0.001403 0.001403... 0.000000 0.000000 0.000000 0.000351 0.000351 0.003857 0.000000 0.000000 1.000351 0.000000
6 7 python class NoSuchService(Exception):\\n def __ini... 0.000000 0.000000 0.000000 0.000000 0.000000 0.006135 0.012270... 0.000000 0.000000 0.000000 0.003067 0.003067 0.006135 0.000000 0.000000 1.003067 0.000000
7 8 python from collections import namedtuple\\nimport fun... 0.000000 0.003158 0.000000 0.000000 0.000148 0.000691 0.003059... 0.000000 0.000000 0.000000 0.000049 0.000049 0.014952 0.000247 0.000000 1.000049 0.000247
8 9 javascript function errorHandler(context) {\\n return fun... 0.000000 0.000000 0.000000 0.008982 0.008982 0.001497 0.000000... 0.000000 0.000000 0.000000 0.000749 0.000749 0.005240 0.014222 0.000000 1.000749 0.000000
9 10 javascript var _ = require('lodash'),\\n fs = require('... 0.000000 0.000000 0.000000 0.005731 0.005731 0.008596 0.002865... 0.000000 0.000000 0.000000 0.005731 0.002865 0.011461 0.011461 0.000000 1.002865 0.000000
10 11 javascript /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... 0.000058 0.000864 0.000000 0.004377 0.004435 0.002649 0.000864... 0.000000 0.000576 0.000000 0.000058 0.000058 0.012844 0.000691 0.002361 1.000058 0.001498
11 12 javascript var r = riot.route = function(arg) {\\n //... 0.000000 0.000000 0.000000 0.011765 0.011765 0.000000 0.000000... 0.000000 0.000000 0.000000 0.005882 0.005882 0.005882 0.000000 0.000000 1.005882 0.000000
12 13 ruby module ActiveJob\\n module Core\\n extend Ac... 0.000000 0.005049 0.000000 0.000000 0.000000 0.000281 0.003086... 0.000000 0.000281 0.000561 0.000281 0.000281 0.001964 0.000000 0.000561 1.000281 0.000000
13 14 ruby require 'formula'\\n\\nclass A52dec < Formula\\n ... 0.000000 0.006110 0.000000 0.000000 0.000000 0.000000 0.002037... 0.000000 0.000000 0.000000 0.002037 0.002037 0.010183 0.000000 0.000000 1.002037 0.000000
14 15 ruby module Fluent\\n class Input\\n include Conf... 0.000000 0.014286 0.000000 0.000000 0.000000 0.000000 0.008163... 0.000000 0.000000 0.000000 0.002041 0.002041 0.000000 0.000000 0.000000 1.002041 0.000000
15 16 haskell {-# LANGUAGE ScopedTypeVariables, FlexibleInst... 0.000131 0.000196 0.000000 0.000000 0.000000 0.000523 0.000261... 0.000849 0.000000 0.000915 0.000065 0.000065 0.013264 0.000261 0.000000 1.000065 0.000000
16 17 haskell reverseDependencies :: ModuleGraph -> M.Map Mo... 0.000000 0.006452 0.000000 0.000000 0.000000 0.000000 0.000000... 0.000000 0.000000 0.006452 0.003226 0.003226 0.012903 0.000000 0.009677 1.003226 0.000000
17 18 haskell {- git-annex extra config files\\n -\\n - Copyri... 0.000491 0.000000 0.000000 0.000000 0.000982 0.001473 0.000491... 0.000000 0.000000 0.003929 0.000491 0.000491 0.001965 0.000491 0.000000 1.000491 0.000000
18 19 scheme (define subst-f\\n (lambda (new old l)\\n (c... 0.000000 0.000000 0.000000 0.002591 0.002591 0.000000 0.007772... 0.000000 0.007772 0.000000 0.002591 0.002591 0.000000 0.010363 0.000000 1.002591 0.000000
19 20 scheme (define add1\\n (lambda (n) (+ n 1))) 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.027778... 0.000000 0.027778 0.000000 0.027778 0.027778 0.000000 0.000000 0.000000 1.027778 0.000000
20 21 scheme (define-lib-primitive (length lst)\\n (if (nul... 0.001341 0.000000 0.000000 0.000000 0.000000 0.000000 0.007449... 0.000000 0.007449 0.000000 0.000149 0.000149 0.000000 0.000298 0.000000 1.000149 0.002086
21 22 java /**\\n * Interface to represent a persistence s... 0.001424 0.000000 0.000000 0.000000 0.000000 0.001898 0.000949... 0.000000 0.000000 0.000000 0.000475 0.000475 0.000949 0.003322 0.000000 1.000475 0.000000
22 23 java /*\\n * Copyright 2002-2008 the original author... 0.000000 0.000000 0.000000 0.000000 0.000000 0.001095 0.001095... 0.000000 0.001095 0.000000 0.000548 0.000548 0.004381 0.003286 0.000000 1.000548 0.000000
23 24 scala package com.github.pathikrit\\n\\nimport scala.a... 0.000000 0.003219 0.000000 0.000000 0.000000 0.000000 0.001788... 0.000000 0.000000 0.001073 0.000358 0.000358 0.005007 0.000000 0.000000 1.000358 0.000000
24 25 scala /* sbt -- Simple Build Tool\\n * Copyright 2010... 0.000000 0.001565 0.000000 0.000000 0.000000 0.000000 0.004173... 0.000000 0.000000 0.000000 0.000522 0.000522 0.001043 0.000000 0.000000 1.000522 0.000000
25 28 php class View\\n{\\n /**\\n * Data available ... 0.000000 0.001805 0.000000 0.002557 0.002708 0.002407 0.000000... 0.000000 0.000000 0.000301 0.000150 0.000150 0.002858 0.004964 0.000602 1.000150 0.000903
26 29 php public function formatLocalized($format)\\n... 0.000000 0.000000 0.000000 0.002950 0.002950 0.002950 0.000000... 0.014749 0.000000 0.000000 0.002950 0.002950 0.014749 0.005900 0.000000 1.002950 0.002950
27 30 php class Application extends App {\\n\\t/**\\n\\t * @... 0.000000 0.000512 0.000000 0.005629 0.005629 0.005118 0.000000... 0.000000 0.000000 0.001535 0.000512 0.000512 0.011771 0.011259 0.000000 1.000512 0.000000
28 31 ocaml type name = string\\n\\nlet compare_label label1... 0.005422 0.001322 0.000000 0.000661 0.002248 0.000926 0.000397... 0.000000 0.000000 0.000132 0.000132 0.000132 0.006612 0.000397 0.000000 1.000132 0.000264
29 32 ocaml let search_compiler_libs () =\\n prerr_endline... 0.005217 0.003478 0.000000 0.000000 0.001739 0.000000 0.000000... 0.000000 0.000000 0.000000 0.001739 0.001739 0.000000 0.012174 0.000000 1.001739 0.001739
\n", - "

30 rows \u00d7 23 columns

\n", - "
" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 280, - "text": [ - " Filename Language Code \\\n", - "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", - "1 2 clojure (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", - "2 3 clojure (extend-type String\\n Person\\n (first-name [... \n", - "3 4 clojure (require '[overtone.live :as overtone])\\n\\n(de... \n", - "4 5 python from pkgutil import iter_modules\\nfrom subproc... \n", - "5 6 python import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", - "6 7 python class NoSuchService(Exception):\\n def __ini... \n", - "7 8 python from collections import namedtuple\\nimport fun... \n", - "8 9 javascript function errorHandler(context) {\\n return fun... \n", - "9 10 javascript var _ = require('lodash'),\\n fs = require('... \n", - "10 11 javascript /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", - "11 12 javascript var r = riot.route = function(arg) {\\n //... \n", - "12 13 ruby module ActiveJob\\n module Core\\n extend Ac... \n", - "13 14 ruby require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", - "14 15 ruby module Fluent\\n class Input\\n include Conf... \n", - "15 16 haskell {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", - "16 17 haskell reverseDependencies :: ModuleGraph -> M.Map Mo... \n", - "17 18 haskell {- git-annex extra config files\\n -\\n - Copyri... \n", - "18 19 scheme (define subst-f\\n (lambda (new old l)\\n (c... \n", - "19 20 scheme (define add1\\n (lambda (n) (+ n 1))) \n", - "20 21 scheme (define-lib-primitive (length lst)\\n (if (nul... \n", - "21 22 java /**\\n * Interface to represent a persistence s... \n", - "22 23 java /*\\n * Copyright 2002-2008 the original author... \n", - "23 24 scala package com.github.pathikrit\\n\\nimport scala.a... \n", - "24 25 scala /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", - "25 28 php class View\\n{\\n /**\\n * Data available ... \n", - "26 29 php public function formatLocalized($format)\\n... \n", - "27 30 php class Application extends App {\\n\\t/**\\n\\t * @... \n", - "28 31 ocaml type name = string\\n\\nlet compare_label label1... \n", - "29 32 ocaml let search_compiler_libs () =\\n prerr_endline... \n", - "\n", - " let end defn function fun return def \\\n", - "0 0.001759 0.000880 0.003518 0.000000 0.000000 0.000000 0.003518 \n", - "1 0.000000 0.000000 0.009852 0.000000 0.000000 0.000000 0.009852 \n", - "2 0.000000 0.006993 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "3 0.001675 0.000000 0.001675 0.000000 0.000000 0.000000 0.003350 \n", - "4 0.000000 0.004983 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "5 0.000000 0.001403 0.000000 0.000000 0.000000 0.001403 0.001403 \n", - "6 0.000000 0.000000 0.000000 0.000000 0.000000 0.006135 0.012270 \n", - "7 0.000000 0.003158 0.000000 0.000000 0.000148 0.000691 0.003059 \n", - "8 0.000000 0.000000 0.000000 0.008982 0.008982 0.001497 0.000000 \n", - "9 0.000000 0.000000 0.000000 0.005731 0.005731 0.008596 0.002865 \n", - "10 0.000058 0.000864 0.000000 0.004377 0.004435 0.002649 0.000864 \n", - "11 0.000000 0.000000 0.000000 0.011765 0.011765 0.000000 0.000000 \n", - "12 0.000000 0.005049 0.000000 0.000000 0.000000 0.000281 0.003086 \n", - "13 0.000000 0.006110 0.000000 0.000000 0.000000 0.000000 0.002037 \n", - "14 0.000000 0.014286 0.000000 0.000000 0.000000 0.000000 0.008163 \n", - "15 0.000131 0.000196 0.000000 0.000000 0.000000 0.000523 0.000261 \n", - "16 0.000000 0.006452 0.000000 0.000000 0.000000 0.000000 0.000000 \n", - "17 0.000491 0.000000 0.000000 0.000000 0.000982 0.001473 0.000491 \n", - "18 0.000000 0.000000 0.000000 0.002591 0.002591 0.000000 0.007772 \n", - "19 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.027778 \n", - "20 0.001341 0.000000 0.000000 0.000000 0.000000 0.000000 0.007449 \n", - "21 0.001424 0.000000 0.000000 0.000000 0.000000 0.001898 0.000949 \n", - "22 0.000000 0.000000 0.000000 0.000000 0.000000 0.001095 0.001095 \n", - "23 0.000000 0.003219 0.000000 0.000000 0.000000 0.000000 0.001788 \n", - "24 0.000000 0.001565 0.000000 0.000000 0.000000 0.000000 0.004173 \n", - "25 0.000000 0.001805 0.000000 0.002557 0.002708 0.002407 0.000000 \n", - "26 0.000000 0.000000 0.000000 0.002950 0.002950 0.002950 0.000000 \n", - "27 0.000000 0.000512 0.000000 0.005629 0.005629 0.005118 0.000000 \n", - "28 0.005422 0.001322 0.000000 0.000661 0.002248 0.000926 0.000397 \n", - "29 0.005217 0.003478 0.000000 0.000000 0.001739 0.000000 0.000000 \n", - "\n", - " ... .format define :: $ ^ , \\\n", - "0 ... 0.000880 0.000000 0.000000 0.000880 0.000880 0.009675 \n", - "1 ... 0.000000 0.000000 0.000000 0.004926 0.004926 0.000000 \n", - "2 ... 0.000000 0.000000 0.000000 0.006993 0.006993 0.000000 \n", - "3 ... 0.000000 0.000000 0.000000 0.001675 0.001675 0.006700 \n", - "4 ... 0.004983 0.000000 0.000000 0.001661 0.001661 0.014950 \n", - "5 ... 0.000000 0.000000 0.000000 0.000351 0.000351 0.003857 \n", - "6 ... 0.000000 0.000000 0.000000 0.003067 0.003067 0.006135 \n", - "7 ... 0.000000 0.000000 0.000000 0.000049 0.000049 0.014952 \n", - "8 ... 0.000000 0.000000 0.000000 0.000749 0.000749 0.005240 \n", - "9 ... 0.000000 0.000000 0.000000 0.005731 0.002865 0.011461 \n", - "10 ... 0.000000 0.000576 0.000000 0.000058 0.000058 0.012844 \n", - "11 ... 0.000000 0.000000 0.000000 0.005882 0.005882 0.005882 \n", - "12 ... 0.000000 0.000281 0.000561 0.000281 0.000281 0.001964 \n", - "13 ... 0.000000 0.000000 0.000000 0.002037 0.002037 0.010183 \n", - "14 ... 0.000000 0.000000 0.000000 0.002041 0.002041 0.000000 \n", - "15 ... 0.000849 0.000000 0.000915 0.000065 0.000065 0.013264 \n", - "16 ... 0.000000 0.000000 0.006452 0.003226 0.003226 0.012903 \n", - "17 ... 0.000000 0.000000 0.003929 0.000491 0.000491 0.001965 \n", - "18 ... 0.000000 0.007772 0.000000 0.002591 0.002591 0.000000 \n", - "19 ... 0.000000 0.027778 0.000000 0.027778 0.027778 0.000000 \n", - "20 ... 0.000000 0.007449 0.000000 0.000149 0.000149 0.000000 \n", - "21 ... 0.000000 0.000000 0.000000 0.000475 0.000475 0.000949 \n", - "22 ... 0.000000 0.001095 0.000000 0.000548 0.000548 0.004381 \n", - "23 ... 0.000000 0.000000 0.001073 0.000358 0.000358 0.005007 \n", - "24 ... 0.000000 0.000000 0.000000 0.000522 0.000522 0.001043 \n", - "25 ... 0.000000 0.000000 0.000301 0.000150 0.000150 0.002858 \n", - "26 ... 0.014749 0.000000 0.000000 0.002950 0.002950 0.014749 \n", - "27 ... 0.000000 0.000000 0.001535 0.000512 0.000512 0.011771 \n", - "28 ... 0.000000 0.000000 0.000132 0.000132 0.000132 0.006612 \n", - "29 ... 0.000000 0.000000 0.000000 0.001739 0.001739 0.000000 \n", - "\n", - " ; & | ! \n", - "0 0.000000 0.000000 1.000880 0.000000 \n", - "1 0.000000 0.009852 1.004926 0.000000 \n", - "2 0.000000 0.000000 1.006993 0.000000 \n", - "3 0.006700 0.000000 1.001675 0.001675 \n", - "4 0.000000 0.000000 1.001661 0.000000 \n", - "5 0.000000 0.000000 1.000351 0.000000 \n", - "6 0.000000 0.000000 1.003067 0.000000 \n", - "7 0.000247 0.000000 1.000049 0.000247 \n", - "8 0.014222 0.000000 1.000749 0.000000 \n", - "9 0.011461 0.000000 1.002865 0.000000 \n", - "10 0.000691 0.002361 1.000058 0.001498 \n", - "11 0.000000 0.000000 1.005882 0.000000 \n", - "12 0.000000 0.000561 1.000281 0.000000 \n", - "13 0.000000 0.000000 1.002037 0.000000 \n", - "14 0.000000 0.000000 1.002041 0.000000 \n", - "15 0.000261 0.000000 1.000065 0.000000 \n", - "16 0.000000 0.009677 1.003226 0.000000 \n", - "17 0.000491 0.000000 1.000491 0.000000 \n", - "18 0.010363 0.000000 1.002591 0.000000 \n", - "19 0.000000 0.000000 1.027778 0.000000 \n", - "20 0.000298 0.000000 1.000149 0.002086 \n", - "21 0.003322 0.000000 1.000475 0.000000 \n", - "22 0.003286 0.000000 1.000548 0.000000 \n", - "23 0.000000 0.000000 1.000358 0.000000 \n", - "24 0.000000 0.000000 1.000522 0.000000 \n", - "25 0.004964 0.000602 1.000150 0.000903 \n", - "26 0.005900 0.000000 1.002950 0.002950 \n", - "27 0.011259 0.000000 1.000512 0.000000 \n", - "28 0.000397 0.000000 1.000132 0.000264 \n", - "29 0.012174 0.000000 1.001739 0.001739 \n", - "\n", - "[30 rows x 23 columns]" - ] - } - ], - "prompt_number": 280 + "outputs": [] }, { "cell_type": "code", @@ -1865,8 +938,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 281 + "outputs": [] }, { "cell_type": "code", @@ -1876,8 +948,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 282 + "outputs": [] }, { "cell_type": "code", @@ -1887,8 +958,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 283 + "outputs": [] }, { "cell_type": "code", @@ -1898,8 +968,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 284 + "outputs": [] }, { "cell_type": "code", @@ -1914,8 +983,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 285 + "outputs": [] }, { "cell_type": "code", @@ -1940,8 +1008,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 286 + "outputs": [] }, { "cell_type": "code", @@ -1951,900 +1018,7 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
FilenameLanguageTestcodecode length^;,&!|...slicereturndefinedoublecoloncheckmake.format->$printf
0 1 clojure (defn cf-settings\\n \"Setup settings for campf... 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826... 0 0.000000 0.000000 0.000000 0.005372 0.000000 0.001240 0.000000 0.000826 0.000000
1 2 clojure (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... 203 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771... 0 0.000000 0.000000 0.000000 0.005012 0.002699 0.001157 0.000000 0.000771 0.000000
2 3 clojure (extend-type String\\n Person\\n (first-name [... 143 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347... 0 0.000000 0.000000 0.000000 0.009094 0.000000 0.001010 0.000000 0.000674 0.000000
3 4 clojure (require '[overtone.live :as overtone])\\n\\n(de... 597 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177... 0 0.000000 0.000000 0.002471 0.006794 0.005559 0.000000 0.005559 0.001235 0.000618
4 5 python from pkgutil import iter_modules\\nfrom subproc... 602 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294... 0 0.000000 0.000000 0.002118 0.006882 0.004764 0.000000 0.005823 0.001059 0.000529
5 6 python import re\\nimport subprocess\\n\\ndef cmd_keymap... 2852 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158... 0 0.000000 0.000000 0.002292 0.007450 0.005158 0.000000 0.006304 0.001146 0.000573
6 7 python class NoSuchService(Exception):\\n def __ini... 326 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719... 0 0.000737 0.000000 0.000000 0.002947 0.000000 0.000000 0.000000 0.000491 0.000000
7 8 python from collections import namedtuple\\nimport fun... 20265 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682... 0 0.001894 0.000000 0.000000 0.004261 0.000000 0.000000 0.000000 0.000947 0.000000
8 9 javascript function errorHandler(context) {\\n return fun... 1336 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636... 0 0.001391 0.000000 0.000000 0.006027 0.000000 0.000000 0.000000 0.000927 0.000000
9 10 javascript var _ = require('lodash'),\\n fs = require('... 349 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234... 0 0.002924 0.000000 0.000000 0.006579 0.000000 0.000000 0.000000 0.001462 0.000000
10 11 javascript /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... 17362 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236... 0 0.001605 0.000000 0.000000 0.011236 0.000000 0.000000 0.000000 0.001605 0.000000
11 12 javascript var r = riot.route = function(arg) {\\n //... 170 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921... 0 0.001403 0.000000 0.000000 0.009818 0.000000 0.000000 0.000000 0.001403 0.000000
12 13 ruby module ActiveJob\\n module Core\\n extend Ac... 3565 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876... 0 0.000000 0.000000 0.000000 0.011085 0.000000 0.000000 0.000000 0.001584 0.000000
13 14 ruby require 'formula'\\n\\nclass A52dec < Formula\\n ... 491 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324... 0 0.000000 0.000000 0.000000 0.005444 0.000000 0.000000 0.000000 0.000436 0.000000
14 15 ruby module Fluent\\n class Input\\n include Conf... 490 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459... 0 0.000000 0.000000 0.000000 0.006146 0.004302 0.000000 0.001229 0.001229 0.001844
15 16 haskell {-# LANGUAGE ScopedTypeVariables, FlexibleInst... 15305 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887... 0 0.000000 0.000000 0.000000 0.004442 0.003110 0.000000 0.006664 0.000888 0.001333
16 17 haskell reverseDependencies :: ModuleGraph -> M.Map Mo... 310 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370... 0 0.000000 0.000000 0.000000 0.007283 0.005098 0.000000 0.002185 0.001457 0.002185
17 18 haskell {- git-annex extra config files\\n -\\n - Copyri... 2036 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423... 0 0.000746 0.000000 0.000000 0.010440 0.000000 0.000000 0.000000 0.001491 0.000000
18 19 scheme (define subst-f\\n (lambda (new old l)\\n (c... 386 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293... 0 0.001906 0.000000 0.000953 0.007623 0.000000 0.000000 0.003335 0.000953 0.000000
19 20 scheme (define add1\\n (lambda (n) (+ n 1))) 36 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506... 0 0.001901 0.000000 0.000000 0.004436 0.000000 0.000000 0.008872 0.001267 0.001901
20 21 scheme (define-lib-primitive (length lst)\\n (if (nul... 6712 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709... 0 0.000693 0.000000 0.000000 0.009015 0.000000 0.000000 0.013870 0.001387 0.002080
21 22 java /**\\n * Interface to represent a persistence s... 2107 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873... 0 0.002033 0.000000 0.000000 0.004743 0.000000 0.000000 0.000000 0.001355 0.002033
22 23 java /*\\n * Copyright 2002-2008 the original author... 1826 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206... 0 0.001289 0.000000 0.000000 0.003866 0.000000 0.000000 0.000000 0.000515 0.000773
23 24 scala package com.github.pathikrit\\n\\nimport scala.a... 2796 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261... 0 0.002784 0.000000 0.000000 0.007238 0.005568 0.001670 0.000000 0.001114 0.000000
24 25 scala /* sbt -- Simple Build Tool\\n * Copyright 2010... 1917 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000... 0 0.000000 0.004079 0.000000 0.005828 0.004079 0.000000 0.000583 0.001166 0.001748
25 28 php class View\\n{\\n /**\\n * Data available ... 6648 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000... 0 0.000000 0.005311 0.000000 0.003863 0.005311 0.000000 0.000483 0.000966 0.001449
26 29 php public function formatLocalized($format)\\n... 339 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000... 0 0.000000 0.009222 0.000000 0.002951 0.004795 0.000000 0.000369 0.000738 0.001107
27 30 php class Application extends App {\\n\\t/**\\n\\t * @... 1954 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018... 0 0.000000 0.000000 0.000000 0.001931 0.000000 0.000000 0.000000 0.001287 0.000000
28 31 ocaml type name = string\\n\\nlet compare_label label1... 7562 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805... 0 0.000000 0.000000 0.000000 0.003040 0.000000 0.000000 0.000000 0.001216 0.000000
29 32 ocaml let search_compiler_libs () =\\n prerr_endline... 575 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794... 0 0.000000 0.000000 0.000000 0.002290 0.000000 0.000000 0.000000 0.001527 0.000000
\n", - "

30 rows \u00d7 26 columns

\n", - "
" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 287, - "text": [ - " Filename Language Testcode \\\n", - "0 1 clojure (defn cf-settings\\n \"Setup settings for campf... \n", - "1 2 clojure (ns my-cli.core)\\n\\n(defn -main [& args]\\n (p... \n", - "2 3 clojure (extend-type String\\n Person\\n (first-name [... \n", - "3 4 clojure (require '[overtone.live :as overtone])\\n\\n(de... \n", - "4 5 python from pkgutil import iter_modules\\nfrom subproc... \n", - "5 6 python import re\\nimport subprocess\\n\\ndef cmd_keymap... \n", - "6 7 python class NoSuchService(Exception):\\n def __ini... \n", - "7 8 python from collections import namedtuple\\nimport fun... \n", - "8 9 javascript function errorHandler(context) {\\n return fun... \n", - "9 10 javascript var _ = require('lodash'),\\n fs = require('... \n", - "10 11 javascript /* Riot v2.0.8, @license MIT, (c) 2015 Muut In... \n", - "11 12 javascript var r = riot.route = function(arg) {\\n //... \n", - "12 13 ruby module ActiveJob\\n module Core\\n extend Ac... \n", - "13 14 ruby require 'formula'\\n\\nclass A52dec < Formula\\n ... \n", - "14 15 ruby module Fluent\\n class Input\\n include Conf... \n", - "15 16 haskell {-# LANGUAGE ScopedTypeVariables, FlexibleInst... \n", - "16 17 haskell reverseDependencies :: ModuleGraph -> M.Map Mo... \n", - "17 18 haskell {- git-annex extra config files\\n -\\n - Copyri... \n", - "18 19 scheme (define subst-f\\n (lambda (new old l)\\n (c... \n", - "19 20 scheme (define add1\\n (lambda (n) (+ n 1))) \n", - "20 21 scheme (define-lib-primitive (length lst)\\n (if (nul... \n", - "21 22 java /**\\n * Interface to represent a persistence s... \n", - "22 23 java /*\\n * Copyright 2002-2008 the original author... \n", - "23 24 scala package com.github.pathikrit\\n\\nimport scala.a... \n", - "24 25 scala /* sbt -- Simple Build Tool\\n * Copyright 2010... \n", - "25 28 php class View\\n{\\n /**\\n * Data available ... \n", - "26 29 php public function formatLocalized($format)\\n... \n", - "27 30 php class Application extends App {\\n\\t/**\\n\\t * @... \n", - "28 31 ocaml type name = string\\n\\nlet compare_label label1... \n", - "29 32 ocaml let search_compiler_libs () =\\n prerr_endline... \n", - "\n", - " code length ^ ; , & ! | \\\n", - "0 1137 0.003719 0.009091 0.000826 0.003719 0.009091 0.000826 \n", - "1 203 0.004241 0.008096 0.000771 0.004241 0.008096 0.000771 \n", - "2 143 0.003705 0.010104 0.001347 0.003705 0.010104 0.001347 \n", - "3 597 0.000000 0.000618 0.006177 0.000000 0.000618 0.006177 \n", - "4 602 0.000000 0.000529 0.005294 0.000000 0.000529 0.005294 \n", - "5 2852 0.000000 0.000573 0.005158 0.000000 0.000573 0.005158 \n", - "6 326 0.000000 0.016208 0.001719 0.000000 0.016208 0.001719 \n", - "7 20265 0.000000 0.013258 0.005682 0.000000 0.013258 0.005682 \n", - "8 1336 0.000000 0.014372 0.004636 0.000000 0.014372 0.004636 \n", - "9 349 0.000000 0.017544 0.010234 0.000000 0.017544 0.010234 \n", - "10 17362 0.000000 0.000000 0.011236 0.000000 0.000000 0.011236 \n", - "11 170 0.000000 0.001403 0.011921 0.000000 0.001403 0.011921 \n", - "12 3565 0.000000 0.000000 0.011876 0.000000 0.000000 0.011876 \n", - "13 491 0.000218 0.000000 0.011324 0.000218 0.000000 0.011324 \n", - "14 490 0.000000 0.004302 0.002459 0.000000 0.004302 0.002459 \n", - "15 15305 0.000000 0.006219 0.004887 0.000000 0.006219 0.004887 \n", - "16 310 0.000000 0.005098 0.004370 0.000000 0.005098 0.004370 \n", - "17 2036 0.000000 0.013423 0.013423 0.000000 0.013423 0.013423 \n", - "18 386 0.000000 0.015722 0.014293 0.000000 0.015722 0.014293 \n", - "19 36 0.000000 0.022180 0.009506 0.000000 0.022180 0.009506 \n", - "20 6712 0.000000 0.017337 0.009709 0.000000 0.017337 0.009709 \n", - "21 2107 0.000000 0.018970 0.012873 0.000000 0.018970 0.012873 \n", - "22 1826 0.000000 0.027320 0.015206 0.000000 0.027320 0.015206 \n", - "23 2796 0.000000 0.000000 0.017261 0.000000 0.000000 0.017261 \n", - "24 1917 0.000000 0.008159 0.000000 0.000000 0.008159 0.000000 \n", - "25 6648 0.000000 0.005794 0.000000 0.000000 0.005794 0.000000 \n", - "26 339 0.000000 0.004426 0.000000 0.000000 0.004426 0.000000 \n", - "27 1954 0.000000 0.000000 0.018018 0.000000 0.000000 0.018018 \n", - "28 7562 0.000000 0.000608 0.015805 0.000000 0.000608 0.015805 \n", - "29 575 0.000000 0.000000 0.016794 0.000000 0.000000 0.016794 \n", - "\n", - " ... slice return define doublecolon check make \\\n", - "0 ... 0 0.000000 0.000000 0.000000 0.005372 0.000000 \n", - "1 ... 0 0.000000 0.000000 0.000000 0.005012 0.002699 \n", - "2 ... 0 0.000000 0.000000 0.000000 0.009094 0.000000 \n", - "3 ... 0 0.000000 0.000000 0.002471 0.006794 0.005559 \n", - "4 ... 0 0.000000 0.000000 0.002118 0.006882 0.004764 \n", - "5 ... 0 0.000000 0.000000 0.002292 0.007450 0.005158 \n", - "6 ... 0 0.000737 0.000000 0.000000 0.002947 0.000000 \n", - "7 ... 0 0.001894 0.000000 0.000000 0.004261 0.000000 \n", - "8 ... 0 0.001391 0.000000 0.000000 0.006027 0.000000 \n", - "9 ... 0 0.002924 0.000000 0.000000 0.006579 0.000000 \n", - "10 ... 0 0.001605 0.000000 0.000000 0.011236 0.000000 \n", - "11 ... 0 0.001403 0.000000 0.000000 0.009818 0.000000 \n", - "12 ... 0 0.000000 0.000000 0.000000 0.011085 0.000000 \n", - "13 ... 0 0.000000 0.000000 0.000000 0.005444 0.000000 \n", - "14 ... 0 0.000000 0.000000 0.000000 0.006146 0.004302 \n", - "15 ... 0 0.000000 0.000000 0.000000 0.004442 0.003110 \n", - "16 ... 0 0.000000 0.000000 0.000000 0.007283 0.005098 \n", - "17 ... 0 0.000746 0.000000 0.000000 0.010440 0.000000 \n", - "18 ... 0 0.001906 0.000000 0.000953 0.007623 0.000000 \n", - "19 ... 0 0.001901 0.000000 0.000000 0.004436 0.000000 \n", - "20 ... 0 0.000693 0.000000 0.000000 0.009015 0.000000 \n", - "21 ... 0 0.002033 0.000000 0.000000 0.004743 0.000000 \n", - "22 ... 0 0.001289 0.000000 0.000000 0.003866 0.000000 \n", - "23 ... 0 0.002784 0.000000 0.000000 0.007238 0.005568 \n", - "24 ... 0 0.000000 0.004079 0.000000 0.005828 0.004079 \n", - "25 ... 0 0.000000 0.005311 0.000000 0.003863 0.005311 \n", - "26 ... 0 0.000000 0.009222 0.000000 0.002951 0.004795 \n", - "27 ... 0 0.000000 0.000000 0.000000 0.001931 0.000000 \n", - "28 ... 0 0.000000 0.000000 0.000000 0.003040 0.000000 \n", - "29 ... 0 0.000000 0.000000 0.000000 0.002290 0.000000 \n", - "\n", - " .format -> $ printf \n", - "0 0.001240 0.000000 0.000826 0.000000 \n", - "1 0.001157 0.000000 0.000771 0.000000 \n", - "2 0.001010 0.000000 0.000674 0.000000 \n", - "3 0.000000 0.005559 0.001235 0.000618 \n", - "4 0.000000 0.005823 0.001059 0.000529 \n", - "5 0.000000 0.006304 0.001146 0.000573 \n", - "6 0.000000 0.000000 0.000491 0.000000 \n", - "7 0.000000 0.000000 0.000947 0.000000 \n", - "8 0.000000 0.000000 0.000927 0.000000 \n", - "9 0.000000 0.000000 0.001462 0.000000 \n", - "10 0.000000 0.000000 0.001605 0.000000 \n", - "11 0.000000 0.000000 0.001403 0.000000 \n", - "12 0.000000 0.000000 0.001584 0.000000 \n", - "13 0.000000 0.000000 0.000436 0.000000 \n", - "14 0.000000 0.001229 0.001229 0.001844 \n", - "15 0.000000 0.006664 0.000888 0.001333 \n", - "16 0.000000 0.002185 0.001457 0.002185 \n", - "17 0.000000 0.000000 0.001491 0.000000 \n", - "18 0.000000 0.003335 0.000953 0.000000 \n", - "19 0.000000 0.008872 0.001267 0.001901 \n", - "20 0.000000 0.013870 0.001387 0.002080 \n", - "21 0.000000 0.000000 0.001355 0.002033 \n", - "22 0.000000 0.000000 0.000515 0.000773 \n", - "23 0.001670 0.000000 0.001114 0.000000 \n", - "24 0.000000 0.000583 0.001166 0.001748 \n", - "25 0.000000 0.000483 0.000966 0.001449 \n", - "26 0.000000 0.000369 0.000738 0.001107 \n", - "27 0.000000 0.000000 0.001287 0.000000 \n", - "28 0.000000 0.000000 0.001216 0.000000 \n", - "29 0.000000 0.000000 0.001527 0.000000 \n", - "\n", - "[30 rows x 26 columns]" - ] - } - ], - "prompt_number": 287 + "outputs": [] }, { "cell_type": "code", @@ -2854,8 +1028,7 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 288 + "outputs": [] }, { "cell_type": "code", @@ -2870,17 +1043,7 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid syntax (, line 1)", - "output_type": "pyerr", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m def create_xy(df, test_df startx, columny):\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" - ] - } - ], - "prompt_number": 289 + "outputs": [] }, { "cell_type": "code", From 628978c75ae3716287725097ed19a61587cd4c0e Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Sun, 15 Feb 2015 15:17:26 -0500 Subject: [PATCH 7/9] updated readme --- README.md | 106 ++++-------------------------------------------------- 1 file changed, 6 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index 8380c5f..8505201 100644 --- a/README.md +++ b/README.md @@ -1,102 +1,8 @@ -# Classify code snippets into programming languages +All appropriate files are included in the directory "plc". To have my classifier determine what language a code snippet was written in, do the following: +1. Copy your code snippet into the file "code_snippet.txt" +2. run "python guess_lang.py" from the command line. +The program will tell you what language it thinks it is, as well as a percentage of how confident it is in that assessment. -## Description - -Create a classifier that can take snippets of code and guess the programming language of the code. - -## Objectives - -### Learning Objectives - -After completing this assignment, you should understand: - -* Feature extraction -* Classification -* The varied syntax of programming languages - -### Performance Objectives - -After completing this assignment, you should be able to: - -* Build a robust classifier - -## Details - -### Deliverables - -* A Git repo called programming-language-classifier containing at least: - * `README.md` file explaining how to run your project - * a `requirements.txt` file - * a suite of tests for your project - -### Requirements - -* Passing unit tests -* No PEP8 or Pyflakes warnings or errors - -## Normal Mode - -### Getting a corpus of programming languages - -Option 1: Get code from the [Computer Language Benchmarks Game](http://benchmarksgame.alioth.debian.org/). You can [download their code](https://alioth.debian.org/snapshots.php?group_id=100815) directly. In the downloaded archive under `benchmarksgame/bench`, you'll find many directories with short programs in them. Using the file extensions of these files, you should be able to find out what programming language they are. - -Option 2: Scrape code from [Rosetta Code](http://rosettacode.org/wiki/Rosetta_Code). You will need to figure out how to scrape HTML and parse it. [BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/) is your best bet for doing that. - -Option 3: Get code from GitHub somehow. The specifics of this are left up to you. - -You are allowed to use other code samples as well. - -**For your sanity, you only have to worry about the following languages:** - -* Clojure -* Haskell -* Java -* JavaScript -* OCaml -* Perl -* PHP -* Python -* Ruby -* Scala -* Scheme -* Tcl - -Feel more than free to add others! - -### Classifying new snippets - -Using your corpus, you should extract features for your classifier. Use whatever classifier engine that works best for you _and that you can explain how it works._ - -Your initial classifier should be able to take a string containing code and return a guessed language for it. It is recommended you also have a method that returns the snippet's percentage chance for each language in a dict. - -### Testing your classifier - -The `test/` directory contains code snippets. The file `test.csv` contains a list of the file names in the `test` directory and the language of each snippet. Use this set of snippets to test your classifier. _Do not use the test snippets for training your classifier, obviously._ - -### Code layout - -This project should be laid out in accordance with the project layout from _The Hacker's Guide to Python_. It should have tests for things which can be tested. Your classifier should be able to be run with a small controlled corpus for testing. - -Your project should also contain an IPython notebook that demonstrates use of your classifier. - -## Hard Mode - -In addition to the requirements from **Normal Mode**: - -Create a runnable Python file that can classify a snippet in a text file, run like this: - -`guess_lang.py code-snippet.txt` - -where `guess_lang.py` is whatever you name your program and `code-snippet.txt` is any snippet. Your program should print out the language it thinks the snippet is. - -To do this, you will likely want to either pre-parse your corpus and output it as features to load or save out your classifier for later use. Otherwise, you'll have to read your entire corpus every time you run the program. That's acceptable, but slow. - -You may want to add some command-line flags to your program. You could allow people to choose the corpus, for example, or to get percentage chances instead of one language. To understand how to write a command-line program with arguments and flags, see the [argparse](https://docs.python.org/3/library/argparse.html) module in the standard library. - -## Additional Resources - -* [TextBlob](http://textblob.readthedocs.org/en/dev/) -* [Beautiful Soup](http://www.crummy.com/software/BeautifulSoup/) -* [Rosetta Code](http://rosettacode.org/wiki/Rosetta_Code) -* [Working with Text Files](https://opentechschool.github.io/python-data-intro/core/text-files.html) +The IPython notebook "Code Classifier.ipynb" demonstrates how the classifier is built and runs it against the test codes found in the "test" directory. Supplemental functions are found in modules referenced by the imports at the start of the notebook. +An additional IPython notebook "split and test.ipynb" contains a classifier trained on a portion of the Benchmarks game code and tested on the remainder of the code. From 7a786f1dfd4ab359ba3bba384f007e3e954d1094 Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Sun, 15 Feb 2015 16:37:34 -0500 Subject: [PATCH 8/9] added command line arg with argparse --- README.md | 4 ++-- plc/guess_lang.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8505201..6f79665 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ All appropriate files are included in the directory "plc". To have my classifier determine what language a code snippet was written in, do the following: -1. Copy your code snippet into the file "code_snippet.txt" -2. run "python guess_lang.py" from the command line. +1. Copy your code snippet into the file "code_snippet.txt" or make a .txt file of a different name with code snippet inside +2. run "python guess_lang.py code_snippet.txt" from the command line. (If you've named a file differently than code_snippet.txt then use that name instead.) The program will tell you what language it thinks it is, as well as a percentage of how confident it is in that assessment. diff --git a/plc/guess_lang.py b/plc/guess_lang.py index 1f0f5c9..766a14e 100644 --- a/plc/guess_lang.py +++ b/plc/guess_lang.py @@ -8,6 +8,11 @@ import pandas as pd import re import random +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("filename") +args = parser.parse_args() word_list = ['let', 'end', 'defn', 'function', 'fun', 'return', 'def', 'return', 'check', 'make', '->', '.format', 'define', '::', 'done', 'type', 'rescue', 'print', 'elif', 'clone', 'display', '$format', 'echo', 'str', @@ -42,7 +47,7 @@ def sub_function3(code): def x_data_frame_generator(): test_list = [] - with open("code_snippet.txt") as test_file: + with open(args.filename) as test_file: test_list.append(test_file.read()) df = pd.DataFrame(test_list, index=range(1), columns=['Code']) for string in word_list: From d4bd7581c7aa40d4790ecac7716058c12ad2018d Mon Sep 17 00:00:00 2001 From: Bret Runestad Date: Sun, 15 Feb 2015 20:22:22 -0500 Subject: [PATCH 9/9] attempted pickling --- plc/Code Classifier.ipynb | 156 ++++++++++++++++++++++++++++++++------ plc/code_snippet.txt | 40 ++++------ plc/picklefile | Bin 0 -> 10509 bytes 3 files changed, 146 insertions(+), 50 deletions(-) create mode 100644 plc/picklefile diff --git a/plc/Code Classifier.ipynb b/plc/Code Classifier.ipynb index 0a95450..da9fbfe 100644 --- a/plc/Code Classifier.ipynb +++ b/plc/Code Classifier.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bb2286b7350a238ba5ac194e90f30571f08fb3a5d205269816ac9c27790329bc" + "signature": "sha256:38f00d516f6fc9736605d73e40bc267b2e9567b9f50d67a67165e3e7bce12bf8" }, "nbformat": 3, "nbformat_minor": 0, @@ -20,7 +20,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 149 + "prompt_number": 203 }, { "cell_type": "code", @@ -34,7 +34,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 150 + "prompt_number": 204 }, { "cell_type": "heading", @@ -52,13 +52,13 @@ " 'define', '::', 'done', 'type', 'rescue', 'print', 'elif', 'clone', 'display', '$format', 'echo', 'str',\n", " 'join', '&&', 'val', 'Nil', 'object', '<-', '--', 'lambda', 'var', '//', 'tmpl', 'public function',\n", " 'stdlib', '=>', 'final', 'case', 'impl']\n", - "symbol_list = ['$', '^', ',', ';', '&', '|', '!', '*', '@', '#']\n", + "symbol_list = ['$', '^', ',', ';', '&', '|', '!', '*', '@', '#', '(', '{', ' ']\n", "endings = ['end', ')', '}']" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 151 + "prompt_number": 205 }, { "cell_type": "heading", @@ -99,7 +99,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 152 + "prompt_number": 206 }, { "cell_type": "code", @@ -110,7 +110,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 153 + "prompt_number": 207 }, { "cell_type": "code", @@ -121,7 +121,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 154 + "prompt_number": 208 }, { "cell_type": "heading", @@ -159,7 +159,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 155 + "prompt_number": 209 }, { "cell_type": "code", @@ -170,7 +170,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 156 + "prompt_number": 210 }, { "cell_type": "code", @@ -181,7 +181,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 157 + "prompt_number": 211 }, { "cell_type": "heading", @@ -201,7 +201,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 158 + "prompt_number": 212 }, { "cell_type": "code", @@ -220,8 +220,8 @@ " precision recall f1-score support\n", "\n", " clojure 1.00 0.75 0.86 4\n", - " haskell 0.50 0.67 0.57 3\n", - " java 1.00 0.50 0.67 2\n", + " haskell 0.67 0.67 0.67 3\n", + " java 0.50 1.00 0.67 2\n", " javascript 1.00 0.50 0.67 4\n", " ocaml 1.00 1.00 1.00 2\n", " perl 0.00 0.00 0.00 0\n", @@ -231,24 +231,24 @@ " scala 0.40 1.00 0.57 2\n", " scheme 0.00 0.00 0.00 3\n", "\n", - "avg / total 0.68 0.57 0.58 30\n", + "avg / total 0.66 0.60 0.59 30\n", "\n", "[[3 0 0 0 0 0 0 0 1 0 0]\n", " [0 2 0 0 0 0 0 1 0 0 0]\n", - " [0 1 1 0 0 0 0 0 0 0 0]\n", + " [0 0 2 0 0 0 0 0 0 0 0]\n", " [0 0 0 2 0 0 0 1 0 1 0]\n", " [0 0 0 0 2 0 0 0 0 0 0]\n", " [0 0 0 0 0 0 0 0 0 0 0]\n", " [0 0 0 0 0 1 1 0 0 1 0]\n", - " [0 0 0 0 0 1 0 2 1 0 0]\n", - " [0 0 0 0 0 1 0 0 2 0 0]\n", + " [0 0 1 0 0 0 0 2 1 0 0]\n", + " [0 0 1 0 0 0 0 0 2 0 0]\n", " [0 0 0 0 0 0 0 0 0 2 0]\n", " [0 1 0 0 0 0 0 1 0 1 0]]\n", - "0.575925925926\n" + "0.58544973545\n" ] } ], - "prompt_number": 159 + "prompt_number": 213 }, { "cell_type": "code", @@ -295,7 +295,7 @@ ] } ], - "prompt_number": 160 + "prompt_number": 214 }, { "cell_type": "code", @@ -309,13 +309,121 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 166, + "prompt_number": 215, + "text": [ + "0.0" + ] + } + ], + "prompt_number": 215 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Attempting to pickle my classifier" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import pickle" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 216 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "pickleclf = GaussianNB()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 217 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "pickleclf.fit(x_train, y_train)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 218, "text": [ - "0.06666666666666667" + "GaussianNB()" + ] + } + ], + "prompt_number": 218 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "file_Name = \"picklefile\"\n", + "fileObject = open(file_Name,'wb')" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 219 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "pickle.dump(pickleclf, fileObject)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 220 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "fileObject.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 221 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "fileObject = open('picklefile','r')\n", + "clf = pickle.load(fileObject)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "UnicodeDecodeError", + "evalue": "'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mUnicodeDecodeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mfileObject\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'picklefile'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'r'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mclf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpickle\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfileObject\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/Users/bretrunestad/.pyenv/versions/3.4.2/lib/python3.4/codecs.py\u001b[0m in \u001b[0;36mdecode\u001b[0;34m(self, input, final)\u001b[0m\n\u001b[1;32m 311\u001b[0m \u001b[0;31m# decode input (taking the buffer into account)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 312\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuffer\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 313\u001b[0;31m \u001b[0;34m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconsumed\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_buffer_decode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merrors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfinal\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 314\u001b[0m \u001b[0;31m# keep undecoded input until the next call\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 315\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuffer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mconsumed\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mUnicodeDecodeError\u001b[0m: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte" ] } ], - "prompt_number": 166 + "prompt_number": 222 } ], "metadata": {} diff --git a/plc/code_snippet.txt b/plc/code_snippet.txt index 3ef89f9..9f1e454 100644 --- a/plc/code_snippet.txt +++ b/plc/code_snippet.txt @@ -1,26 +1,14 @@ -class Utils - - def self.seconds_to_string(s) - - # d = days, h = hours, m = minutes, s = seconds - m = (s / 60).floor - s = s % 60 - h = (m / 60).floor - m = m % 60 - d = (h / 24).floor - h = h % 24 - - output = "#{s} second#{Utils.pluralize(s)}" if (s > 0) - output = "#{m} minute#{Utils.pluralize(m)}, #{s} second#{Utils.pluralize(s)}" if (m > 0) - output = "#{h} hour#{Utils.pluralize(h)}, #{m} minute#{Utils.pluralize(m)}, #{s} second#{Utils.pluralize(s)}" if (h > 0) - output = "#{d} day#{Utils.pluralize(d)}, #{h} hour#{Utils.pluralize(h)}, #{m} minute#{Utils.pluralize(m)}, #{s} second#{Utils.pluralize(s)}" if (d > 0) - - return output - end - - def self.pluralize number - return "s" unless number == 1 - return "" - end - -end +module BinarySearch where + +a :: [Int] +a = [6, 13, 14, 25, 33, 43, 51, 53, 64, 72, 84, 93, 95, 96, 97] + +bsearch :: Int -> [Int] -> Int +bsearch _ [] = -1 +bsearch key xs + | key < val = bsearch key (take (mid-1) xs) + | key > val = bsearch key (drop (mid+1) xs) + | otherwise = val + where + mid = floor ((fromIntegral $ (length xs) - 1) / 2) + val = xs !! mid diff --git a/plc/picklefile b/plc/picklefile new file mode 100644 index 0000000000000000000000000000000000000000..2f1a3e6c7acfa4e8735af46b06d1dba3b3445235 GIT binary patch literal 10509 zcmaiZcRZKf|G!ZvWMo8SWv^tf*CDIO-lMGS`8Gl%E3#5n6p6YKQrVJ9D3Oe$REi{{ z6bXg+_3gf|%j4Jk(c^Rd(bH=`U+28fbBb@8lTf61Y{z zF*q>L!_n7Z-&O*Na5RDRIDt&aiiU)Q#M#?1FwovVz{4-VopBCgJQC;3DA@ z>>cFc7!cqXw$(ns#o5m{Feo6{IcO_k)4yI@eUJQWC2ZCsIZ2?8CJ?Ah2wQ~o zNcE^s61M*5cqAyy-(@R-+KTK~L01I=jUI^}X##=Pgs@FWkKBs%msW*9XJBBUyZ-C> z{f{0=5P{w)QNwDYzmTFyx)FKaP|oOkSBtJk@VW+0-9vsAYienkH_(((>~L;M9gaQ{ zoWESF(d1di0FjY;T<^Rriw+ub+0|L%mz{Z|{z zCIpt>ZRjb)6Ik81CGJz(PC_#CgrV?!#$`xj6&Lti&<=O=`gSni&j%ja!;V+3c;eWQ zQo+~A<_vG@VkYH}RY6&;nhWQ_7eLxcTJnJ|10E{z(ke-YL;9i?X%6*8kSKT+cVR0x zWDN>TQcEzvo%-`-`^zMO)M2SKiYge_8@}36=+bl!m&2B?Rn9uO;4&7E;o7skpINQ@ zA@+qFx51+Gp7kw5z3s(2fo}ugW$NU2KdBd>eMc)T#s3mWRp!T>)*1uT{Sx$2N(rE0 z!^N2MsSCW{At#@!^r%Xx?B(|z=|G6Rx3zH41O3SdlQlR-TQrnwVBU(dnvOgL?<2YQ zLCy^!DJWB$Weed)P#9g8+&y^?BF`FLaAgdD5ffb>74c`VSmLyua`F)rMEXvxRlfq; zy6m)8D+SzdO4$HerQL=+uS|z(kx=kXO-gc1jlk=W$r9dK%p~A4#_MnRJXY+nVCZe! zpH+%%m0ZLg@@->nPbPH25(hQi0BEA*jJm8K}p*49T`Uh2iQeP6Dw~V9mV! zAnzhKN-b!7e~(ZKSDx=}V2HT{jA^&7#CJZ0d~(egozd5z+Ht(#Xx%Hg>&f<&i6s;Q zK2l^JFdPD*;zTVTN(QtizV!K%>QrE_O**q4LBM(c$?p-l7HPQV5s+1R(s|9Z8s}Nw z_jFKAWCvi#=Q$N5eYhBQ5NzIju@VLU%4r_MeT^_v_2W_d>j)5%Cc9!7B?$Tw($lsR zd3YYIp3O0`syH)8B0W>#fkj>34gcFGjfy_XND}#Bc^03a?2oay2n`Zre3witA?65Q z8egL${9uif{VuvOubC=nUDbSJ{U_c@*FKSV2G3jgt&B=F>pYYisO;~1P=)KUI)CEo z-J_v-jqO0yofWC{;VN_qPx5}r2>=1{c6HfJY`~|NG;VfmKRB>_d->=lH+s0M*nDw) z38wNb!l*S;Atqgk`}}GTSk1g6VRcQ0CApB5zH_fY{IcrZ8T3xCnpD9t z@8&_~17}25{}l9^K6^L37DzOI*C_m{##`2i^cZjEJW1`3TOR_3Ejc-PLG5Lr6*PKK z#wZ4+Pf%UG^Pvgs?K|z>R=5)NkNIKwFtpbPW_Gn)++Xrtwe|Le9$d!!EDljm1Sn<^ z>F)9P4-<2!HC18k>m(1BdOqXrC7m`G=(5Jx$h91^THfRZFWGxIM(7 z##v+cJMdRHNXD7_8rNg>|Auul&4MKo=|uk3dXjX_?V0f9AIm4BpVX0vsr62o7#39M zUtQgwejOYv{a4&#Xpqjq)czX1La1vhjQcLI8C?|HrQLbI4bSIu#r+iT3Ai|4*Smpsp_(3!K{$2~7N4J7n*7AH5gw#rWYc06}@mgo~nU%DG z<2ZF(5K@FL>)Sh%u64q@e z`Or?3XH$^JUD3p+MEdKy#FtwiWy5=>;ctg#qKWKSJq*!_P(dy#7f^N+IafM$6oyks z&HL=+@P6GCPNOC1IAC97qwTpg3PRz_x?#6xVV{-UrZ}b=xG*}OUJ^e8{BQhro1UJ5 z@q7U)d;J+`dzTbDI^zpz35i2}omS8kuNGQ;kp#KOFVn|XUI8QB%e|b6wtt;JpYv=2 z;VzC4^8M^bklgqkV7#3c=PH(_;$dNv;1T1HS}=Yhu=6HWCP3%yo%AvTP=o$vD9$&4kAp&e8KudlFvt#d_N5VQ2gY%wuU)+SxE;%XSU~e0>-7>`&&fvpgX)ta zw55^?<}z&TJD7jw@z9Z>j&7)PbCa)sn*l@pA3dnpb>Y~zrIRxI?-S+0;$qLU4GFUy z$L$y&-nybQ7H7}mddwd~?G=su2UY{%Hl!|CGrR}f+OmRg6gt9aZ)~$`wZ*S_X}V9) z*p1kB=)92NJrAQvAFiCGqCk2VJ};^qScUbranwei0c+plm$tR8fS7A5>3*65m=wC^ z&k!^T1{Zaof8d!0xzg#_(UGl4j#oEqJz^0Kohp^`o-p9knYjzQL>cKZw=M1ArBRrY(iVAP5g#xKJzONUHq3t616Wz0Y!13PE zn4nq=)2Emv$WDESv_q8)BOUcnIVAK;0Dd*4j-;y)KW%?lIKH19u zz5k?srFH%2e-oaq*NJ~QI*iAcw;%OdkuU-qGR;!)m20>j8~xq=i7ZRunb4h@5+ zSDCAgl_by}(>Pms@ngWBU8QMLM1@v454Lr(kf1vc^0KS*JAiS^;l+Di>##;>s4ZwJ zfnk|1S9~qT@jBZ^&dDSQ&cUNX(vAcAYY<=IFOYcWDR|rnKji$4`21pMrVUT}{czgVjd2=bFO-Y%h=37Y{_hdHc)_8(hvb2jHD1Tg z*6Y>H!?keIBkl79jTNrP#{WA1p71MLMz*c{+?JQ+&Er;AAQU zf9>S8q78>v%Xi$^=@#L*%X9Xk*<-L?9kinEHV5waJ4jfw4}g5QCD~iy5jfBEl3PTP z4EfOnuD$Cohnl1Nzp%Ln{B`|VkNT*#`dNX}wx?&-OvZ42$No_=Rutj^<`>uBP^_B6 zs7b}Zb)js?`!=rLX#N0_K1=G1rBB1%1N`wfA11+18FTCO%?4n*yQ%nPe-gZE?lRr0 z#t06yZ0^JSd-1%3W3=X*d9~pBcirZ6e?>s5mnvRf*f{TF8iR%DFr z*ScTPKPKT;X#>n=CsrO*67O@FoZL+hnu;OTpM*=ieLv0v%g-E?+vm=bM5M>;YC@r$ zVwy8}Kg|zyg<6wxaQ~a!d(*o5ilNUut!-K$6RH?J4}^W+g6>`{WaeiiK!Ge*IFc@h z!KO)ViaCAr3*}L^}C*T3$XiVgeCRo)-SYYSdIKRyKT>I2U5f2~4jP3PJ zvf=sXkz-n#MKEytl)_rrG&K0equVpva2;@Tu!2Haf@hZJ`EL(>U6 zrF-9xft5p@_-=KYbf? zn@A6QXuJuFvvUe&w&D=m)XU`hig-OlI*hf@O>5)hIQ!;Hx#DKx^LSc{&mE1fK->=- z&ooL${(6~>{Rq>a8-MuOMrmUo6^iDVDjzk#<2{`8-BUQ((2lp^sg~}iVO)eUyZ>7t zwB;-fPxgA^epo&X_gjr~?fLbcj>(!F_eYx}+C0dyo7oR z&)8dihslN3j-Ljb@c9y*JsR33N4)=Gd>rx&M1(XsAHo`uE0=+l0V_-55p?c>n(!Lli{db4ol!*ezs5`8&U#XK;WEf&aJU z?ilFh;_Xcku-f#?=IMCUksxTb^}jy@odZ1lg9t)an|~?%oE?3<3Bteq{9OXP2_jbH zztsNj{shtA*M!k}g4nJ^x-Z z2D!Tg{kmk7!kXRtf6Ypp5M=O6Mp^8V@t`bQS3s^K`cnMx@_QR2v?r|gagLNV;!WY) z^N5ZeN44w|(ykxq5mO7@gGweB#NcD}m3ht%HHW#8cx;tMlkWDDom||genk~stkC~geuvz5jB=`4A^yX=h4$YN z!Tnx8IL%she+t-m+36?!R-uU1x-a#lCYn$Yv9#%6LwE0zNe?|VLMjYrMBlLJp&29f zH|*U3$i6`JqjB6EV16~X*4eI~aYW^GlGJZ+up*uZcGFHq8+AN(B#JI%$>MeY9JfDZ zfdTKhJH^_#|EzrF>-uL~5dYv5Q`J{>bVxZZXJ`6e+)iddfOG|1=XeLaJ!jH7VlY;y~u|a3 zYkqhEiq3@nWR*CHrtEjM?#oj{`6W4B^8`iI{Ovk-QLi)dd%`O*Z|s3+8fp(q_1L5S z-8+2CM)(j3RsWM&YGcHv(z=<^_YB%k)AFU7Oc9N&4y-zg_2Tvah!jB)%gVmeJ*M0u9o{UJJo?G1RFtafqTwU5tBhi!iI>F*GTxC%cixvTt zcJTYY$6PF^h_sTiU~xOzPIqo+Mx;8PpCaOAHhoVYp66UY>U33=#_hV19nK_l0_fNW zQHEFEhPWQ9^C#vz=%vW<+M=y(fsI_pBv3j@wqVOR7kU>{#badg2*kJCr{bF@ML9oL zR^^mWAkD>&{sfD&2pzv?$Kx%IOuEg}htKJv9(i_xnUyNaJu|S<0q%%t<+V}yHx8u! zuvnrhX%(oI!=-zoPost6;`Dy zPxy8^6B#i3c~3T|qo&fLpaEG=l$|?}Zjw4L)^b(6{xs)dCrPNDcH5pFzAMQYskNyx23@Id^R{j zH|NHW?%m9J2-8rh0&NPg49BX&L~|KlfxF0Gw@?El=s8)xyg|Ja6@ z>P!UpS>*2JV=7T72CrU1SjY1Q?#)irssYu)T<^74u2=rZ1ByaKhW1Kg} z3&Vn*D7_OmXCe8m{(HlV8|Mg`0~%F*Z;X*%UD=8q!4w7lsCPRcYlucw8zYt__aMVy zh}^7w5E*32zPydgFbI4m^}LBv7HqC%59vEQr_N^zfr0 z!XXj#a%`-Bap z-x-I17N2-389sDxmOaE|vILDa8pQLr^P=m`f!meEPor|lO+j|%+34CTjkD2hQzTyZ zqkMA45%HOH7GLPsLwU7cu3?=U@9hC+O2xOjHmLrtuzCB=Ok}@l@>9O;QIw-?TcTk= zJbw}Fj*TS@AJB?x_u!8*5_GYC{l2EA2HwY)9dqu(Q7dpHXw?Q>MUi(4%P}1}6LdGc zmo(JF32~%o(oQufAey6-vb6jNO}uxT+P=ODo#!NXyipM zyS0`i${m>|pMS=T@+7xf$1Itk)BP+z9&-wy&Oqyb_%3@Q8GplSv$(IYGlyd+vgjys zi^>b*rxmtEJ8dWc|j7kl|`=GI@2>rC}IdD!~ zTh$mNMGC>YjbEPMi=HdAF+!_75_WLoa?iI!Ld8E%?KWpZT9NYY54ygApHXdM<;+g> zZ+ty?Te{sVZ+egSZGCF~amMW>I56obPspEw4!R>_+$-O5k6Vc^yuJj zU9-hCO%xP<{L!wNC?sr7zDM|&KI$yZmhL0*MQ5e1Jz2Tog{UmIB?x#$qJ!x*leq#3 z=xp6RKgn4S6wQ1nfWCrw{bBrkwsROfPNqWYp<53u|t?4fwpgXn*sZm2eZX|9; zHE!MQqP4OlWiDyTk7u2_lh3u7dt5f0WeFJ{%Ilh~~EC=_nu7L2s$cBhqwKQMQspm~wqL zK7UOg7TmOKoRH`H2O2$5hj2bv9Sr$*{A2QF)Dp3!7R0KQOCulW6F;ls^pM5z@u>RE zYf!f$>b7T$9%Xq^UeXr+4E{ByV%_txNQXrtty0t+ov10EZcbK5N()=e&Ujg)o?VeE z3Ty|^i4NBBS7ijG3mK=AM?{d4Jms?JWg65q!ZwxfosCR0{^2>#9ESc$DLFax?eFK8 zdeKj(O~YML9gA}5Ri=&iUN%X0WJ>EAh+ev=8Zt|Z_7xYE8@Q7pr}sRgS)Kk!X#EDO zmyI@3oRU;)J7SJhB