--- db/prgsrc/makeauthors.pl 2005/12/10 00:03:55 1.7 +++ db/prgsrc/makeauthors.pl 2010/04/24 17:21:53 1.8 @@ -44,42 +44,20 @@ 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 () { + next unless /\S/; ($number,$nick)=split; next unless $number=~/^\d+$/; ($name,$surname)=split ' ',; $name{$nick}= ucfirst lc $name; + $surname||=''; $surname=ucfirst lc $surname; $surname=~s/\-(.)/"-". uc $1/ge; $surname=~s/\'(.)/"'". uc $1/ge; - $surname{$nick}= $surname; - + $surname{$nick}= $surname; } + $surname{'error'}='Глюков'; $name{'error'}='Очепят'; $surname{'unknown'}='Неизвестный'; @@ -99,16 +77,14 @@ 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) { @@ -131,21 +107,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; @@ -157,6 +133,11 @@ while (($QuestionId, $author)=getrow,$Qu 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 +152,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;