Navigation
Home News Examples Demo Downloads FAQ Documentation Mailing Lists License
Project Status
The latest stable version of GeSHi is 1.0.8.2, released on the 25th of December, 2008.

Supported Languages:
*ABAP
*Actionscript
*ADA
*Apache Log
*AppleScript
*APT sources.list
*ASM (m68k)
*ASM (pic16)
*ASM (x86)
*ASM (z80)
*ASP
*AutoIT
*Backus-Naur form
*Bash
*Basic4GL
*BlitzBasic
*Brainfuck
*C
*C for Macs
*C#
*C++
*C++ (with QT)
*CAD DCL
*CadLisp
*CFDG
*CIL / MSIL
*COBOL
*ColdFusion
*CSS
*D
*Delphi
*Diff File Format
*DIV
*DOS
*DOT language
*Eiffel
*Fortran
*FourJ's Genero
*FreeBasic
*GetText
*glSlang
*GML
*gnuplot
*Groovy
*Haskell
*HQ9+
*HTML
*INI (Config Files)
*Inno
*INTERCAL
*IO
*Java
*Java 5
*Javascript
*KiXtart
*KLone C & C++
*LaTeX
*Lisp
*LOLcode
*LotusScript
*LScript
*Lua
*Make
*mIRC
*MXML
*MySQL
*NSIS
*Objective C
*OCaml
*OpenOffice BASIC
*Oracle 8 & 11 SQL
*Pascal
*Perl
*PHP
*Pixel Bender
*PL/SQL
*POV-Ray
*PowerShell
*Progress (OpenEdge ABL)
*Prolog
*ProvideX
*Python
*Q(uick)BASIC
*robots.txt
*Ruby
*Ruby on Rails
*SAS
*Scala
*Scheme
*Scilab
*SDLBasic
*Smalltalk
*Smarty
*SQL
*T-SQL
*TCL
*thinBasic
*TypoScript
*Uno IDL
*VB.NET
*Verilog
*VHDL
*VIM Script
*Visual BASIC
*Visual Fox Pro
*Visual Prolog
*Whitespace
*Winbatch
*Windows Registry Files
*X++
*XML
*Xorg.conf

GeSHi 1.0.8.2 is the current stable release, with ten new languages and bug fixes over the last release.

GeSHi 1.1.2alpha3 is the current latest version from the development branch, with full C support (see the GeSHi development website).
Help GeSHi out!
If you're using GeSHi, why not help GeSHi out? You can link to GeSHi with this image:
Powered by GeSHi
Get the HTML

Subscribe
RSS 2
Mailing Lists
Freshmeat
Project Record
Vitality: 4477.47
Popularity: 1813.26
Rating: 8.42
Subscriptions: 74
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense 
9:03 am GMT

Demo Results

Here is the highlighted version of your file. If there are any problems with the highlighted version, check you're using the right language, and that your syntax is correct. If there still is a problem, mail a bug report to BenBE@geshi.org.

