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

methodius-cli

v1.2.0

Published

Run Methodius from the command line. Analyze text for ngrams and frequencies with ease.

Downloads

38

Readme

Methodius CLI (an N-gram utility)

Methodius A utility for analyzing frequency of text in chunks.

This CLI lets you do it from the command line.

Hippocratic License HL3-LAW-MEDIA-MIL-SOC-SV

npm

Installation

Prerequisites

  • Node LTS (as of September 2023, Node 18.16.0)

Running on-demand

Download this package. Then run

npm install

Globally via NPM

npm i -g methodius-cli

Usage

Basic Scanning

Get all the details:

methodius -f "great-expectations.txt"

Decide what properties you'd like to see: (use -p for each property you want to see)

methodius -f "great-expectations.txt" -p "uniqueWords" -p "uniqueBigrams" -p letterFrequencies

Do the same on multiple files

methodius -f "great-expectations.txt" -f "a-tale-of-two-cities.txt" -p "uniqueWords" -p "uniqueBigrams" -p letterFrequencies

Output multiple files to a directory

methodius -f "great-expectations.txt" -f "a-tale-of-two-cities.txt" -p "uniqueWords" -p "uniqueBigrams" -p letterFrequencies -o "dickens/"

Set your own output file

methodius -f "great-expectations.txt" -f "a-tale-of-two-cities.txt" -p "uniqueWords" -o uniqueWords.json 

Options

| Option | Alias | Description | Defaults | |---|---|---|---| | --files |-f | fully qualified path to a file Required. | samples/alice.txt | | --topLimit |-l | for any methods, this sets the number of top-ngrams to get. Optional. | 15 | | --properties | -p | which properties to return. Optional. Get the list off of the repo | 'bigramFrequencies','trigramFrequencies','letterFrequencies','meanWordSize', 'medianWordSize','wordFrequencies','bigramPositions','trigramPositions', 'uniqueWords' | | --topMethods | -s | which "top" methods to use. optional. | 'topBigrams', 'topTrigrams','topWords',| | --outputFileName | -o | name of the output file. Optional. | analysis.json or <inputfilename>.analysis.json if multiple files. This could also be a directory: analysis/en/ | | --mergeResults| -m | Merges the results files. output will be .merged.json . Optional. | false|

Merging results

--mergeResults, -m, and methodius-merge analyzes all of the results files and creates a single file that contains all of the results. How it merges is based on the type of value for the property:

  • If a property in a results file is an Object or a Map, what's merged are the keys. Duplicates are removed.
  • If a property in a results file is an array or Set (which would be weird because JSON can't output a Set), the arrays are concatenated. Duplicates are removed.
  • If a property in a results file is a number, the numbers are averaged.
Merging results with methodius-merge

If you want to merge results after the fact, you can use the methodius-merge command. This takes all of the same arguments as methodius. It exists so that there's the option to pick the files you merge.


methodius-merge -f "alice.analysis.json" "huck-fin.analysis.json" -o "merged.json"

You can also designate which properties from the analysis files you want to merge:

methodius-merge -f "alice.analysis.json" "huck-fin.analysis.json" -o "merged.json" -p uniqueWords