--- db/prgsrc/makeauthors.pl 2003/01/09 01:43:21 1.3 +++ db/prgsrc/makeauthors.pl 2010/09/24 16:58:57 1.10 @@ -1,5 +1,4 @@ - -#!/usr/local/bin/perl -w +#!/usr/bin/perl -w =head1 NAME @@ -45,47 +44,31 @@ 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 () { - ($number,$nick)=split; + ($number,$nick)=split; + next unless $number; next unless $number=~/^\d+$/; - ($name,$surname)=split ' ',; - $name{$nick}= ucfirst lc $name; - $surname=ucfirst lc $surname; + @parts = split ' ',; + $_ = ucfirst lc $_ foreach @parts; + $surname = pop @parts; + my $name; + $name = $name{$nick}= join ' ', @parts; $surname=~s/\-(.)/"-". uc $1/ge; + $surname=~s/\'(.)/"'". uc $1/ge; $surname{$nick}= $surname; - + $sn = "$name $surname"; +print "$name!$surname\n"; + $sn =~ tr/Ёё/Ее/; + $nickfromname{uc $sn} = $nick; } + $surname{'error'}='Глюков'; $name{'error'}='Очепят'; $surname{'unknown'}='Неизвестный'; $name{'unknown'}='Псевдоним'; -$surname{'team'}='Капитанова'; -$name{'team'}='Команда_'; +$surname{'team'}='Авторов'; +$name{'team'}='Коллектив'; while () @@ -99,23 +82,21 @@ while () $ssnick{$nick}.="|$str"; } - close (NICKS); close (SSNICKS); - - open AUTHORS,"<$authorsfile" or die "Can not open authors"; - +print "REading authors...\n"; while () { + ($nick,$number,$descr)=m/^([a-zA-Z][a-zA-Z\s]+)(\d+)\s+(.*)$/g; if (!$nick) { ($number,$descr)=m/^(\d+)\s+(.*)$/g; $nick='unknown'; } - $nick=~s/\s*$//; +# if ($nick=~s/\s*$//) $descr=~s/([\.\,\:\!\?])/$1 /g; $descr=~s/\\n/ /g; $descr=~s/^\s+//g; @@ -131,21 +112,21 @@ while () } } - +print "printing unknown...\n"; foreach $as(keys %unknick) { print UNICKS "$as \n ", (join "\n ", (grep {$nick{$_}=~/$as/} keys %nick)); print UNICKS "\n"; } -%forbidden=checktable('equalto')? getequalto : (); +%forbidden=tableexists('equalto')? getequalto : (); #print scalar keys %forbidden, "forbidden questions\n"; getbase('QuestionId','Authors'); - while (($QuestionId, $author)=getrow,$QuestionId) { + print "." unless $i++ % 100; next unless $author; $author=~s/([\.\,\:\!\?])/$1 /gm; $author=~s/^\s+//mg; @@ -153,10 +134,15 @@ while (($QuestionId, $author)=getrow,$Qu $author=~s/\s+$//mg; $author=~s/\s+/ /mg; $author=uc $author; - + $author=~s/ё/е/mg; if ($nick = $nick{$author}) { my @a=split ' ',$nick; + foreach $tmp(@a) { + if ($tmp eq '!!!') { + print STDERR "!$author!".$QuestionId."\n"; + } + } push @{$questions{$_}},$QuestionId foreach @a; } else @@ -171,7 +157,6 @@ print scalar keys %nick , " authors foun #print STDERR "$_ ".$name{$_}."!\n" foreach keys %name; - -addauthors($_,$name{$_},$surname{$_},$questions{$_},$ssnick{$_},\%forbidden) foreach keys %questions; +addquestions2author($_,$name{$_},$surname{$_},$questions{$_},$ssnick{$_},\%forbidden) foreach keys %questions; print UNKNOWN "$_\n" foreach sort keys %unknown;