It is currently Sun Aug 18, 2019 3:56 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
Offline
 Post subject: Merging SGFs
Post #1 Posted: Wed Dec 28, 2011 5:23 am 
Oza
User avatar

Posts: 2493
Liked others: 1277
Was liked: 1110
Greetings,

How can I merge a fairly large quantity of sgfs (tsumego probs) into one sgf file?

The reason I ask, is that I recently tried to view single files of Carl Jung's 440 problems on wegoigo on an android phone, and it didn't work so well, and then I installed the merged files which he had at some point made available, and they worked like a charm, so now I would like to try that with some other files as well.

Thanks.

_________________
Go? It's like sharing two bowls of cookies, but one person gets all of them.

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #2 Posted: Wed Dec 28, 2011 6:25 am 
Honinbo

Posts: 8541
Liked others: 1476
Was liked: 1436
KGS: Kirby
Tygem: 커비라고해
A variation is enclosed in parentheses. After the root with basi info (only have one root), you can see the main variation in parentheses. Subvariations are in subparentheses.

To merge another sgf from move 1, just copy that big set of text after the root including parentheses, and paste it after the closing parenthesis of the original file.

If this is confusing, this page may clarify:
http://www.red-bean.com/sgf/sgf4.html

In particular, pretend move A in the first diagram is the first move in your first sgf. Move F can be move 1 from your second sgf. You can see the general pattern that, when a new variation comes up, use parentheses to delimit them.

_________________
it's be happy, not achieve happiness

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #3 Posted: Wed Dec 28, 2011 6:29 am 
Gosei
User avatar

Posts: 1534
Location: Hong Kong
Liked others: 45
Was liked: 516
GD Posts: 1292
Maybe try multigo4
File >> Import Files as Branch

_________________
http://tchan001.wordpress.com
A blog on Asian go books, go sightings, and interesting tidbits
Go is such a beautiful game.

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #4 Posted: Wed Dec 28, 2011 7:58 am 
Lives in gote
User avatar

Posts: 439
Liked others: 85
Was liked: 85
Rank: 5k DGS
GD Posts: 100
I used one of Carl Jung's converters on a set by goplayer2006 on ebay. To combine the sgf files into a single file I found it very easy. I use Ubuntu and I used the 'cat' command to create a single file (actually a number of files one for each difficulty level) that just contained the others. Gogrinder on my android phone took the new file fine. I think weigoigo had problems with it because my phone is cheap and ran out of memory but Gogrinder seems to manage it's memory differently and was okay (these were files with 1000 problems in each). Since they're simple ascii files you can open them up in your favourite text editor anyway.

_________________
I am John. John-I-Am.

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #5 Posted: Wed Dec 28, 2011 9:36 am 
Oza
User avatar

Posts: 2493
Liked others: 1277
Was liked: 1110
@Kirby- since I want to merge hundreds of files, pasting them one by one seems impractical.
@TChan - thanks, that was quite easy. Unfortunately, Wegoigo opens the file, but incorrectly - wegoigo does not show the preview, and instead shows a blank board. I don't know if this is because of Wegoigo or Multigo, but CGoban won't open them either, complaining of a "redundant rule specification."
@CnP I couldn't find Carl Jung's tool. It doesn't seem to be listed here: viewtopic.php?f=18&t=637&start=0

_________________
Go? It's like sharing two bowls of cookies, but one person gets all of them.

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #6 Posted: Wed Dec 28, 2011 9:42 am 
Oza
User avatar

Posts: 2493
Liked others: 1277
Was liked: 1110
Sensei's library points to this sgf merger: http://www.igoweb.org/~wms/comp/sgfMerger/

but the page blithly says:

Quote:
To use it, just run the .jar file as a command line application, with the input SGF files as arguments. It will emit merge.sgf. For example, on Unix you would type:
$ java -jar sgfMerge.jar x.sgf y.sgf z.sgf
On Windows or Mac systems, I'm not sure exactly how to do the same thing, but it should be possible

I'm not computer-savvy enough to be able to figure out how to do this.

_________________
Go? It's like sharing two bowls of cookies, but one person gets all of them.

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #7 Posted: Wed Dec 28, 2011 11:10 am 
Honinbo

Posts: 8686
Liked others: 2544
Was liked: 2985
daal wrote:
Sensei's library points to this sgf merger: http://www.igoweb.org/~wms/comp/sgfMerger/

but the page blithly says:

Quote:
To use it, just run the .jar file as a command line application, with the input SGF files as arguments. It will emit merge.sgf. For example, on Unix you would type:
$ java -jar sgfMerge.jar x.sgf y.sgf z.sgf
On Windows or Mac systems, I'm not sure exactly how to do the same thing, but it should be possible

I'm not computer-savvy enough to be able to figure out how to do this.


Open a terminal, console, or DOS window -- whatever your system calls it -- and navigate to the folder or directory where the sgf files are. I think that the command to do that is cd {directory} for Windows, Macs, and Linux. (CD = change directory :)) then type in the java command (without the $). :)

_________________
The Adkins Principle:

At some point, doesn't thinking have to go on?

— Winona Adkins

I think it's a great idea to talk during sex, as long as it's about snooker.

— Steve Davis

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #8 Posted: Wed Dec 28, 2011 11:54 am 
Oza
User avatar

Posts: 2493
Liked others: 1277
Was liked: 1110
Thanks Bill, but I haven't managed to get farther than opening a command window. Everything I've typed into it so far has resulted in a dos version of a sceptically raised eyebrow.

The sgfs are located in a folder called "tsumego" located at the top level of the partition "D." Can you or anyone else tell me exactly what to type in the command window, and whether I have to type the name of each sgf?

_________________
Go? It's like sharing two bowls of cookies, but one person gets all of them.

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #9 Posted: Wed Dec 28, 2011 11:59 am 
Honinbo

Posts: 8541
Liked others: 1476
Was liked: 1436
KGS: Kirby
Tygem: 커비라고해
daal wrote:
Thanks Bill, but I haven't managed to get farther than opening a command window. Everything I've typed into it so far has resulted in a dos version of a sceptically raised eyebrow.

The sgfs are located in a folder called "tsumego" located at the top level of the partition "D." Can you or anyone else tell me exactly what to type in the command window, and whether I have to type the name of each sgf?


Type "D:" without quotes to get to the D: drive, prior to using any "cd" command.

_________________
it's be happy, not achieve happiness

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #10 Posted: Wed Dec 28, 2011 1:53 pm 
Oza
User avatar

Posts: 2493
Liked others: 1277
Was liked: 1110
Kirby wrote:
daal wrote:
Thanks Bill, but I haven't managed to get farther than opening a command window. Everything I've typed into it so far has resulted in a dos version of a sceptically raised eyebrow.

The sgfs are located in a folder called "tsumego" located at the top level of the partition "D." Can you or anyone else tell me exactly what to type in the command window, and whether I have to type the name of each sgf?


Type "D:" without quotes to get to the D: drive, prior to using any "cd" command.


Thanks, but after typing d in the command module and pressing enter, something appears to the effect of: "The command 'd' is either written wrong or could not be found."

But even if I got to "D," I still need someone to explain how to "navigate" to the folder and what exactly to type.

Thanks.

edit: Here we see demonstrated the failure to impart due importance to little things such as colons.

_________________
Go? It's like sharing two bowls of cookies, but one person gets all of them.


Last edited by daal on Sat Dec 31, 2011 6:24 am, edited 1 time in total.
Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #11 Posted: Wed Dec 28, 2011 2:58 pm 
Honinbo

Posts: 8541
Liked others: 1476
Was liked: 1436
KGS: Kirby
Tygem: 커비라고해
daal wrote:
Kirby wrote:
daal wrote:
Thanks Bill, but I haven't managed to get farther than opening a command window. Everything I've typed into it so far has resulted in a dos version of a sceptically raised eyebrow.

The sgfs are located in a folder called "tsumego" located at the top level of the partition "D." Can you or anyone else tell me exactly what to type in the command window, and whether I have to type the name of each sgf?


Type "D:" without quotes to get to the D: drive, prior to using any "cd" command.


Thanks, but after typing d in the command module and pressing enter, something appears to the effect of: "The command 'd' is either written wrong or could not be found."

But even if I got to "D," I still need someone to explain how to "navigate" to the folder and what exactly to type.

Thanks.


Ok. Go to the start menu, and select run. Type:

cmd

This should open up a command window. The next thing to check is if the java executable - you probably have it - is in the classpath. In other words, you can see if you can execute the java command without specifying the directory. To do that, in the command window, type:

java -version

Just typing:

java

could work to. Confirmthat the command is found.

Assuming java is found, to make things easier on you, simply look at the directory the cmd window is open to. In windows explorer, copy the jar file you downloaded and all sgfs to that directory.

After this, back in the cmd window, type:

java -jar sgfMerge.jar x.sgf y.sgf z.sgf

where x, y, and z are the sgf filenames you want to merge. If you have more than three sgf files, just keep appending more arguments after z.sgf.

If you could not find java, above, let me know, and we can discuss more from there.

_________________
it's be happy, not achieve happiness

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #12 Posted: Wed Dec 28, 2011 4:19 pm 
Oza
User avatar

Posts: 2493
Liked others: 1277
Was liked: 1110
Thanks Kirby. I found java, but when I ran the command, I got "unable to access jarfile sgfMerge.jar...ah, because it's called sgfMerger..x.x back to typing...

Hm. That brought up: "Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to read type -5

at org.igoweb.go.sgf.FileIo.parseParam<FileIo.java:635
at org.igoweb.go.sgf.FileIo.readNode<fileIo.java:349>
at org.igoweb.go.sgf.FileIo.readSgf<FileIo.java:299>
at org.igoweb.go.sgf.FileIo.<Init><FileIo.java:244>
at org.igoweb.sgfMerger.SgfMerger.main<SgfMerger.java:29>

Oh bother. This is too much typing anyway. I have hundreds of tsumego files, and this would take forever to type in all the names. There isn't an easier way?

_________________
Go? It's like sharing two bowls of cookies, but one person gets all of them.

Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #13 Posted: Wed Dec 28, 2011 4:22 pm 
Honinbo

Posts: 8541
Liked others: 1476
Was liked: 1436
KGS: Kirby
Tygem: 커비라고해
daal wrote:
Thanks Kirby. I found java, but when I ran the command, I got "unable to access jarfile sgfMerge.jar...ah, because it's called sgfMerger..x.x back to typing...

Hm. That brought up: "Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to read type -5

at org.igoweb.go.sgf.FileIo.parseParam<FileIo.java:635
at org.igoweb.go.sgf.FileIo.readNode<fileIo.java:349>
at org.igoweb.go.sgf.FileIo.readSgf<FileIo.java:299>
at org.igoweb.go.sgf.FileIo.<Init><FileIo.java:244>
at org.igoweb.sgfMerger.SgfMerger.main<SgfMerger.java:29>

Oh bother. This is too much typing anyway. I have hundreds of tsumego files, and this would take forever to type in all the names. There isn't an easier way?



I'll tell you what... I don't know much about the jar file - I even made a typo in the name. Sorry about that. Zinstead of this hassle, I'll just write up a script and pm it to you. It'll take a few minutes, but I'll send you something ina bit.

_________________
it's be happy, not achieve happiness


This post by Kirby was liked by: daal
Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #14 Posted: Thu Dec 29, 2011 2:34 pm 
Lives with ko

Posts: 159
Liked others: 5
Was liked: 36
Rank: EGF 3d
Edit: This is for windows (but other systems almost same, so do say what you have if not windows).

You can right click on the tsumego folder while holding the shift key, and select "open command prompt here".
Into command prompt type the following.

Code:
type *.sgf > ..\merged.sgf

"type" echoes what is inside a file (similar to "cat" in linux).
This will copy the content of all sgf files in that folder into a new file named merged.sgf in the upper folder (of course you can use a better name for the new file).
WARNING: If the output file (merged.sgf) already exists, then it will be overwritten.


This post by kivi was liked by 2 people: daal, xed_over
Top
 Profile  
 
Offline
 Post subject: Re: Merging SGFs
Post #15 Posted: Sat Dec 31, 2011 5:37 am 
Oza
User avatar

Posts: 2493
Liked others: 1277
Was liked: 1110
Thanks to all for your assistance. Strangely, even kivi's method didn't work on my computer right away (shift right click didn't offer the option "open command prompt here") But since the solution seemed promising, I did figure out enough about navigating in the command window to get to the file where the tsumegos were. Here I'll tell anyone noobier than me how to do it:

First open the command window. You can do this at Start>run and type cmd and hit enter.
1. When the command window opens, you can move to another partition (for example "D") by typing "D:" (with colon, without quotes) and pressing enter.
2. To see what's there, type "dir" , again without quotes, and press enter.
3. To move to one of those folders, type "cd NameOfFolderYouWantToGoTo" (skip the quotes) and press enter.
4. When the name of the folder with the tsumegos is displayed last, you can type the command kivi presented above:
"type *.sgf >..\merged.sgf" (yeah, without quotes) and press enter. This should spit out a merged file "merged.sgf" to the same directory where the original folder with the sgfs is located.
5. If for some reason you need to move up a level (for example if you've navigated to the wrong folder) you can type "cd.." press enter and up you go.

This worked for me, I hope it does for you too.


Now it's time to move on to the next roadblock: how to modify the problems so that the apps recognize the solutions... ;-)

_________________
Go? It's like sharing two bowls of cookies, but one person gets all of them.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group