Subject: | warnings: Using a hash as a reference is deprecated |
Then I call Detect function:
my $cyr_detector = Lingua::DetectCyrillic->new( MaxTokens => 200,
DetectAllLang => 1 );
my ( $coding, $language, $chars_processed, $algorithm ) =
$cyr_detector->Detect( $text );
I got many warnings:
Using a hash as a reference is deprecated at
/usr/local/lib/perl5/site_perl/5.10.1/Lingua/DetectCyrillic.pm line 116.
Using a hash as a reference is deprecated at
/usr/local/lib/perl5/site_perl/5.10.1/Lingua/DetectCyrillic.pm line 213.
Using a hash as a reference is deprecated at
/usr/local/lib/perl5/site_perl/5.10.1/Lingua/DetectCyrillic.pm line 215.
...
I replace '%Stat->' to '$Stat' and warnings is off. Patch in attach
Subject: | patch.diff |
--- DetectCyrillic.pm.orig 2011-04-08 10:45:16.000000000 +0400
+++ DetectCyrillic.pm 2011-04-08 11:00:10.000000000 +0400
@@ -113,7 +113,7 @@ my $Outfile=shift;
########### Ôîðìàò îò÷åòà ##########
format STAT =
@<<<<<<@######@######@######@######@######@##########@##########@######@######
-$key,%Stat->{$key}{GoodTokensChars},%Stat->{$key}{GoodTokensCount},%Stat->{$key}{AllTokensChars},%Stat->{$key}{AllTokensCount},%Stat->{$key}{CharsUkr},%Stat->{$key}{HashScore2Rus},%Stat->{$key}{HashScore2Ukr},%Stat->{$key}{WordsRus},%Stat->{$key}{WordsUkr}
+$key,$Stat{$key}{GoodTokensChars},$Stat{$key}{GoodTokensCount},$Stat{$key}{AllTokensChars},$Stat{$key}{AllTokensCount},$Stat{$key}{CharsUkr},$Stat{$key}{HashScore2Rus},$Stat{$key}{HashScore2Ukr},$Stat{$key}{WordsRus},$Stat{$key}{WordsUkr}
.
# Âûâîäèì îò÷åò. Åñëè íàçâàíèÿ ôàéëà íåò, èëè ýòî stdout - âûâîäèì íà ýêðàí, èíà÷å â ôàéë
@@ -210,9 +210,9 @@ for ( @InputData ) {
my $String=$_;
for (@Codings) {
- _ParseString ($_,$String,%Stat->{$_});
+ _ParseString ($_,$String,$Stat{$_});
# Âûõîäèì, åñëè õîòü ïî îäíîé èç êîäèðîâîê íàáðàëè ìàêñèìàëüíîå ÷èñëî òîêåíîâ
- if (%Stat->{$_}{GoodTokensCount} > $Args{MaxTokens} ) { $EnoughTokens=1; }
+ if ($Stat{$_}{GoodTokensCount} > $Args{MaxTokens} ) { $EnoughTokens=1; }
}
if ( $EnoughTokens ) { last; }
@@ -236,7 +236,7 @@ my $UkrTokensShare=0.01;
## Àíàëèçèðóåì ÷èñòî êèðèëëè÷åñêèå òîêåíû ñ ïðàâèëüíîé êàïèòàëèçàöèåé.
my @CyrCharRating;
-for ( @Codings ) { push @CyrCharRating,[$_, %Stat->{$_}{GoodTokensChars}]; }
+for ( @Codings ) { push @CyrCharRating,[$_, $Stat{$_}{GoodTokensChars}]; }
@CyrCharRating = sort { $b->[1] <=> $a->[1] } @CyrCharRating;
$MaxCharsProcessed = $CyrCharRating[0]->[1];
@@ -260,7 +260,7 @@ if ( scalar(@BestCodings) == 1 ) {
# Îïðåäåëÿåì ÿçûê. Ñìîòðèì, íåò ëè óêðàèíñêèõ òîêåíîâ. Åñëè îíè ïðèñóòñòâóþò
# â êîëè÷åñòâå íå ìåíåå $UkrTokensShare, ñ÷èòàåì ÿçûê óêðàèíñêèì, èíà÷å - ðóññêèì.
-if ( %Stat->{$Coding}{CharsUkr} / %Stat->{$Coding}{GoodTokensCount} > $UkrTokensShare )
+if ( $Stat{$Coding}{CharsUkr} / $Stat{$Coding}{GoodTokensCount} > $UkrTokensShare )
{ $Language = "Ukr"; } else { $Language = "Rus"; }
$Algorithm = 11;
return;
@@ -276,7 +276,7 @@ $BestCoding2 = $CyrCharRating[1]->[0];
# Ïåðâûé âàðèàíò - ýòî êîäèðîâêè koi8u è koi8r.
if ( $BestCoding1 =~ /koi/ && $BestCoding2 =~ /koi/ ) {
# Îïðåäåëÿåì ÿçûê è íà ýòîì îñíîâàíèè - êîäèðîâêó
-if (%Stat->{$Coding}{GoodTokensCount} > 0 && %Stat->{$Coding}{CharsUkr} / %Stat->{$Coding}{GoodTokensCount} > $UkrTokensShare )
+if ($Stat{$Coding}{GoodTokensCount} > 0 && $Stat{$Coding}{CharsUkr} / $Stat{$Coding}{GoodTokensCount} > $UkrTokensShare )
{ $Coding = "koi8u"; $Language = "Ukr"; } else { $Coding = "koi8r"; $Language = "Rus"; }
$Algorithm = 21;
return;
@@ -286,7 +286,7 @@ return;
# ñòðî÷íûìè áóêâàìè áåç Þ è Ý. Ïðåäïî÷èòàåì îäíîçíà÷íî win1251
if ( $BestCoding1 =~ /(win1251|mac)/ && $BestCoding2 =~ /(win1251|mac)/ ) {
$Coding="win1251";
-if (%Stat->{$Coding}{GoodTokensCount} > 0 && %Stat->{$Coding}{CharsUkr} / %Stat->{$Coding}{GoodTokensCount} > $UkrTokensShare )
+if ($Stat{$Coding}{GoodTokensCount} > 0 && $Stat{$Coding}{CharsUkr} / $Stat{$Coding}{GoodTokensCount} > $UkrTokensShare )
{ $Language = "Ukr"; } else { $Language = "Rus"; }
$Algorithm = 22;
return;
@@ -302,7 +302,7 @@ $FullStat = 1;
_GetStat();
# Ïðîâåðÿåì, à åñòü ëè êèðèëëèöà â òåêñòå âîîáùå.
-for ( @BestCodings ) { push @CyrCharRating,[$_, %Stat->{$_}{AllTokensChars}]; }
+for ( @BestCodings ) { push @CyrCharRating,[$_, $Stat{$_}{AllTokensChars}]; }
@CyrCharRating = sort { $b->[1] <=> $a->[1] } @CyrCharRating;
$MaxCharsProcessed = $CyrCharRating[0]->[1];
@@ -321,8 +321,8 @@ if ( $MaxCharsProcessed == 0 ) { $Coding
# Øàã 1. Èùåì ìàêñèìàëüíûé ðåéòèíã ñëîâ èç ÷àñòîòíîãî ñëîâàðÿ
my @WordsRating;
for ( @BestCodings ) {
- push @WordsRating, [$_,"Rus", %Stat->{$_}{WordsRus}];
- push @WordsRating, [$_,"Ukr", %Stat->{$_}{WordsUkr}];
+ push @WordsRating, [$_,"Rus", $Stat{$_}{WordsRus}];
+ push @WordsRating, [$_,"Ukr", $Stat{$_}{WordsUkr}];
}
@WordsRating = sort { $b->[2] <=> $a->[2] } @WordsRating;
@@ -359,9 +359,9 @@ my @HashRating;
for $arrayref ( @BestWordsRating ) {
if ( $arrayref->[1] eq "Rus" ) {
- push @HashRating, [$arrayref->[0],"Rus", %Stat->{$arrayref->[0]}{HashScore2Rus}]; }
+ push @HashRating, [$arrayref->[0],"Rus", $Stat{$arrayref->[0]}{HashScore2Rus}]; }
if ( $arrayref->[1] eq "Ukr" ) {
- push @HashRating, [$arrayref->[0],"Ukr", %Stat->{$arrayref->[0]}{HashScore2Ukr}]; }
+ push @HashRating, [$arrayref->[0],"Ukr", $Stat{$arrayref->[0]}{HashScore2Ukr}]; }
}
@HashRating = sort { $b->[2] <=> $a->[2] } @HashRating;
@@ -405,7 +405,7 @@ for $arrayref ( @HashRating ) {
for $arrayref (@BestHashRating) {
if ( $arrayref ->[0] =~ /win/ ) {
$Coding = "win1251";
- if (%Stat->{$Coding}{GoodTokensCount} > 0 && %Stat->{$Coding}{CharsUkr} / %Stat->{$Coding}{GoodTokensCount} > $UkrTokensShare )
+ if ($Stat{$Coding}{GoodTokensCount} > 0 && $Stat{$Coding}{CharsUkr} / $Stat{$Coding}{GoodTokensCount} > $UkrTokensShare )
{ $Language = "Ukr"; } else { $Language = "Rus"; }
$Algorithm = 33;
return;