delete informant symbols for one color in pgn

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Jonathan003
Posts: 46
Joined: Fri Jul 06, 2018 2:23 pm
Full name: Jonathan Cremers

delete informant symbols for one color in pgn

Post by Jonathan003 » Sat Feb 09, 2019 8: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).

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.

jackd
Posts: 25
Joined: Mon Dec 10, 2018 1:45 pm
Full name: jack d.

Re: delete informant symbols for one color in pgn

Post by jackd » Sat Feb 09, 2019 9:35 pm


Jonathan003
Posts: 46
Joined: Fri Jul 06, 2018 2:23 pm
Full name: Jonathan Cremers

Re: delete informant symbols for one color in pgn

Post by Jonathan003 » Sun Feb 10, 2019 9:05 am

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.

Ferdy
Posts: 4018
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: delete informant symbols for one color in pgn

Post by Ferdy » Sun Feb 10, 2019 12:14 pm

Jonathan003 wrote:
Sat Feb 09, 2019 8: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?

Jonathan003
Posts: 46
Joined: Fri Jul 06, 2018 2:23 pm
Full name: Jonathan Cremers

Re: delete informant symbols for one color in pgn

Post by Jonathan003 » Sun Feb 10, 2019 5:25 pm

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!!

Jonathan003
Posts: 46
Joined: Fri Jul 06, 2018 2:23 pm
Full name: Jonathan Cremers

Re: delete informant symbols for one color in pgn

Post by Jonathan003 » Sun Feb 10, 2019 6: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.

Jonathan003
Posts: 46
Joined: Fri Jul 06, 2018 2:23 pm
Full name: Jonathan Cremers

Re: delete informant symbols for one color in pgn

Post by Jonathan003 » Sun Feb 10, 2019 7:19 pm

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.

Ferdy
Posts: 4018
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: delete informant symbols for one color in pgn

Post by Ferdy » Mon Feb 11, 2019 8:49 am

Jonathan003 wrote:
Sun Feb 10, 2019 6: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

AlvaroBegue
Posts: 919
Joined: Tue Mar 09, 2010 2:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: delete informant symbols for one color in pgn

Post by AlvaroBegue » Mon Feb 11, 2019 12:18 pm

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.

Jonathan003
Posts: 46
Joined: Fri Jul 06, 2018 2:23 pm
Full name: Jonathan Cremers

Re: delete informant symbols for one color in pgn

Post by Jonathan003 » Thu Feb 14, 2019 10:45 am

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.
Last edited by Jonathan003 on Thu Feb 14, 2019 10:49 am, edited 1 time in total.

Post Reply