GeSHi © 2004-2007 Nigel McNie, 2007-2008 Benny Baumann, 2008 Milian Wolff
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use utf8;
  6.  
  7. binmode STDIN, ':utf8';
  8. binmode STDOUT, ':utf8';
  9.  
  10. do "NGramLangModel.pl";
  11.  
  12. our @iy = ( "i", "y", "í", "ý", "I", "Y", "Í", "Ý");
  13.  
  14. sub usage
  15. {
  16.         print "correct.pl trainFile N\n";
  17.         print "Uses train file to train N-gram language model.";
  18.         print "Corrects i/y from STDIN and writes result to STDOUT.\n";
  19. }
  20.  
  21. sub init
  22. {
  23.         my $posib = shift;
  24.         my $tm = shift;
  25.  
  26.         my $i = @{$tm} - 1;
  27.         while ($i >= 0) {
  28.                 ${$posib}[$i] = getPosib($$tm[$i]);
  29.                 $i--;
  30.         }
  31. }
  32.  
  33. sub getPosib
  34. {
  35.         my $word = shift;
  36.         my @posib = ();
  37.         my $ver = 1;
  38.  
  39. #       print "Word: ", $word, "\n";
  40.  
  41.         if ( $word !~ /[íýiyÍÝIY]/) {
  42.                 my @res = ();
  43.                 $res[0] = $word;
  44.                 return @res;
  45.         }
  46.  
  47.         my @chars = split(//, $word);
  48.  
  49.         for my $i ( 0 .. $#chars ) {   
  50.                 my $c = $chars[$i];
  51.                 if ( $c =~ /[íýiyÍÝIY]/) {
  52.                        
  53.                         for my $j ( 0 .. $#iy ) {
  54.                                 # iy char
  55.                                 if ($c eq $iy[$j]) {
  56.                                         my $next = 0;
  57.                                         if ($j %2 == 0) {
  58.                                                 $next = $j + 1;
  59.                                         } else {
  60.                                                 $next = $j - 1;
  61.                                         }
  62.  
  63.                                         for my $v ( 0 .. ($ver - 1) ) {
  64.                                                 $posib[$v][$i] = $c;
  65.  
  66.                                                 for my $tmpI ( 0 .. $i ) {
  67.                                                         $posib[$v + $ver][$tmpI] = $posib[$v][$tmpI];
  68.                                                 }
  69.  
  70.                                                 $posib[$v + $ver][$i] = $iy[$next];
  71.                                         }
  72.  
  73. #                                       print $c, "=>", $iy[$next], ": ", $posib[0], " vs ", $posib[1], "\n";
  74.                                         $ver *= 2;
  75.                                         last;
  76.                                 }
  77. #                               else {
  78. #                                       print $i, ".", $j, ": not ", $iy[$j], "\n";
  79. #                               }
  80.                         }
  81.                 } else {
  82.                         for my $v ( 0 .. ($ver - 1) ) {
  83. #                               print $v, ":", $i, " = ", $c, "\n";    
  84.                                 $posib[$v][$i] = $c;
  85.                         }
  86.                 }
  87.         }
  88.  
  89.         my @res;
  90.  
  91.         for my $i ( 0 .. ($ver - 1) ) {
  92.                 $res[$i] = join("", @{$posib[$i]});
  93. #               print $i, ": ", $res[$i], "\n";
  94.         }
  95.  
  96.         return @res;
  97. }              
  98.        
  99.  
  100. if ( $#ARGV < 0) {
  101.         usage();
  102.         exit(3);
  103. }
  104.  
  105. my $trainFile = $ARGV[0];
  106. my $heldOutFile = $ARGV[1];
  107. my $n = $ARGV[2];
  108. my $bogusFile = $ARGV[3];
  109.  
  110. my $model = NGramLangModel->new($n, $trainFile);
  111. $model->computeProbs();
  112. $model->emSmooth($heldOutFile);
  113.  
  114.  
  115. my $stream = NGramStream->new($bogusFile, $n);
  116.  
  117. my @prob = ();
  118. my @used = ();
  119.  
  120.  
  121. #inicializace
  122. my $ngram = $stream->next();
  123.  
  124. my $i = $n - 1;
  125. while ($i >= 0) {
  126.         my $tmpN = $n - $i;
  127.  
  128. #       print "tmpN: ", $tmpN, "(", $i, ")\n";
  129.  
  130.         my $j = $tmpN - 1;
  131.         while ($j > 0) {
  132.                 $used[$j] = $used[$j - 1];
  133.  
  134. #               print $j, ": ", $used[$j], "\n";
  135.                 $j--;
  136.         }
  137.  
  138.         if ($$ngram[$i] !~ /[íýiyÍÝIY]/) {
  139.                 $used[0] = $$ngram[$i];
  140.         } else {
  141.        
  142.                 my @posib = getPosib($$ngram[$i]);
  143.  
  144.                 my $max = 0;
  145.                 my $maxIndex = 0;
  146.  
  147.                 for my $pos ( 0 .. $#posib ) {
  148.                         $used[0] = $posib[$pos];
  149.                         my $p = $model->getSmoothedProb(\@used, $tmpN);
  150.  
  151.                         if ($p > $max) {
  152.                                 $max = $p;
  153.                                 $maxIndex = $pos;
  154.                         }
  155.                 }
  156.  
  157.                 $used[0] = $posib[$maxIndex];
  158.  
  159. #               print $used[0], ": ", $max, "\n";
  160.         }
  161.  
  162.         print $used[0], "\n";
  163.  
  164.  
  165.         $i--;
  166. }
  167.  
  168.  
  169. while (my $ngram = $stream->next() ) {
  170.         my $i = $n - 1;
  171.         while ($i > 0) {
  172.                 $used[$i] = $used[$i - 1];
  173.                 $i--;
  174.         }
  175.  
  176.         if ($$ngram[0] !~ /[íýiyÍÝIY]/) {
  177.                 $used[0] = $$ngram[0];
  178.         } else {
  179.                 my @posib = getPosib($$ngram[0]);
  180.  
  181.                 my $max = 0;
  182.                 my $maxIndex = 0;
  183.  
  184.                 for my $pos ( 0 .. $#posib ) {
  185.                         $used[0] = $posib[$pos];
  186.                         my $p = $model->getSmoothedProb(\@used, $n);
  187.  
  188.                         if ($p > $max) {
  189.                                 $max = $p;
  190.                                 $maxIndex = $pos;
  191.                         }
  192.                 }
  193.  
  194.                 $used[0] = $posib[$maxIndex];
  195.         }
  196.  
  197.         print $used[0], "\n";
  198. }
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. #if ( $n !~ /\d+/ || $p !~ /0?\.\d+/) {
  206. #       usage();
  207. #       exit(3);
  208. #}
  209.  
  210. my $p = 0;
  211. my $act = 0;
  212. my $lines = 0;
  213.  
  214. while (<STDIN>) {
  215.         my @chars = split(//, $_);
  216.  
  217.         for my $i ( 0 .. $#chars ) {
  218.                 my $c = $chars[$i];
  219.                 if ( $c =~ /[íýiy]/ && rand() < $p && $act < $n) {
  220.                         $c =~ tr/íýiy/ýíyi/;
  221.                         $act++;
  222.                 }
  223.                 print $c;
  224.         }
  225.  
  226.         $lines++;
  227.  
  228.         if ( $act == $n ) {
  229.                 last;
  230.         }
  231. }
  232.  
Parsed in 0.526 seconds at 7.10 KB/s

Statistics

Language used: perl
StatisticYour sourceAverage for perl
Characters in source:3820 (49324 in highlighted result)3341.068
Total time highlighting:0.596 seconds0.354 seconds
Characters per second:6407.128 chars per second0.000/9147.038/314205.844 chars per second


Back to enter source