Kyu and dan levels on the sgf files

Kyu and dan levels on the sgf files

Postby jwz on Mon Dec 21, 2009 5:58 am

If this is done one can study by degrees of difficulty.

Regards,

Justin
jwz
 
Posts: 4
Joined: Mon Dec 21, 2009 4:36 am

Re: Kyu and dan levels on the sgf files

Postby tails on Mon Dec 21, 2009 9:46 pm

Hi, are you talking about the offline version?
tails
 
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm

Re: Kyu and dan levels on the sgf files

Postby jwz on Fri Dec 25, 2009 6:07 am

Yes
jwz
 
Posts: 4
Joined: Mon Dec 21, 2009 4:36 am

Re: Kyu and dan levels on the sgf files

Postby tails on Fri Dec 25, 2009 11:17 am

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.
tails
 
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm

Re: Kyu and dan levels on the sgf files

Postby jwz on Sat Jan 23, 2010 3:59 am

How do you suggest I allocate the right file, because they are individual files and the degrees of difficulty are pretty random.
Thanks
jwz
 
Posts: 4
Joined: Mon Dec 21, 2009 4:36 am

Re: Kyu and dan levels on the sgf files

Postby tails on Sat Jan 23, 2010 7:24 am

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.
tails
 
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm

Re: Kyu and dan levels on the sgf files

Postby jwz on Sun Jan 24, 2010 4:57 am

Thank you!

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

Regards!
jwz
 
Posts: 4
Joined: Mon Dec 21, 2009 4:36 am

Re: Kyu and dan levels on the sgf files

Postby usagi on Sat Jul 31, 2010 8:16 pm

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");
}
usagi
 
Posts: 3
Joined: Sat Jul 31, 2010 6:52 am

Re: Kyu and dan levels on the sgf files

Postby tails on Sun Aug 01, 2010 5:35 am

Thank you very much for the nice improvement, Usagi!
tails
 
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm


Return to Suggestions

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron