Diff for /db/prgsrc/makeauthors.pl between versions 1.7 and 1.8

version 1.7, 2005/12/10 00:03:55 version 1.8, 2010/04/24 17:21:53
Line 44  open STDERR, ">$DUMPDIR/errors"; Line 44  open STDERR, ">$DUMPDIR/errors";
   
   
   
         mydo("DROP TABLE IF EXISTS Authors");  
 mydo("CREATE TABLE Authors  
 (  
                 Id     INT NOT NULL PRIMARY KEY AUTO_INCREMENT,  
                             KEY idkey (Id),  
                 CharId     CHAR(20),  
                 Name   CHAR(50),  
                 Surname CHAR(50),  
                 Nicks TEXT,  
                 QNumber INT  
 )");  
   
 mydo ("DROP TABLE IF EXISTS A2Q");  
 mydo("CREATE TABLE A2Q  
 (  
                 Id  INT NOT NULL PRIMARY KEY AUTO_INCREMENT,  
                 Author INT UNSIGNED ,  
                 Question INT UNSIGNED   
 )  
   
              "  
             );  
   
   
 while (<NICKS>)  while (<NICKS>)
 {  {
      next unless /\S/;
    ($number,$nick)=split;     ($number,$nick)=split;
    next unless $number=~/^\d+$/;     next unless $number=~/^\d+$/;
    ($name,$surname)=split ' ',<NICKS>;     ($name,$surname)=split ' ',<NICKS>;
    $name{$nick}= ucfirst lc $name;     $name{$nick}= ucfirst lc $name;
      $surname||='';
    $surname=ucfirst lc $surname;     $surname=ucfirst lc $surname;
    $surname=~s/\-(.)/"-". uc $1/ge;     $surname=~s/\-(.)/"-". uc $1/ge;
    $surname=~s/\'(.)/"'". uc $1/ge;     $surname=~s/\'(.)/"'". uc $1/ge;
    $surname{$nick}= $surname;     $surname{$nick}= $surname;   
      
 }  }
   
 $surname{'error'}='Глюков';  $surname{'error'}='Глюков';
 $name{'error'}='Очепят';  $name{'error'}='Очепят';
 $surname{'unknown'}='Неизвестный';  $surname{'unknown'}='Неизвестный';
Line 99  while (<SSNICKS>) Line 77  while (<SSNICKS>)
    $ssnick{$nick}.="|$str";     $ssnick{$nick}.="|$str";
 }  }
   
   
 close (NICKS);  close (NICKS);
 close (SSNICKS);  close (SSNICKS);
   
   
   
 open AUTHORS,"<$authorsfile" or die "Can not open authors";  open AUTHORS,"<$authorsfile" or die "Can not open authors";
   print "REading authors...\n";
 while (<AUTHORS>)  while (<AUTHORS>)
 {  {
   
    ($nick,$number,$descr)=m/^([a-zA-Z][a-zA-Z\s]+)(\d+)\s+(.*)$/g;     ($nick,$number,$descr)=m/^([a-zA-Z][a-zA-Z\s]+)(\d+)\s+(.*)$/g;
    if (!$nick)      if (!$nick) 
    {     {
Line 131  while (<AUTHORS>) Line 107  while (<AUTHORS>)
    }     }
 }  }
   
   print "printing unknown...\n";
 foreach $as(keys %unknick)  foreach $as(keys %unknick)
 {  {
     print UNICKS "$as \n ", (join "\n ", (grep {$nick{$_}=~/$as/} keys %nick));      print UNICKS "$as \n ", (join "\n ", (grep {$nick{$_}=~/$as/} keys %nick));
     print UNICKS "\n";      print UNICKS "\n";
 }  }
   
 %forbidden=checktable('equalto')? getequalto : ();  %forbidden=tableexists('equalto')? getequalto : ();
   
 #print scalar keys %forbidden, "forbidden questions\n";  #print scalar keys %forbidden, "forbidden questions\n";
   
 getbase('QuestionId','Authors');  getbase('QuestionId','Authors');
   
 while (($QuestionId, $author)=getrow,$QuestionId)  while (($QuestionId, $author)=getrow,$QuestionId)
 {  {
      print "." unless $i++ % 100;
    next unless $author;     next unless $author;
    $author=~s/([\.\,\:\!\?])/$1 /gm;     $author=~s/([\.\,\:\!\?])/$1 /gm;
    $author=~s/^\s+//mg;     $author=~s/^\s+//mg;
Line 157  while (($QuestionId, $author)=getrow,$Qu Line 133  while (($QuestionId, $author)=getrow,$Qu
    if ($nick = $nick{$author})      if ($nick = $nick{$author}) 
    {      { 
       my @a=split ' ',$nick;        my @a=split ' ',$nick;
    foreach $tmp(@a) {
      if ($tmp eq '!!!') {
        print STDERR "!$author!".$QuestionId."\n";
      }
    }
       push @{$questions{$_}},$QuestionId foreach @a;        push @{$questions{$_}},$QuestionId foreach @a;
    }     }
    else      else 
Line 171  print scalar keys %nick , " authors foun Line 152  print scalar keys %nick , " authors foun
   
   
 #print STDERR "$_ ".$name{$_}."!\n" foreach keys %name;  #print STDERR "$_ ".$name{$_}."!\n" foreach keys %name;
   addquestions2author($_,$name{$_},$surname{$_},$questions{$_},$ssnick{$_},\%forbidden) foreach keys %questions;
 addauthors($_,$name{$_},$surname{$_},$questions{$_},$ssnick{$_},\%forbidden) foreach keys %questions;  
   
 print UNKNOWN "$_\n" foreach sort keys %unknown;  print UNKNOWN "$_\n" foreach sort keys %unknown;

Removed from v.1.7  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>