Commit 4b3e434a authored by Arnaud Bey's avatar Arnaud Bey
Browse files

fix palindromic bigram weight

parent 9ecc4170
......@@ -20,22 +20,22 @@ class BigramManager
//hash enregistrant les bigrams déjà écrit à dans $string2print
$grambigrams = [];
//Impression des keys
$string2print="Bigrammes\tFreq\tPoids\tArrondi\n";
$string2print = "Bigrammes\tFreq\tPoids\tArrondi\n";
arsort($bigrams);
$max = max($bigrams);
$nbTranches = 100;#nombre de tranches pour les poids de bigram (on divise $max par $nbtranches et le résultat vaut poids)
$factorBigram=$max/$nbTranches;
$factorBigram = $max/$nbTranches;
foreach ($bigrams as $key => $value) {
$yek = $this->mb_strrev($key);
if (!in_array($key, $grambigrams)) {
$freqInverse=0;
if (isset($bigrams[$yek])) {
$freqInverse=$bigrams[$yek];
$freqInverse = 0;
if ($yek != $key && isset($bigrams[$yek])) {
$freqInverse = $bigrams[$yek];
}
$poids = ($value+$freqInverse)/$factorBigram;
$poids = ($value + $freqInverse) / $factorBigram;
$poidsRound = 1;
if ($poids>1) {
$poidsRound=round($poids);
if ($poids > 1) {
$poidsRound = round($poids);
}
$string2print .= $key."\t".$value."\t".$poids."\t".$poidsRound."\n";
$grambigrams[] = $key;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment