Scapple and ChatGPT

I decided I wanted to try once again to use Scapple to help me plot out a novel. But this time, I wanted to be able to “collaborate” with ChatGPT regarding the Scapple layout. That is, I’d create a layout, pass it to ChatGPT, and interact for suggestions, comments, etc., much as I routinely do with text extracts.

However, Scapple doesn’t output a format readable by ChatGPT. After fiddling around for a bit, I persuaded ChatGPT to create a Python script to extract the relational data (nodes and edges) from Scapple’s XML and convert it to json, which ChatGPT groks (I don’t speak Python). The json output includes nodes (Notes) and their labels, and edges (undirected, directed, bidirectional) and their labels, if any. It ignores everything else. It is a CLI filter that reads Scapple XML from standard input and writes json to standard output, such as:
scap2json < foo.scap > foo.json

To use it with ChatGPT, you need to explain what the nodes and edges are in story terms, because they can be just about anything. I used the Wouk WWII duology as a testbed, and used family meetings as the nodes, with who what when where info in the node label, and used edge labels to give causal or other connecting information between nodes.

Here’s a sample output from the script:
{
“nodes”: [
“Prewar reunion: 1939, Washington, DC, Warren, Byron, Rhoda, Madeline, Pug”,
“Chance meeting: 1940, London, Warren, Pug”,
“Midway debriefing: 1942, Hawaii, Pug, Warren”,
“Byron & Natalie part: 1942-1943, Italy, Byron, Natalie”,
“Pug & Rhoda reconnect: 1944, home front, Pug, Rhoda”,
“Postwar reunion: 1945, US, Pug, Byron, Rhoda, Madeline”,
“Pug & Pamela reconnect: 1942-1943, London, Pug, Pamela”
],
“edges”: [
{
“source”: “Prewar reunion: 1939, Washington, DC, Warren, Byron, Rhoda, Madeline, Pug”,
“target”: “Pug & Rhoda reconnect: 1944, home front, Pug, Rhoda”,
“label”: “Rhoda’s affair”,
“direction”: 1
},
{
“source”: “Pug & Pamela reconnect: 1942-1943, London, Pug, Pamela”,
“target”: “Pug & Rhoda reconnect: 1944, home front, Pug, Rhoda”,
“label”: “European war ends”,
“direction”: 1
},
{
“source”: “Postwar reunion: 1945, US, Pug, Byron, Rhoda, Madeline”,
“target”: “Byron & Natalie part: 1942-1943, Italy, Byron, Natalie”,
“label”: “Byron submarine warfare”,
“direction”: 1
},
{
“source”: “Prewar reunion: 1939, Washington, DC, Warren, Byron, Rhoda, Madeline, Pug”,
“target”: “Midway debriefing: 1942, Hawaii, Pug, Warren”,
“label”: “Warren in naval aviation”,
“direction”: 1
},
{
“source”: “Prewar reunion: 1939, Washington, DC, Warren, Byron, Rhoda, Madeline, Pug”,
“target”: “Chance meeting: 1940, London, Warren, Pug”,
“label”: “Pug’s diplomatic mission”,
“direction”: 1
},
{
“source”: “Midway debriefing: 1942, Hawaii, Pug, Warren”,
“target”: “Postwar reunion: 1945, US, Pug, Byron, Rhoda, Madeline”,
“label”: “Warren dies”,
“direction”: 1
},
{
“source”: “Prewar reunion: 1939, Washington, DC, Warren, Byron, Rhoda, Madeline, Pug”,
“target”: “Byron & Natalie part: 1942-1943, Italy, Byron, Natalie”,
“label”: “Byron & Natalie marry”,
“direction”: 1
},
{
“source”: “Chance meeting: 1940, London, Warren, Pug”,
“target”: “Midway debriefing: 1942, Hawaii, Pug, Warren”,
“label”: “Pug becomes FDR advisor”,
“direction”: 1
},
{
“source”: “Pug & Rhoda reconnect: 1944, home front, Pug, Rhoda”,
“target”: “Postwar reunion: 1945, US, Pug, Byron, Rhoda, Madeline”,
“label”: “War ends”,
“direction”: 1
}
]
}

Here is the Scapple test layout:
Wouk2.scap (5.8 KB)

And here is the python script as a .txt.zip file:
scap2json.txt.zip (1.4 KB)

UPDATE: I decided I also needed the script to write out node border information (border style, border line width). Here is a zipped version of the revised script:
scap2json.zip (1.6 KB)

1 Like