I'm having trouble extracting JSON information. My JSON file contains 100 chapters of a novel. Each chapter contains a number of characters found in the chapter.
For instance:
{"ONE": ["PERSON A", "PERSON B", "PERSON C", "PERSON D", "PERSON A"],
"TWO": ["PERSON A", "PERSON D", "PERSON F", "PERSON G", "PERSON H"],
"THREE": ["PERSON F", "PERSON D", "PERSON A", "PERSON A", "PERSON A"]
... "ONE HUNDRED": ["PERSON B", "PERSON A"]
}
My goal is to design a method to extract how many times two characters co-occurred in the whole book, and two characters can only co-occur once in a chapter. eg, within 100 chapters, I want to know how many times PERSON A and PERSON B co-occurred.
I have two methods in mind, A. Use JSON PATH and filter out the dataset (where PERSON A and B co-occurred), and calculate the number of chapters they co-occurred. (I don't know what to query either :P ) B. Although I'm not really good with JAVASCRIPT. My idea is to define an integer, and then run for loops in every chapter of the JSON file.
I wonder if you guys could share your knowledge with me on this! Thanks!