npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ctj

v0.2.3

Published

Convert CProjects to JSON

Downloads

12

Readme

ctj

CProject to JSON

Convert ContentMine's CProjects to JSON or other formats.

TOC

Install

npm install --global ctj

or

npm i -g ctj

for short.

Usage

Usage: ctj [options] [command]


Options:

  -V, --version  output the version number
  -h, --help     output usage information


Commands:

  collect [options]  Collect AMI results into one or several JSON files
  rdf [options]      Collect AMI results into a RDF file
  help [cmd]         display help for [cmd]

ctj collect

Convert CProjects to JSON in the most basic way.

Usage: ctj collect [options]


Options:

  -V, --version                output the version number
  -p, --project <path>         CProject folder
  -o, --output <path>          Output directory (directory will be created if it doesn't exist, defaults to CProject folder
  -g, --group-results <items>  group AMI results of all the papers into JSON, grouped by type.
                            specify types to combine, separated by ",". Types are found in the title attribute in the root element of the results.xml file
  -s, --save-separately        save paper JSON and AMI JSON separately
  -M, --no-minify              do not minify JSON output
  -h, --help                   output usage information

Group results

The -g, --group-results flag collects ami results and sorts by topic. This is an example of how it would work for the following CProject:

CProject/
├── PMC1
│   └── results
│       └── word
│           └── frequencies
│               └── results.xml
└── PMC2
    └── results
        └── word
            └── frequencies
                └── results.xml

(files not necessary for this example are omitted)

This is the output:

{
  // Words
  "foo": [
    {
      "count": 31
      "word": "foo"
      "pmcid": "PMC1"
    },
    {
      "count": 18
      "word": "foo"
      "pmcid": "PMC2"
    }
  ],
  "bar": [
    {
      "count": 25
      "word": "bar"
      "pmcid": "PMC2"
    }
  ]
}

There are two articles, PMC1 and PMC2. In their respective results/word/frequencies/results.xml files, it says what words are found how many times. 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. The 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".

Save separately

Output is JSON, in one or multiple files, depending on the flag -s, --save-separately.

One file

Without -s.

// data.json

{

  // Papers
  "articles": {
    ...
    "PMC0000000": {
      "metadata": {
        // JSON from eupmc_result.json
      },
      "AMIResults": {
        // AMI results of this article, sorted by their type
        ...
        "binomial": [
          // Instances of a <result> object in the corresponding <results> object
          ...
          {
            // Attributes of corresponding <result> object
          },
          ...
        ],
        ...
      }
    },
    ...
  },
  
  // AMI results of all articles, sorted by their type
  ...
  "binomial": {
    ...
    "Picea glauca": [
      // Instances of a <result> object with "Picea glauca" as match attribute
      ...
      {
        // Attributes of corresponding <result> object
        ...
        // PubMed Central ID of the paper where the <result> object comes from
        "pmc": "PMC0000000"
      },
      ...
    ],
    ...
  },
  ...
}
Multiple files

With -s.

// articles.json

{
  ...
  "PMC0000000": {
    "metadata": {
      // JSON from eupmc_result.json
    },
    "AMIResults": {
      // AMI results of this article, sorted by their type
      ...
      "binomial": [
        // Instances of a <result> object in the corresponding <results> object
        ...
        {
          // Attributes of corresponding <result> object
        },
        ...
      ],
      ...
    }
  },
  ...
}

// AMI results of all articles, sorted by their type

// binomial.json

{
  ...
  "Picea glauca": [
    // Instances of a <result> object with "Picea glauca" as match attribute
    ...
    {
      // Attributes of corresponding <result> object
      ...
      // PubMed Central ID of the paper where the <result> object comes from
      "pmc": "PMC0000000"
    },
    ...
  ],
  ...
}

// genus.json

{
  ...
  "Pinus": [
    // Instances of a <result> object with "Pinus" as match attribute
    ...
    {
      // Attributes of corresponding <result> object
      ...
      // PubMed Central ID of the paper where the <result> object comes from
      "pmc": "PMC0000000"
    },
    ...
  ],
  ...
}

// etc.

ctj rdf

Convert CProjects to rdf. Currently only Turtle support.

Usage: ctj rdf [options]


Options:

  -V, --version         output the version number
  -p, --project <path>  CProject folder
  -o, --output <path>   Output directory (directory will be created if it doesn't exist, defaults to CProject folder
  -h, --help            output usage information

Outputs triples like this:

@prefix ...

pmcid:PMC1 cito:discusses
  :MD5_HASH_1 ,
  :MD5_HASH_2 .

pmcid:PMC2 cito:discusses
  :MD5_HASH_2 .

:MD5_HASH_1 a type:binomial ; rdfs:label "Speciesii nameus" .
:MD5_HASH_2 a type:genus    ; rdfs:label "Speciesii" .

type:binomial rdfs:label "Species" .
type:genus    rdfs:label "Genus" .