#!/usr/bin/perl -w # John Cowan wrote this, but relinquishes copyright. Share and enjoy. # Plug in the six source language words in Lojban form into the # @words array. Then run the script and type candidate gismu. use strict; my @words = ("uan", "rakan", "ekspekt", "esper", "predpologa", "mulud"); my @weights = (0.347, 0.196, 0.160, 0.123, 0.089, 0.085); while (<>) { chomp; die "$_ not gismu\n" if length($_) != 5; print "$_ "; my $total = 0; for (my $i = 0; $i < 6; $i++) { my @g = split(//, $_); local $_ = $words[$i]; my $weight = $weights[$i]; my $score = 0; if (/$g[0].*$g[1].*$g[2].*$g[3].*$g[4]/) { $score = 5; } elsif (/$g[0].*$g[1].*$g[2].*$g[3]/) { $score = 4; } elsif (/$g[0].*$g[1].*$g[2].*$g[4]/) { $score = 4; } elsif (/$g[0].*$g[1].*$g[3].*$g[4]/) { $score = 4; } elsif (/$g[0].*$g[2].*$g[3].*$g[4]/) { $score = 4; } elsif (/$g[1].*$g[2].*$g[3].*$g[4]/) { $score = 4; } elsif (/$g[0].*$g[1].*$g[2]/) { $score = 3; } elsif (/$g[0].*$g[1].*$g[3]/) { $score = 3; } elsif (/$g[0].*$g[1].*$g[4]/) { $score = 3; } elsif (/$g[0].*$g[2].*$g[4]/) { $score = 3; } elsif (/$g[0].*$g[2].*$g[3]/) { $score = 3; } elsif (/$g[0].*$g[3].*$g[4]/) { $score = 3; } elsif (/$g[1].*$g[2].*$g[3]/) { $score = 3; } elsif (/$g[1].*$g[2].*$g[4]/) { $score = 3; } elsif (/$g[1].*$g[3].*$g[4]/) { $score = 3; } elsif (/$g[2].*$g[3].*$g[4]/) { $score = 3; } elsif (/$g[0]$g[1]/ || /$g[0].$g[2]/) { $score = 2; } elsif (/$g[1]$g[2]/ || /$g[1].$g[3]/) { $score = 2; } elsif (/$g[2]$g[3]/ || /$g[2].$g[4]/) { $score = 2; } elsif (/$g[3]$g[4]/) { $score = 2; } else { $score = 0; } print "$score "; $total += $score * $weight; } print "$total\n"; }