Page 1 of 2

delete informant symbols for one color in pgn

Posted: Sat Feb 09, 2019 9:33 am
by Jonathan003
Hi
Does someone know how it's possible to delete informant symbols in a big pgn file, only for one color, (white, or black moves).

I want to use it to filter out main lines from pgn files created with obk2pgn

"PGN Output

Each variation in the original OBK file is output as a separate game in the PGN file. Each move is annotated according to the book score: 3 = !!, 2 = !, 1 = , 0 = ? ."

Than I put a extra ! for one color, with lgpgnmw. Open the pgn in a text editor and delete al !!! annotations. Than I convert the pgn to cbh, and create a search booster. Than I remove the games with !!, !, and ?! in the annotation.

I will end up with only the main lines where chessmaster 9000 added 3 dots to the variation.

I hope someone can help me with that.

Re: delete informant symbols for one color in pgn

Posted: Sat Feb 09, 2019 10:35 pm
by jackd

Re: delete informant symbols for one color in pgn

Posted: Sun Feb 10, 2019 10:05 am
by Jonathan003
Yes I have pgn-exract. I don't think it has an option to only delete comments for white (or black) moves. I know there is a option to delete all comments but that's not what I look for.

Re: delete informant symbols for one color in pgn

Posted: Sun Feb 10, 2019 1:14 pm
by Ferdy
Jonathan003 wrote: Sat Feb 09, 2019 9:33 am Hi
Does someone know how it's possible to delete informant symbols in a big pgn file, only for one color, (white, or black moves).
Could you post a sample game?

Re: delete informant symbols for one color in pgn

Posted: Sun Feb 10, 2019 6:25 pm
by Jonathan003
This is how the output of obkpgn looks like for a white book.

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "-"]
[White "?"]
[Black "?"]
[Result "1/2-1/2"]
1. Nc3 c5? 2. Nf3? Nc6? 3. e4!! g6? 4. Bb5!! Bg7? 5. O-O!! d6? 6. Re1!! Bd7? 7.
a4!! Rc8? 8. d3!! Nf6? 9. Nd5!! O-O? 10. Bg5!! a6? 11. Bxf6!! exf6? 12. Bc4!!
f5? 13. c3!! fxe4? 14. dxe4!!

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "-"]
[White "?"]
[Black "?"]
[Result "1/2-1/2"]
1. Nc3 c5? 2. e4!! a6? 3. Nge2!! d6? 4. g3!! Nc6? 5. Bg2!! g6? 6. d3!! Bg7? 7.
Be3!! Nf6? 8. h3!! Bd7? 9. Qd2!! b5? 10. Bh6!! Bxh6? 11. Qxh6!! Nd4? 12. Nxd4!!
cxd4? 13. Ne2!! e5? 14. O-O!!

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "-"]
[White "?"]
[Black "?"]
[Result "1/2-1/2"]
1. Nc3 c5? 2. e4!! a6? 3. Nge2!! d6? 4. g3!! g6? 5. Bg2!! Nc6?

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "-"]
[White "?"]
[Black "?"]
[Result "1/2-1/2"]
1. Nc3 c5? 2. e4!! a6? 3. Nge2!! d6? 4. g3!! g6? 5. Bg2!! Bg7? 6. d4!! cxd4? 7.
Nxd4!! Nf6? 8. O-O!! O-O? 9. b3!! Nc6? 10. Nxc6!! bxc6? 11. Bb2!! Qa5? 12. Na4!!
Bg4? 13. Qe1!! Qh5? 14. f3!!

Re: delete informant symbols for one color in pgn

Posted: Sun Feb 10, 2019 7:25 pm
by Jonathan003
I would like to delete only the comments for black moves in this file. So I wil be able to search for games with ? or ?! annotation for the white moves in chessbase.

Re: delete informant symbols for one color in pgn

Posted: Sun Feb 10, 2019 8:19 pm
by Jonathan003
I think I have find a solution. I first ad a extra ! to the black moves. Than I search for ?! in a text editor and remove them. I wonder if it can be done without lgpgnmw. Luckily I stil have a copy of it somewhere.

Re: delete informant symbols for one color in pgn

Posted: Mon Feb 11, 2019 9:49 am
by Ferdy
Jonathan003 wrote: Sun Feb 10, 2019 7:25 pm I would like to delete only the comments for black moves in this file. So I wil be able to search for games with ? or ?! annotation for the white moves in chessbase.
Try this move annotation modifier

Sample run:

Code: Select all

enter pgn filename? sample.pgn
enter color of move annotation to be removed (w/b) ? b

Done, see output file out_sample.pgn
Press any key to exit
Note:
Place your pgn file in the same dir with the move anno exe file

Sample output from your posted pgn file.

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "-"]
[White "?"]
[Black "?"]
[Result "1/2-1/2"]

1. Nc3 c5 2. Nf3? Nc6 3. e4!! g6 4. Bb5!! Bg7 5. O-O!! d6 6. Re1!! Bd7 7. a4!! Rc8 8. d3!! Nf6 9. Nd5!! O-O 10. Bg5!! a6 11. Bxf6!! exf6 12. Bc4!! f5 13. c3!! fxe4 14. dxe4!! 1/2-1/2

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "-"]
[White "?"]
[Black "?"]
[Result "1/2-1/2"]

1. Nc3 c5 2. e4!! a6 3. Nge2!! d6 4. g3!! Nc6 5. Bg2!! g6 6. d3!! Bg7 7. Be3!! Nf6 8. h3!! Bd7 9. Qd2!! b5 10. Bh6!! Bxh6 11. Qxh6!! Nd4 12. Nxd4!! cxd4 13. Ne2!! e5 14. O-O!! 1/2-1/2

This program is using the python-chess lib from https://github.com/niklasf/python-chess

Re: delete informant symbols for one color in pgn

Posted: Mon Feb 11, 2019 1:18 pm
by AlvaroBegue
Here's a hacked-together Perl implementation:

Code: Select all

cat kk.pgn | perl -ne '
if (/^\[/ || /^$/) {print; next;}
for $token (split " ", $_) {
  if ($token =~ /^[1-9]/) {$wtm = 1; print "$token "; next;}
  if ($wtm == 0) {$token =~ s/[!\?]//g;}
  print "$token ";
  $wtm = 1-$wtm;
}
print "\n"
'
That removes markings for black. If you want to remove markings for white, use "if ($wtm == 1)". No guarantees, but it seems to work in the example you posted.

Re: delete informant symbols for one color in pgn

Posted: Thu Feb 14, 2019 11:45 am
by Jonathan003
Thanks Ferdy for the tool move annotation modifier.
It works great!

Also thanks for the Perl implementation Alvaro. But I have no experience with Perl implementation.