[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/auth/provider/godb.php on line 137: Undefined array key "PHPSESSID"
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4129: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3008)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4129: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3008)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4129: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3008)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4129: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3008)
goproblems.com • Kyu and dan levels on the sgf files
Page 1 of 1

Kyu and dan levels on the sgf files

Posted: Mon Dec 21, 2009 5:58 am
by jwz
If this is done one can study by degrees of difficulty.

Regards,

Justin

Re: Kyu and dan levels on the sgf files

Posted: Mon Dec 21, 2009 9:46 pm
by tails
Hi, are you talking about the offline version?

Re: Kyu and dan levels on the sgf files

Posted: Fri Dec 25, 2009 6:07 am
by jwz
Yes

Re: Kyu and dan levels on the sgf files

Posted: Fri Dec 25, 2009 11:17 am
by tails
Ok, I'll add the kyu and dan levels ... oh, it's already there! :o

The offline SGF files contain some extended tags:
  • GE : genre
  • DI : difficulty as kyu/dan value
  • DP : difficulty as percentage
  • SO : author (submitter)
  • CO : old coolness value
Check out the value of DI tag; that's what you want.

Re: Kyu and dan levels on the sgf files

Posted: Sat Jan 23, 2010 3:59 am
by jwz
How do you suggest I allocate the right file, because they are individual files and the degrees of difficulty are pretty random.
Thanks

Re: Kyu and dan levels on the sgf files

Posted: Sat Jan 23, 2010 7:24 am
by tails
Hmm... So, you are using some software (such as CGoban) to open SGF files, and not using the offline site archive, right? And, to open a file of a certain level, you wish to know the level by its filename, right?

If you have Perl installed in your system, then this script will rename the files for you. The names will have kyu/dan levels, and be lexicographically sortable by the order of difficulty.

Code: Select all

use strict;
use integer;
chdir("goproblemsSGF");  # <-- modify this for your env.
foreach my $fn (<*.sgf>) {
    my $f;
    open($f,$fn);
    my $t=<$f>;
    close($f);
    my $di=$t=~/DI\[(.*?)\]/?$1:'x';
    my $dp=$t=~/DP\[(.*?)\]/?sprintf("%03d",$1):'x';
    rename($fn,"$dp-$di-$fn");
}
I don't think we can just change the naming rules on the site because that would cause troubles to other users who are using the files.

Re: Kyu and dan levels on the sgf files

Posted: Sun Jan 24, 2010 4:57 am
by jwz
Thank you!

I can program, has been a whole I must say, but that will not be a problem.

Regards!

Re: Kyu and dan levels on the sgf files

Posted: Sat Jul 31, 2010 8:16 pm
by usagi
tails wrote: If you have Perl installed in your system, then this script will rename the files for you. (...)
Great idea tails!

I noticed that the script doesn't handle some SGF files which include line breaks before the tags. This is a bit of a problem, in the current goproblemsSGF collection there are nearly 400 files it won't handle. So I changed your script a bit. This one works on all files. Thanks and good luck everyone.

Code: Select all

# by tails on 2008-10-23
# v1.1 by usagi on 2010-08-01
use strict;
use integer;

foreach my $fn (<*.sgf>) {
    my $f;
    open my $FILE, '<' , $fn or die "can't open $fn $!";

    my $di = 'x';
    my $dp = 'x';

    while (<$FILE>)
    {
      if ( /DI\[(.*?)\]/ )
      {
        $di = $1;
      }
      
      if ( /DP\[(.*?)\]/ )
      {
        $dp = sprintf("%03d",$1);
      }
    }

    rename($fn,"$dp-$di-$fn");
}

Re: Kyu and dan levels on the sgf files

Posted: Sun Aug 01, 2010 5:35 am
by tails
Thank you very much for the nice improvement, Usagi!