$d) { $d = strtoupper($d); $d = preg_replace("|[^$abc]|ismU", '', $d); if ($d == '') { unset($dict[$n]); } else { $dict[$n] = $d; } } } function generate_char_haeufigkeit($file) { $dict = file($file); sanitydict($dict); $dict = array_unique($dict); $count = array(); $total = 0; foreach ($dict as $d) { for ($i=0; $i Rel foreach ($count as $n => $f) { $count[$n] = $f / $total; } $max = 0; foreach ($count as $c) if ($c > $max) $max = $c; $count['max'] = $max; return $count; } function generate_char_haeufigkeit_start($file) { $dict = file($file); sanitydict($dict); $dict = array_unique($dict); $count = array(); $total = 0; foreach ($dict as $d) { $total++; $i = 0; $c = substr($d, $i, 1); $count[$c]++; } // Abs -> Rel foreach ($count as $n => $f) { $count[$n] = $f / $total; } $max = 0; foreach ($count as $c) if ($c > $max) $max = $c; $count['max'] = $max; return $count; } function generate_char_haeufigkeit_end($file) { $dict = file($file); sanitydict($dict); $dict = array_unique($dict); $count = array(); $total = 0; foreach ($dict as $d) { $total++; $i = strlen($d)-1; $c = substr($d, $i, 1); $count[$c]++; } // Abs -> Rel foreach ($count as $n => $f) { $count[$n] = $f / $total; } $max = 0; foreach ($count as $c) if ($c > $max) $max = $c; $count['max'] = $max; return $count; } function generate_wordcount($file) { $dict = file($file); sanitydict($dict); $dict = array_unique($dict); return count($dict); } function generate_neighbor_n_lookup($n, $file) { $dict = file($file); sanitydict($dict); $dict = array_unique($dict); $folge = array(); $total = 0; foreach ($dict as $d) { for ($i=0; $i Rel foreach ($folge as $n => $f) { $folge[$n] = $f / $total; } $max = 0; foreach ($folge as $c) if ($c > $max) $max = $c; $folge['max'] = $max; # TODO: fill up return $folge; } function generate_markov_lookup($file) { $n = 2; $dict = file($file); sanitydict($dict); $dict = array_unique($dict); $folge = array(); $total = array(); foreach ($dict as $d) { for ($i=0; $i Rel foreach ($folge as $n => $f) { $total2 = 0; global $abc; for ($u=0; $u