{"id":19312923,"url":"https://github.com/larsgw/ctj","last_synced_at":"2025-07-11T18:34:47.169Z","repository":{"id":66156311,"uuid":"66555829","full_name":"larsgw/ctj","owner":"larsgw","description":"Node.js program to convert CProjects to JSON files","archived":false,"fork":false,"pushed_at":"2017-08-21T11:16:10.000Z","size":355,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T15:08:07.869Z","etag":null,"topics":["contentmine","cproject","json"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/larsgw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-08-25T12:26:03.000Z","updated_at":"2024-06-20T19:36:15.000Z","dependencies_parsed_at":"2023-02-21T02:15:55.425Z","dependency_job_id":null,"html_url":"https://github.com/larsgw/ctj","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/larsgw/ctj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgw%2Fctj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgw%2Fctj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgw%2Fctj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgw%2Fctj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larsgw","download_url":"https://codeload.github.com/larsgw/ctj/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgw%2Fctj/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264870974,"owners_count":23676339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contentmine","cproject","json"],"created_at":"2024-11-10T00:36:40.274Z","updated_at":"2025-07-11T18:34:47.161Z","avatar_url":"https://github.com/larsgw.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ctj\n_CProject to JSON_\n\nConvert [ContentMine](http://contentmine.org/)'s [CProject](https://github.com/ContentMine/CTree/blob/master/CProject.md)s to JSON or other formats.\n\n## TOC\n\n- [Install](#install)\n- [Usage](#usage)\n  - [ctj collect](#ctj-collect)\n    - [Group results](#group-results)\n    - [Save separately](#save-separately)\n      - [One file](#one-file)\n      - [Multiple files](#multiple-files)\n  - [ctj rdf](#ctj-rdf)\n\n## Install\n\n```js\nnpm install --global ctj\n```\n\nor\n\n```js\nnpm i -g ctj\n```\n\nfor short.\n\n## Usage\n\n    Usage: ctj [options] [command]\n\n\n    Options:\n\n      -V, --version  output the version number\n      -h, --help     output usage information\n\n\n    Commands:\n\n      collect [options]  Collect AMI results into one or several JSON files\n      rdf [options]      Collect AMI results into a RDF file\n      help [cmd]         display help for [cmd]\n\n### ctj collect\n\nConvert CProjects to JSON in the most basic way.\n\n    Usage: ctj collect [options]\n\n\n    Options:\n\n      -V, --version                output the version number\n      -p, --project \u003cpath\u003e         CProject folder\n      -o, --output \u003cpath\u003e          Output directory (directory will be created if it doesn't exist, defaults to CProject folder\n      -g, --group-results \u003citems\u003e  group AMI results of all the papers into JSON, grouped by type.\n                                specify types to combine, separated by \",\". Types are found in the title attribute in the root element of the results.xml file\n      -s, --save-separately        save paper JSON and AMI JSON separately\n      -M, --no-minify              do not minify JSON output\n      -h, --help                   output usage information\n\n#### Group results\n\nThe `-g, --group-results` flag collects ami results and sorts by topic. This is an example of how it would work for the following CProject:\n\n    CProject/\n    ├── PMC1\n    │   └── results\n    │       └── word\n    │           └── frequencies\n    │               └── results.xml\n    └── PMC2\n        └── results\n            └── word\n                └── frequencies\n                    └── results.xml\n\n(files not necessary for this example are omitted)\n\nThis is the output:\n\n```javascript\n{\n  // Words\n  \"foo\": [\n    {\n      \"count\": 31\n      \"word\": \"foo\"\n      \"pmcid\": \"PMC1\"\n    },\n    {\n      \"count\": 18\n      \"word\": \"foo\"\n      \"pmcid\": \"PMC2\"\n    }\n  ],\n  \"bar\": [\n    {\n      \"count\": 25\n      \"word\": \"bar\"\n      \"pmcid\": \"PMC2\"\n    }\n  ]\n}\n```\n\nThere are two articles, **PMC1** and **PMC2**. In their respective `results/word/frequencies/results.xml` files, it says what words are found how many times.\n**PMC1** has the word \"foo\" `31` times. **PMC2** has the word \"foo\" `18` times, and the word \"bar\" `25` times. The word \"foo\" occurs in `2` articles, which is the length of the array in the \"foo\" entry.\nThe word \"bar\" occurs in `1` article, which is the length of the array in the \"bar\" entry. The total number of occurrences is `31 + 18 = 49` for \"foo\" and `25` for \"bar\".\n\n#### Save separately\n\nOutput is JSON, in one or multiple files, depending on the flag `-s, --save-separately`.\n\n##### One file\n\nWithout `-s`.\n\n```javascript\n// data.json\n\n{\n\n  // Papers\n  \"articles\": {\n    ...\n    \"PMC0000000\": {\n      \"metadata\": {\n        // JSON from eupmc_result.json\n      },\n      \"AMIResults\": {\n        // AMI results of this article, sorted by their type\n        ...\n        \"binomial\": [\n          // Instances of a \u003cresult\u003e object in the corresponding \u003cresults\u003e object\n          ...\n          {\n            // Attributes of corresponding \u003cresult\u003e object\n          },\n          ...\n        ],\n        ...\n      }\n    },\n    ...\n  },\n  \n  // AMI results of all articles, sorted by their type\n  ...\n  \"binomial\": {\n    ...\n    \"Picea glauca\": [\n      // Instances of a \u003cresult\u003e object with \"Picea glauca\" as match attribute\n      ...\n      {\n        // Attributes of corresponding \u003cresult\u003e object\n        ...\n        // PubMed Central ID of the paper where the \u003cresult\u003e object comes from\n        \"pmc\": \"PMC0000000\"\n      },\n      ...\n    ],\n    ...\n  },\n  ...\n}\n```\n\n##### Multiple files\n\nWith `-s`.\n\n```javascript\n// articles.json\n\n{\n  ...\n  \"PMC0000000\": {\n    \"metadata\": {\n      // JSON from eupmc_result.json\n    },\n    \"AMIResults\": {\n      // AMI results of this article, sorted by their type\n      ...\n      \"binomial\": [\n        // Instances of a \u003cresult\u003e object in the corresponding \u003cresults\u003e object\n        ...\n        {\n          // Attributes of corresponding \u003cresult\u003e object\n        },\n        ...\n      ],\n      ...\n    }\n  },\n  ...\n}\n\n// AMI results of all articles, sorted by their type\n\n// binomial.json\n\n{\n  ...\n  \"Picea glauca\": [\n    // Instances of a \u003cresult\u003e object with \"Picea glauca\" as match attribute\n    ...\n    {\n      // Attributes of corresponding \u003cresult\u003e object\n      ...\n      // PubMed Central ID of the paper where the \u003cresult\u003e object comes from\n      \"pmc\": \"PMC0000000\"\n    },\n    ...\n  ],\n  ...\n}\n\n// genus.json\n\n{\n  ...\n  \"Pinus\": [\n    // Instances of a \u003cresult\u003e object with \"Pinus\" as match attribute\n    ...\n    {\n      // Attributes of corresponding \u003cresult\u003e object\n      ...\n      // PubMed Central ID of the paper where the \u003cresult\u003e object comes from\n      \"pmc\": \"PMC0000000\"\n    },\n    ...\n  ],\n  ...\n}\n\n// etc.\n```\n\n### ctj rdf\n\nConvert CProjects to rdf. Currently only Turtle support.\n\n    Usage: ctj rdf [options]\n\n\n    Options:\n\n      -V, --version         output the version number\n      -p, --project \u003cpath\u003e  CProject folder\n      -o, --output \u003cpath\u003e   Output directory (directory will be created if it doesn't exist, defaults to CProject folder\n      -h, --help            output usage information\n\nOutputs triples like this:\n\n    @prefix ...\n    \n    pmcid:PMC1 cito:discusses\n      :MD5_HASH_1 ,\n      :MD5_HASH_2 .\n    \n    pmcid:PMC2 cito:discusses\n      :MD5_HASH_2 .\n    \n    :MD5_HASH_1 a type:binomial ; rdfs:label \"Speciesii nameus\" .\n    :MD5_HASH_2 a type:genus    ; rdfs:label \"Speciesii\" .\n    \n    type:binomial rdfs:label \"Species\" .\n    type:genus    rdfs:label \"Genus\" .","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsgw%2Fctj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarsgw%2Fctj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsgw%2Fctj/lists"}