Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathieu Loiseau
MagicWord
Commits
4b3e434a
Commit
4b3e434a
authored
Sep 30, 2019
by
Arnaud Bey
Browse files
fix palindromic bigram weight
parent
9ecc4170
Changes
1
Hide whitespace changes
Inline
Side-by-side
application/src/LexiconBundle/Manager/BigramManager.php
View file @
4b3e434a
...
...
@@ -18,24 +18,24 @@ class BigramManager
public
function
generateBigrams
(
$bigrams
,
$pathLexiconDir
)
{
//hash enregistrant les bigrams déjà écrit à dans $string2print
$grambigrams
=
[];
$grambigrams
=
[];
//Impression des keys
$string2print
=
"Bigrammes
\t
Freq
\t
Poids
\t
Arrondi
\n
"
;
$string2print
=
"Bigrammes
\t
Freq
\t
Poids
\t
Arrondi
\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
;
$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
;
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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment