move-wrap remover utility for pgn files

Discussions about Winboard/Xboard. News about engines or programs to use with these GUIs (e.g. tournament managers or adapters) belong in this sub forum.

Moderator: Andres Valverde

move-wrap remover utility for pgn files

Postby Norm Pollock » 31 Jul 2006, 00:28

I wrote a utility to remove "move-wrap" from a pgn file. Move-wrapping is where a move starts on one line and continues onto the next line. It is very annoying to read.

It is available temporarily at

http://www.hoflink.com/~npollock/slim.rar

Usage is in a command window on a "clean" pgn file (no comments, no nags, no variations)

example: slim alpha.pgn

This produces "ourR.pgn" without affecting alpha.pgn.

"ourR.pgn" has 5 full moves per line. No move-wrapping. Lines are little shorter. The overall effect is that the pgns are easier for a human to read. Computer programs will not be affected.
Last edited by Norm Pollock on 31 Jul 2006, 21:47, edited 1 time in total.
Norm Pollock
 
Posts: 217
Joined: 27 Sep 2004, 02:52

Re: move-wrap remover utility for pgn files

Postby Jim Ablett » 31 Jul 2006, 17:43

Hi Norm,

'Slim' now available from my homepage.

Thanks for another very useful little utility.

Regards,
Jim.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

Re: move-wrap remover utility for pgn files

Postby Norm Pollock » 03 Aug 2006, 19:46

Jim Ablett wrote:Hi Norm,

'Slim' now available from my homepage.

Thanks for another very useful little utility.

Regards,
Jim.


Thanks Jim.

I've taken Slim off my temporary site, so if anyone wants to download it, just go to Jim's site at

http://homepages.tesco.net/henry.ablett/jims.html

In its place, I put up a program that is an alternative to Slim. I call it Trim because I don't want to get confused with Slim2 etc. I would appreciate any feedback as to which is preferable- slim or trim.

The download link is

www.hoflink.com/~npollock/trim.exe

What Trim does is fit as many full moves as possible into a line, without resorting to move-wrap (word-wrap of moves). You can also set Trim to the desired output width. The default is 75 characters (which includes a space after the last token, so if you count you would only count 74). You can set the width to any value from 50 to 100.

The output file is also called "outR.pgn"

Here is the usage (no readme included- see the slim readme.txt for information how to "clean" a pgn file)

trim alpha.pgn

(note: alpha.pgn has to be "clean" of comments, nags, variations)

or

trim alpha.pgn 60

The latter sets the width to 60 characters (including a space at the end).
Norm Pollock
 
Posts: 217
Joined: 27 Sep 2004, 02:52

Re: move-wrap remover utility for pgn files

Postby Salvo Spitaleri » 04 Aug 2006, 08:19

Hi Norm :) ,


Trim has a clone ;-) PGN-Extract by David J. Barnes


"Output Line Length (-w)

The -w flag allows an approximate line width to be set for output. The
default value is 75 characters. The following request output lines to be
approximately 100 characters wide:

pgn-extract -w100 file.pgn"


Ciao
Salvo
Salvo Spitaleri
 
Posts: 10
Joined: 04 Oct 2004, 18:46
Location: Italy

Re: move-wrap remover utility for pgn files

Postby Norm Pollock » 04 Aug 2006, 13:53

Salvo Spitaleri wrote:Hi Norm :) ,


Trim has a clone ;-) PGN-Extract by David J. Barnes


"Output Line Length (-w)

The -w flag allows an approximate line width to be set for output. The
default value is 75 characters. The following request output lines to be
approximately 100 characters wide:

pgn-extract -w100 file.pgn"


Ciao
Salvo


Hi Salvo,

pgn-extract is one of my favorite programs. It is my understanding that pgn-extract does not remove "move-wrap" which trim does. Adjusting width is just an add-on for trim and no doubt other programs can do that too.

Speaking of pgn-extract, it is a necessary assistant to trim.exe.

First of all, it can remove comments, nags and variations, which is necessary for trim to work properly.

Second, it can remove a very common "bug" within pgn files. It can do so by using the same command line.

pgn-extract -C -V -N -s %1 -oout.pgn

The program "Scid" for example, creates pgn files with the following "bug": Scid fails to put a space (" ") after the period (".") that follows the move number in a pgn of a game. This is a violation of pgn specs. This bug causes trim to malfunction. However pgn-extract removes the bug by putting in the required "space", and thereafter trim works fine.

-Norm
Norm Pollock
 
Posts: 217
Joined: 27 Sep 2004, 02:52

Re: move-wrap remover utility for pgn files

Postby Salvo Spitaleri » 04 Aug 2006, 14:50

Hi Norm,

Sorry, I miss the "move-wrap" word :?

Can You give me an example?

Ciao
Salvo
Salvo Spitaleri
 
Posts: 10
Joined: 04 Oct 2004, 18:46
Location: Italy

Re: move-wrap remover utility for pgn files

Postby Norm Pollock » 04 Aug 2006, 15:06

Salvo Spitaleri wrote:Hi Norm,

Sorry, I miss the "move-wrap" word :?

Can You give me an example?

Ciao
Salvo


OK. Here are 2 games.

before using trim

Code: Select all
[Event "G-3"]
[Site "?"]
[Date "2006.06.12"]
[Round "1.1"]
[White "Scorpio 1.8"]
[Black "SmarThink"]
[Result "1/2-1/2"]

1. e4 c5 2. d4 cxd4 3. Nf3 e6 4. Nxd4 Nc6 5. Nc3 a6 6. g3 Qc7 7. Bg2 d6 8.
O-O Nf6 9. Nxc6 bxc6 10. Na4 Be7 11. c4 O-O 12. Be3 Rb8 13. Qe2 c5 14. Nc3
Nd7 15. f4 Bf6 16. Qd2 Bxc3 17. Qxc3 f5 18. e5 dxe5 19. fxe5 Bb7 20. Bxb7
Rxb7 21. Rae1 a5 22. Re2 Re8 23. Bf4 Nb6 24. Rd2 a4 25. Rfd1 Qe7 26. Rd6
Nc8 27. R6d3 Nb6 28. Be3 Nd7 29. Rd6 Qf7 30. Bf4 Nf8 31. R1d2 Rc8 32. Be3
Qe8 33. Qa5 Rbc7 34. Qb5 h6 35. h4 Ng6 36. Bf4 Nxf4 37. Qxe8+ Rxe8 38. gxf4
Rb7 39. Rc6 Reb8 40. Rxe6 Rxb2 41. Rf2 Rxf2 42. Kxf2 Rb4 43. Ke3 Rxc4 44.
Rc6 Rc3+ 45. Ke2 Kf7 46. Rc7+ Kg6 47. h5+ Kxh5 48. Rxg7 Rc2+ 49. Ke3 Rxa2
50. e6 Rb2 51. Rc7 Rb3+ 52. Kd2 Kg6 53. Rxc5 Rb4 54. e7 Re4 55. Ra5 Rxe7
56. Rxa4 Kh5 57. Ra6 Re4 58. Rd6 Rxf4 59. Ke3 Rc4 60. Rd8 Kg6 61. Rg8+ Kf7
62. Ra8 h5 63. Kf3 Kg7 64. Ra7+ Kf6 65. Kg3 Rg4+ 66. Kh3 Rg7 67. Ra2 Kg5
68. Rg2+ Kh6 69. Rf2 Rf7 70. Kg3 Kg5 71. Rg2 h4+ 72. Kh3+ Kf4 73. Rf2+ Ke3
74. Ra2 Rh7 75. Ra1 Rh8 76. Ra4 Rh6 77. Ra1 Rh7 78. Re1+ Kf4 79. Rf1+ Kg5
80. Rg1+ Kf6 81. Rf1 Rh6 82. Rd1 Rh8 83. Rf1 Rh5 84. Rf2 Rh6 85. Rd2 Kg5
86. Rg2+ Kf4 87. Rf2+ Ke4 88. Re2+ Kf3 89. Rd2 Rh7 90. Ra2 Rh5 91. Ra5 Kf2
92. Re5 Kf1 93. Re3 Rg5 94. Re5 Rg3+ 95. Kxh4 Rg1 96. Rxf5+ Ke2 1/2-1/2

[Event "G-3"]
[Site "?"]
[Date "2006.06.12"]
[Round "1.2"]
[White "Pseudo"]
[Black "Scorpio 1.8"]
[Result "0-1"]

1. e4 c5 2. d4 cxd4 3. Nf3 e6 4. Nxd4 Nc6 5. Nc3 Qc7 6. Be2 a6 7. O-O Nf6
8. Be3 Be7 9. f4 d6 10. a4 Bd7 11. Kh1 O-O 12. Bf3 Rfe8 13. Nb3 b6 14. g4
Bc8 15. g5 Nd7 16. Bg2 Bb7 17. Qh5 Nb4 18. Rf2 Bf8 19. Rd1 g6 20. Qh3 Nc5
21. Bd4 Bc8 22. Nxc5 e5 23. Nxa6 Rxa6 24. Nb5 Qb8 25. Qb3 exd4 26. Qxb4 d5
27. Qb3 dxe4 28. f5 gxf5 29. Nxd4 f4 30. Nc6 Qc7 31. Nb4 Bxb4 32. Qxb4 f3
33. Bf1 e3 34. Bxa6 Bxa6 35. Qe1 Bb7 36. g6 fxg6 37. c4 Re5 0-1



after using trim

Code: Select all

[Event "G-3"]
[Site "?"]
[Date "2006.06.12"]
[Round "1.1"]
[White "Scorpio 1.8"]
[Black "SmarThink"]
[Result "1/2-1/2"]

1. e4 c5 2. d4 cxd4 3. Nf3 e6 4. Nxd4 Nc6 5. Nc3 a6 6. g3 Qc7 7. Bg2 d6
8. O-O Nf6 9. Nxc6 bxc6 10. Na4 Be7 11. c4 O-O 12. Be3 Rb8 13. Qe2 c5
14. Nc3 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"?"]
[Date "2006.06.12"]
[Round "1.2"]
[White "Pseudo"]
[Black "Scorpio 1.8"]
[Result "0-1"]

1. e4 c5 2. d4 cxd4 3. Nf3 e6 4. Nxd4 Nc6 5. Nc3 Qc7 6. Be2 a6 7. O-O Nf6
8. Be3 Be7 9. f4 d6 10. a4 Bd7 11. Kh1 O-O 12. Bf3 Rfe8 13. Nb3 b6
14. g4 Bc8 15. g5 Nd7 16. Bg2 Bb7 17. Qh5 Nb4 18. Rf2 Bf8 19. Rd1 g6
20. Qh3 Nc5 21. Bd4 Bc8 22. Nxc5 e5 23. Nxa6 Rxa6 24. Nb5 Qb8 25. Qb3 exd4
26. Qxb4 d5 27. Qb3 dxe4 28. f5 gxf5 29. Nxd4 f4 30. Nc6 Qc7 31. Nb4 Bxb4
32. Qxb4 f3 33. Bf1 e3 34. Bxa6 Bxa6 35. Qe1 Bb7 36. g6 fxg6 37. c4 Re5
0-1


Norm Pollock
 
Posts: 217
Joined: 27 Sep 2004, 02:52

Re: move-wrap remover utility for pgn files

Postby Salvo Spitaleri » 04 Aug 2006, 17:26

Hi Norm,

thanks, it's a very useful utility. :D


Ciao
Salvo
Salvo Spitaleri
 
Posts: 10
Joined: 04 Oct 2004, 18:46
Location: Italy


Return to Winboard and related Topics

Who is online

Users browsing this forum: Google [Bot] and 54 guests